From scipy-svn at scipy.org Thu Mar 1 12:51:32 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Mar 2007 11:51:32 -0600 (CST) Subject: [Scipy-svn] r2800 - trunk/Lib/sandbox/timeseries Message-ID: <20070301175132.C06F039C1DD@new.scipy.org> Author: pierregm Date: 2007-03-01 11:51:29 -0600 (Thu, 01 Mar 2007) New Revision: 2800 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: tseries : forced the _dates of tsmasked to a DateArray : forced the _dates of a series of 1 variable to the shape of the data Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-03-01 04:43:08 UTC (rev 2799) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-03-01 17:51:29 UTC (rev 2800) @@ -330,7 +330,8 @@ return _data.view(cls) assert(_datadatescompat(_data,newdates)) _data._dates = newdates - _data._defaultdates = _data._dates + if _data._dates.size == _data.size and _data.ndim > 1: + _data._dates.shape = _data.shape _data.observed = observed return _data #............................................ @@ -904,8 +905,11 @@ if dates is None: dshape = data.shape if len(dshape) > 0: + if length is None: + length = dshape[0] + if len(dshape) > 0: dates = date_array(start_date=start_date, end_date=end_date, - length=dshape[0], include_last=include_last, + length=length, include_last=include_last, freq=freq) else: dates = date_array([], freq=freq) @@ -921,7 +925,7 @@ "Returns whether the series is a valid TimeSeries object." return isinstance(series, TimeSeries) -tsmasked = TimeSeries(masked,dates=Date('D',1)) +tsmasked = TimeSeries(masked,dates=DateArray(Date('D',1))) ##### -------------------------------------------------------------------------- #---- ... Additional functions ... @@ -1415,6 +1419,7 @@ dates = date_array_fromlist(dlist) data = masked_array(numeric.arange(10), mask=[1,0,0,0,0]*2, dtype=float_) series = time_series(data, dlist) +# tostr = series._dates.tostring() # import cPickle series_pickled = cPickle.loads(series.dumps()) @@ -1422,13 +1427,5 @@ assert_equal(series_pickled._data, series._data) assert_equal(series_pickled._mask, series._mask) # - data = masked_array(N.matrix(range(10)).T, mask=[1,0,0,0,0]*2) - dates = date_array(start_date=thisday('D'), length=10) - series = time_series(data,dates=dates) - series_pickled = cPickle.loads(series.dumps()) - assert_equal(series_pickled._dates, series._dates) - assert_equal(series_pickled._data, series._data) - assert_equal(series_pickled._mask, series._mask) - assert(isinstance(series_pickled._data, N.matrix)) - + \ No newline at end of file From scipy-svn at scipy.org Thu Mar 1 14:04:04 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Mar 2007 13:04:04 -0600 (CST) Subject: [Scipy-svn] r2801 - trunk/Lib/sandbox/timeseries Message-ID: <20070301190404.BEEA039C0CA@new.scipy.org> Author: mattknox_ca Date: 2007-03-01 13:04:00 -0600 (Thu, 01 Mar 2007) New Revision: 2801 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: removed out of date comment at top of tseries.py Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-03-01 17:51:29 UTC (rev 2800) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-03-01 19:04:00 UTC (rev 2801) @@ -1,22 +1,12 @@ -# pylint: disable-msg=W0201, W0212 """ -Core classes for time/date related arrays. - -The `DateArray` class provides a base for the creation of date-based objects, -using days as the base units. This class could be adapted easily to objects -with a smaller temporal resolution (for example, using one hour, one second as the -base unit). - The `TimeSeries` class provides a base for the definition of time series. A time series is defined here as the combination of two arrays: - an array storing the time information (as a `DateArray` instance); - - an array storing the data (as a `MaskedArray` instance. + - an array storing the data (as a `MaskedArray` instance.) These two classes were liberally adapted from `MaskedArray` class. - - :author: Pierre GF Gerard-Marchant & Matt Knox :contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com :version: $Id$ From scipy-svn at scipy.org Thu Mar 1 16:15:04 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Mar 2007 15:15:04 -0600 (CST) Subject: [Scipy-svn] r2802 - in trunk/Lib/sandbox/maskedarray: . tests Message-ID: <20070301211504.B0F4839C340@new.scipy.org> Author: pierregm Date: 2007-03-01 15:14:59 -0600 (Thu, 01 Mar 2007) New Revision: 2802 Modified: trunk/Lib/sandbox/maskedarray/core.py trunk/Lib/sandbox/maskedarray/tests/test_core.py trunk/Lib/sandbox/maskedarray/tests/test_subclassing.py Log: core : masked_array now accepts a subok argument to prevent the conversion of a MaskedArray subclass to plain MaskedArray tests/test_subclassing : update Modified: trunk/Lib/sandbox/maskedarray/core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/core.py 2007-03-01 19:04:00 UTC (rev 2801) +++ trunk/Lib/sandbox/maskedarray/core.py 2007-03-01 21:14:59 UTC (rev 2802) @@ -980,7 +980,7 @@ _baseclass = numeric.ndarray def __new__(cls, data=None, mask=nomask, dtype=None, copy=False, fill_value=None, keep_mask=True, small_mask=True, hard_mask=False, flag=None, - **options): + subok=True, **options): """array(data, dtype=None, copy=True, mask=nomask, fill_value=None) If `data` is already a ndarray, its dtype becomes the default value of dtype. @@ -992,7 +992,8 @@ # Process data............ _data = numeric.array(data, dtype=dtype, copy=copy, subok=True) _baseclass = getattr(_data, '_baseclass', type(_data)) - _data = _data.view(cls) + if not isinstance(data, MaskedArray) or not subok: + _data = _data.view(cls) # Process mask ........... # Backwards compat if hasattr(data,'_mask') and not isinstance(data, ndarray): Modified: trunk/Lib/sandbox/maskedarray/tests/test_core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_core.py 2007-03-01 19:04:00 UTC (rev 2801) +++ trunk/Lib/sandbox/maskedarray/tests/test_core.py 2007-03-01 21:14:59 UTC (rev 2802) @@ -1106,6 +1106,7 @@ assert_equal(sortedx._mask, [1,1,0,0,0]) def check_ravel(self): + "Tests ravel" a = array([[1,2,3,4,5]], mask=[[0,1,0,0,0]]) aravel = a.ravel() assert_equal(a._mask.shape, a.shape) Modified: trunk/Lib/sandbox/maskedarray/tests/test_subclassing.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_subclassing.py 2007-03-01 19:04:00 UTC (rev 2801) +++ trunk/Lib/sandbox/maskedarray/tests/test_subclassing.py 2007-03-01 21:14:59 UTC (rev 2802) @@ -118,20 +118,27 @@ assert_equal(ym._mask, [1,0,0,0,1]) ym._series._setmask([0,0,0,0,1]) assert_equal(ym._mask, [0,0,0,0,1]) + + def check_subclasspreservation(self): + "Checks that masked_array(...,subok=True) preserves the class." + x = N.arange(5) + m = [0,0,1,0,0] + xinfo = [(i,j) for (i,j) in zip(x,m)] + xsub = MSubArray(x, mask=m, info={'xsub':xinfo}) + # + mxsub = masked_array(xsub, subok=True) + assert isinstance(mxsub, MSubArray) + assert_equal(mxsub.info, xsub.info) + # + mxsub = masked_array(xsub, subok=False) + assert not isinstance(mxsub, MSubArray) + assert isinstance(mxsub, MaskedArray) ################################################################################ if __name__ == '__main__': NumpyTest().run() - if 1: - x = N.arange(5) - m = [0,0,1,0,0] - xinfo = [(i,j) for (i,j) in zip(x,m)] - xsub = MSubArray(x, mask=m, info={'xsub':xinfo}) - # - xsub_low = less(xsub,3) - assert isinstance(xsub, MSubArray) - assert_equal(xsub_low.info, xinfo) + From scipy-svn at scipy.org Thu Mar 1 16:31:06 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Mar 2007 15:31:06 -0600 (CST) Subject: [Scipy-svn] r2803 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070301213106.C386D39C076@new.scipy.org> Author: mattknox_ca Date: 2007-03-01 15:31:03 -0600 (Thu, 01 Mar 2007) New Revision: 2803 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: added strfmt function Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-01 21:14:59 UTC (rev 2802) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-01 21:31:03 UTC (rev 2803) @@ -1,7 +1,9 @@ #include +#include #include #include #include +#include #include "arrayobject.h" static char cseries_doc[] = "Speed sensitive time series operations"; @@ -214,6 +216,7 @@ dinfo->year = year; dinfo->month = month; + dinfo->quarter = ((month-1)/3)+1; dinfo->day = day; dinfo->day_of_week = dInfoCalc_DayOfWeek(absdate); @@ -1164,10 +1167,8 @@ Py_DECREF(start_index_retval); return returnVal; - } - static char cseries_asfreq_doc[] = ""; static PyObject * cseries_asfreq(PyObject *self, PyObject *args) @@ -1338,10 +1339,111 @@ return (PyObject *) newArray; } +static char *str_replace(const char *s, const char *old, const char *new) +{ + char *ret; + int i, count = 0; + size_t newlen = strlen(new); + size_t oldlen = strlen(old); + for (i = 0; s[i] != '\0'; i++) { + if (strstr(&s[i], old) == &s[i]) { + count++; + i += oldlen - 1; + } + } + + ret = malloc(i + 1 + count * (newlen - oldlen)); + if (ret == NULL) return NULL; + + i = 0; + while (*s) { + if (strstr(s, old) == s) { + strcpy(&ret[i], new); + i += newlen; + s += oldlen; + } else { + ret[i++] = *s++; + } + } + ret[i] = '\0'; + + return ret; +} + +static char cseries_strfmt_doc[] = ""; +static PyObject * +cseries_strfmt(PyObject *self, PyObject *args) +{ + + char *orig_fmt_str, *fmt_str, *q_loc; + char *result; + char place_holder[] = "^`"; + struct tm c_date; + struct date_info tempDate; + int result_len; + PyObject *date, *py_result; + + if (!PyArg_ParseTuple(args, "Os:strfmt(datetime, fmt_str)", &date, &orig_fmt_str)) return NULL; + + if (dInfoCalc_SetFromDateAndTime(&tempDate, + PyDateTime_GET_YEAR(date), + PyDateTime_GET_MONTH(date), + PyDateTime_GET_DAY(date), + PyDateTime_DATE_GET_HOUR(date), + PyDateTime_DATE_GET_MINUTE(date), + PyDateTime_DATE_GET_SECOND(date), + GREGORIAN_CALENDAR)) return NULL; + + /* We need to modify the fmt_str passed in to handle our special syntax for quarters. + We can't modify the string passed in directly, so we must make a copy. */ + fmt_str = malloc(strlen(orig_fmt_str)*sizeof(char)); + strcpy(fmt_str, orig_fmt_str); + + if ((q_loc = strstr(fmt_str,"%q")) != NULL) { + q_loc = strstr(fmt_str,"%q"); + strncpy (q_loc,place_holder,2); + } + + c_date.tm_sec = (int)tempDate.second; + c_date.tm_min = tempDate.minute; + c_date.tm_hour = tempDate.hour; + c_date.tm_mday = tempDate.day; + c_date.tm_mon = tempDate.month - 1; + c_date.tm_year = tempDate.year - 1900; + c_date.tm_wday = tempDate.day_of_week; + c_date.tm_yday = tempDate.day_of_year; + c_date.tm_isdst = -1; + + result_len = strlen(orig_fmt_str) + 50; + + result = malloc(result_len * sizeof(char)); + + strftime(result, result_len, fmt_str, &c_date); + + if (q_loc != NULL) { + char *alt_result; + char q_str[2]; + + sprintf(q_str, "%i", tempDate.quarter); + alt_result = str_replace(result, place_holder, q_str); + py_result = PyString_FromString(alt_result); + free(result); + free(alt_result); + } else { + py_result = PyString_FromString(result); + free(result); + } + + return py_result; + +} + + /////////////////////////////////////////////////////////////////////// static PyMethodDef cseries_methods[] = { + {"strfmt", cseries_strfmt, METH_VARARGS, cseries_strfmt_doc}, {"convert", cseries_convert, METH_VARARGS, cseries_convert_doc}, {"asfreq", cseries_asfreq, METH_VARARGS, cseries_asfreq_doc}, {"getDateInfo", cseries_getDateInfo, METH_VARARGS, cseries_getDateInfo_doc}, @@ -1354,6 +1456,7 @@ PyObject *m, *TSER_CONSTANTS; m = Py_InitModule3("cseries", cseries_methods, cseries_doc); import_array(); + PyDateTime_IMPORT; TSER_CONSTANTS = PyDict_New(); From scipy-svn at scipy.org Thu Mar 1 16:39:34 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Mar 2007 15:39:34 -0600 (CST) Subject: [Scipy-svn] r2804 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070301213934.D7F0E39C076@new.scipy.org> Author: mattknox_ca Date: 2007-03-01 15:39:24 -0600 (Thu, 01 Mar 2007) New Revision: 2804 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: fixed segfault error in strfmt Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-01 21:31:03 UTC (rev 2803) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-01 21:39:24 UTC (rev 2804) @@ -1397,7 +1397,7 @@ /* We need to modify the fmt_str passed in to handle our special syntax for quarters. We can't modify the string passed in directly, so we must make a copy. */ - fmt_str = malloc(strlen(orig_fmt_str)*sizeof(char)); + fmt_str = malloc((strlen(orig_fmt_str) + 1)*sizeof(char)); strcpy(fmt_str, orig_fmt_str); if ((q_loc = strstr(fmt_str,"%q")) != NULL) { From scipy-svn at scipy.org Thu Mar 1 16:40:11 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Mar 2007 15:40:11 -0600 (CST) Subject: [Scipy-svn] r2805 - trunk/Lib/sandbox/timeseries Message-ID: <20070301214011.75A5039C076@new.scipy.org> Author: mattknox_ca Date: 2007-03-01 15:40:02 -0600 (Thu, 01 Mar 2007) New Revision: 2805 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: changed strfmt method to call cseries.strfmt Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-01 21:39:24 UTC (rev 2804) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-01 21:40:02 UTC (rev 2805) @@ -371,11 +371,7 @@ "Formats the date" if fmt is None: fmt = self.default_fmtstr[self.freqstr] - qFmt = fmt.replace("%q", "XXXX") - tmpStr = self.datetime.strftime(qFmt) - if "XXXX" in tmpStr: - tmpStr = tmpStr.replace("XXXX", str(self.quarter)) - return tmpStr + return cseries.strfmt(self.datetime, fmt) def __str__(self): return self.strfmt(self.default_fmtstr[self.freqstr]) From scipy-svn at scipy.org Thu Mar 1 17:38:48 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 1 Mar 2007 16:38:48 -0600 (CST) Subject: [Scipy-svn] r2806 - trunk/Lib/sandbox/maskedarray Message-ID: <20070301223848.3A9E239C10A@new.scipy.org> Author: pierregm Date: 2007-03-01 16:38:43 -0600 (Thu, 01 Mar 2007) New Revision: 2806 Modified: trunk/Lib/sandbox/maskedarray/core.py Log: core : array: added the subok optional parameter... Modified: trunk/Lib/sandbox/maskedarray/core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/core.py 2007-03-01 21:40:02 UTC (rev 2805) +++ trunk/Lib/sandbox/maskedarray/core.py 2007-03-01 22:38:43 UTC (rev 2806) @@ -1945,7 +1945,7 @@ masked = masked_singleton masked_array = MaskedArray -def array(data, dtype=None, copy=False, order=False, mask=nomask, +def array(data, dtype=None, copy=False, order=False, mask=nomask, subok=True, keep_mask=True, small_mask=True, hard_mask=None, fill_value=None): """array(data, dtype=None, copy=True, order=False, mask=nomask, keep_mask=True, small_mask=True, fill_value=None) @@ -1953,7 +1953,7 @@ And backwards compatibility... """ #TODO: we should try to put 'order' somwehere - return MaskedArray(data, mask=mask, dtype=dtype, copy=copy, + return MaskedArray(data, mask=mask, dtype=dtype, copy=copy, subok=subok, keep_mask=keep_mask, small_mask=small_mask, hard_mask=hard_mask, fill_value=fill_value) From scipy-svn at scipy.org Fri Mar 2 03:48:22 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Mar 2007 02:48:22 -0600 (CST) Subject: [Scipy-svn] r2807 - in trunk/Lib/sandbox/timeseries: . addons addons/tests Message-ID: <20070302084822.1EF7C39C29C@new.scipy.org> Author: pierregm Date: 2007-03-02 02:48:04 -0600 (Fri, 02 Mar 2007) New Revision: 2807 Added: trunk/Lib/sandbox/timeseries/addons/ trunk/Lib/sandbox/timeseries/addons/__init__.py trunk/Lib/sandbox/timeseries/addons/filters.py trunk/Lib/sandbox/timeseries/addons/interpolate.py trunk/Lib/sandbox/timeseries/addons/tests/ trunk/Lib/sandbox/timeseries/addons/tests/test_filters.py trunk/Lib/sandbox/timeseries/addons/tests/test_interpolate.py Log: extras : deleted, redispatched to addons/filters and addons/interpolate Added: trunk/Lib/sandbox/timeseries/addons/__init__.py =================================================================== --- trunk/Lib/sandbox/timeseries/addons/__init__.py 2007-03-01 22:38:43 UTC (rev 2806) +++ trunk/Lib/sandbox/timeseries/addons/__init__.py 2007-03-02 08:48:04 UTC (rev 2807) @@ -0,0 +1,9 @@ +""" +:author: Pierre GF Gerard-Marchant & Matt Knox +:contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com +:version: $Id$ +""" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" +__version__ = '1.0' +__revision__ = "$Revision$" +__date__ = '$Date$' \ No newline at end of file Property changes on: trunk/Lib/sandbox/timeseries/addons/__init__.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Added: trunk/Lib/sandbox/timeseries/addons/filters.py =================================================================== --- trunk/Lib/sandbox/timeseries/addons/filters.py 2007-03-01 22:38:43 UTC (rev 2806) +++ trunk/Lib/sandbox/timeseries/addons/filters.py 2007-03-02 08:48:04 UTC (rev 2807) @@ -0,0 +1,137 @@ +""" + +A collection of filters for timeseries + +:author: Pierre GF Gerard-Marchant & Matt Knox +:contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com +:version: $Id$ +""" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" +__version__ = '1.0' +__revision__ = "$Revision$" +__date__ = '$Date$' + +import numpy as N +from numpy import bool_, float_ +narray = N.array + +from scipy.signal import convolve, get_window + +import maskedarray as MA +from maskedarray import MaskedArray, nomask, getmask, getmaskarray, masked +marray = MA.array + + +__all__ = ['expmave' + 'running_window', 'running_mean' + ] + +#####--------------------------------------------------------------------------- +#---- --- Moving average functions --- +#####--------------------------------------------------------------------------- +def expmave(data, n, tol=1e-6): + """Calculate the exponential moving average of a series. + +:Parameters: + - `data` (ndarray, MaskedArray) : data is a valid ndarray or MaskedArray + or an instance of a subclass of these types. In particular, TimeSeries + objects are valid here. + - `n` (int) : time periods. Where the smoothing factor is 2/(n + 1) + - `tol` (float, *[1e-6]*) : when `data` contains masked values, this + parameter will determine what points in the result should be masked. + Values in the result that would not be "significantly" impacted (as + determined by this parameter) by the masked values are left unmasked. +""" + if isinstance(data, MaskedArray): + ismasked = (data._mask is not nomask) + else: + ismasked = False + # + k = 2./float(n + 1) + def expmave_sub(a, b): + return b + k * (a - b) + # + if ismasked: + data = data.filled(0) + # + result = N.frompyfunc(expmave_sub, 2, 1).accumulate(data).astype(data.dtype) + if ismasked: + _unmasked = N.logical_not(getmask(data)).astype(float_) + marker = 1 - N.frompyfunc(expmave_sub, 2, 1).accumulate(_unmasked) + result[marker > tol] = masked + # + return result + +#............................................................................... +def running_window(data, window_type, window_size): + """Applies a running window of type window_type and size window_size on the + data. + + Returns a (subclass of) MaskedArray. The k first and k last data are always + masked (with k=window_size//2). When data has a missing value at position i, + the result has missing values in the interval [i-k:i+k+1]. + + +:Parameters: + data : ndarray + Data to process. The array should be at most 2D. On 2D arrays, the window + is applied recursively on each column. + window_type : string/tuple/float + Window type (see Notes) + window_size : integer + The width of the window. + +Notes +----- + +The recognized window types are: boxcar, triang, blackman, hamming, hanning, +bartlett, parzen, bohman, blackmanharris, nuttall, barthann, kaiser (needs beta), +gaussian (needs std), general_gaussian (needs power, width), slepian (needs width). +If the window requires parameters, the window_type argument should be a tuple +with the first argument the string name of the window, and the next arguments +the needed parameters. If window_type is a floating point number, it is interpreted +as the beta parameter of the kaiser window. + +Note also that only boxcar has been thoroughly tested. + """ + # + data = marray(data, copy=True, subok=True) + if data._mask is nomask: + data._mask = N.zeros(data.shape, bool_) + window = get_window(window_type, window_size, fftbins=False) + (n, k) = (len(data), window_size//2) + # + if data.ndim == 1: + data._data.flat = convolve(data._data, window)[k:n+k] / float(window_size) + data._mask[:] = ((convolve(getmaskarray(data), window) > 0)[k:n+k]) + elif data.ndim == 2: + for i in range(data.shape[-1]): + _data = data._data[:,i] + _data.flat = convolve(_data, window)[k:n+k] / float(window_size) + data._mask[:,i] = (convolve(data._mask[:,i], window) > 0)[k:n+k] + else: + raise ValueError, "Data should be at most 2D" + data._mask[:k] = data._mask[-k:] = True + return data + +def running_mean(data, width): + """Computes the running mean of size width on the data. + + Returns a (subclass of) MaskedArray. The k first and k last data are always + masked (with k=window_size//2). When data has a missing value at position i, + the result has missing values in the interval [i-k:i+k+1]. + +:Parameters: + data : ndarray + Data to process. The array should be at most 2D. On 2D arrays, the window + is applied recursively on each column. + window_size : integer + The width of the window. + """ + return running_window(data, 'boxcar', width) + +################################################################################ +if __name__ == '__main__': + from maskedarray.testutils import assert_equal, assert_almost_equal + from timeseries import time_series, thisday + Property changes on: trunk/Lib/sandbox/timeseries/addons/filters.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Added: trunk/Lib/sandbox/timeseries/addons/interpolate.py =================================================================== --- trunk/Lib/sandbox/timeseries/addons/interpolate.py 2007-03-01 22:38:43 UTC (rev 2806) +++ trunk/Lib/sandbox/timeseries/addons/interpolate.py 2007-03-02 08:48:04 UTC (rev 2807) @@ -0,0 +1,115 @@ +""" +A collection of intperolation tools for timeseries + +:author: Pierre GF Gerard-Marchant & Matt Knox +:contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com +:version: $Id$ +""" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" +__version__ = '1.0' +__revision__ = "$Revision$" +__date__ = '$Date$' + + +import numpy.core.numeric as numeric + +from scipy.interpolate import fitpack + +import maskedarray as MA +from maskedarray.core import masked, nomask, getmask +from maskedarray.extras import flatnotmasked_edges +marray = MA.array + + +__all__ = [ + 'forward_fill', 'backward_fill', 'interp_masked1d', + ] + + + + +#####--------------------------------------------------------------------------- +#---- --- Functions for filling in masked values in a masked array --- +#####--------------------------------------------------------------------------- +def forward_fill(marr, maxgap=None): + """forward_fill(marr, maxgap=None) + +Forward fills masked values in a 1-d array when there are less maxgap +consecutive masked values. If maxgap is None, then forward fill all +masked values.""" + # Initialization .................. + if numeric.ndim(marr) > 1: + raise ValueError,"The input array should be 1D only!" + marr = marray(marr, copy=True) + if getmask(marr) is nomask or marr.size == 0: + return marr + # + currGap = 0 + if maxgap is not None: + for i in range(1, marr.size): + if marr._mask[i]: + currGap += 1 + if currGap <= maxgap and not marr._mask[i-1]: + marr._data[i] = marr._data[i-1] + marr._mask[i] = False + elif currGap == maxgap + 1: + marr._mask[i-maxgap:i] = True + else: + currGap = 0 + else: + for i in range(1, marr.size): + # CHECK: We should probable be able to speed things up here + if marr._mask[i] and not marr._mask[i-1]: + marr._data[i] = marr._data[i-1] + marr._mask[i] = False + return marr +#.......................................................... +def backward_fill(marr, maxgap=None): + """backward_fill(marr, maxgap=None) + +Backward fills masked values in a 1-d array when there are less than maxgap +consecutive masked values. If maxgap is None, then backward fills all +masked values. + """ + return forward_fill(marr[::-1], maxgap=maxgap)[::-1] + +#.......................................................... +def interp_masked1d(marr, kind='linear'): + """interp_masked1d(marr, king='linear') + +Interpolates masked values in marr according to method kind. +kind must be one of 'constant', 'linear', 'cubic', quintic' +""" + if numeric.ndim(marr) > 1: + raise ValueError("array must be 1 dimensional!") + # + marr = marray(marr, copy=True) + if getmask(marr) is nomask: + return marr + # + unmaskedIndices = (~marr._mask).nonzero()[0] + if unmaskedIndices.size < 2: + return marr + # + kind = kind.lower() + if kind == 'constant': + return forward_fill(marr) + try: + k = {'linear' : 1, + 'cubic' : 3, + 'quintic' : 5}[kind.lower()] + except KeyError: + raise ValueError("Unsupported interpolation type.") + + first_unmasked, last_unmasked = flatnotmasked_edges(marr) + + vals = marr.data[unmaskedIndices] + + tck = fitpack.splrep(unmaskedIndices, vals, k=k) + + maskedIndices = marr._mask.nonzero()[0] + interpIndices = maskedIndices[(maskedIndices > first_unmasked) & \ + (maskedIndices < last_unmasked)] + marr[interpIndices] = fitpack.splev(interpIndices, tck).astype(marr.dtype) + return marr + Property changes on: trunk/Lib/sandbox/timeseries/addons/interpolate.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Added: trunk/Lib/sandbox/timeseries/addons/tests/test_filters.py =================================================================== --- trunk/Lib/sandbox/timeseries/addons/tests/test_filters.py 2007-03-01 22:38:43 UTC (rev 2806) +++ trunk/Lib/sandbox/timeseries/addons/tests/test_filters.py 2007-03-02 08:48:04 UTC (rev 2807) @@ -0,0 +1,90 @@ +# pylint: disable-msg=W0611, W0612, W0511,R0201 +"""Tests suite for MaskedArray & subclassing. + +:author: Pierre Gerard-Marchant & Matt Knox +:contact: pierregm_at_uga_dot_edu & mattknox_ca_at_hotmail_dot_com +:version: $Id$ +""" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" +__version__ = '1.0' +__revision__ = "$Revision$" +__date__ = '$Date$' + +import numpy as N +import numpy.core.numeric as numeric + +from numpy.testing import NumpyTest, NumpyTestCase + +import maskedarray.testutils +#reload(maskedarray.testutils) +from maskedarray.testutils import * + +import maskedarray.core as coremodule +#reload(coremodule) +from maskedarray.core import MaskedArray, masked + +import tseries +from tseries import time_series, thisday + +import addons.filters +reload(addons.filters) +from addons.filters import running_mean + + +class test_runningmean(NumpyTestCase): + + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + self.data = numeric.arange(25) + self.maskeddata = MaskedArray(self.data) + self.maskeddata[10] = masked + # + def test_onregulararray(self): + data = self.data + for width in [3,5,7]: + k = (width-1)/2 + ravg = running_mean(data,width) + assert(isinstance(ravg, MaskedArray)) + assert_equal(ravg, data) + assert_equal(ravg._mask, [1]*k+[0]*(len(data)-2*k)+[1]*k) + # + def test_onmaskedarray(self): + data = self.maskeddata + for width in [3,5,7]: + k = (width-1)/2 + ravg = running_mean(data,width) + assert(isinstance(ravg, MaskedArray)) + assert_equal(ravg, data) + m = N.zeros(len(data), N.bool_) + m[:k] = m[-k:] = m[10-k:10+k+1] = True + assert_equal(ravg._mask, m) + # + def test_ontimeseries(self): + data = time_series(self.maskeddata, start_date=thisday('D')) + for width in [3,5,7]: + k = (width-1)/2 + ravg = running_mean(data,width) + assert(isinstance(ravg, MaskedArray)) + assert_equal(ravg, data) + m = N.zeros(len(data), N.bool_) + m[:k] = m[-k:] = m[10-k:10+k+1] = True + assert_equal(ravg._mask, m) + assert_equal(ravg._dates, data._dates) + # + def tests_onmultitimeseries(self): + maskeddata = MaskedArray(N.random.random(75).reshape(25,3)) + maskeddata[10] = masked + data = time_series(maskeddata, start_date=thisday('D')) + for width in [3,5,7]: + k = (width-1)/2 + ravg = running_mean(data,width) + assert(isinstance(ravg, MaskedArray)) + assert_almost_equal(ravg[18].squeeze(), data[18-k:18+k+1].mean(0)) + m = N.zeros(data.shape, N.bool_) + m[:k] = m[-k:] = m[10-k:10+k+1] = True + assert_equal(ravg._mask, m) + assert_equal(ravg._dates, data._dates) + +#------------------------------------------------------------------------------ +if __name__ == "__main__": + NumpyTest().run() \ No newline at end of file Property changes on: trunk/Lib/sandbox/timeseries/addons/tests/test_filters.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Added: trunk/Lib/sandbox/timeseries/addons/tests/test_interpolate.py =================================================================== --- trunk/Lib/sandbox/timeseries/addons/tests/test_interpolate.py 2007-03-01 22:38:43 UTC (rev 2806) +++ trunk/Lib/sandbox/timeseries/addons/tests/test_interpolate.py 2007-03-02 08:48:04 UTC (rev 2807) @@ -0,0 +1,66 @@ +""" +:author: Pierre Gerard-Marchant & Matt Knox +:contact: pierregm_at_uga_dot_edu & mattknox_ca_at_hotmail_dot_com +:version: $Id$ +""" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" +__version__ = '1.0' +__revision__ = "$Revision$" +__date__ = '$Date$' + +import numpy as N +import numpy.core.numeric as numeric + +from numpy.testing import NumpyTest, NumpyTestCase + +import maskedarray.testutils +#reload(maskedarray.testutils) +from maskedarray.testutils import * + +import maskedarray.core as coremodule +#reload(coremodule) +from maskedarray.core import MaskedArray, masked + +from addons.interpolate import backward_fill, forward_fill, interp_masked1d + +class test_funcs(NumpyTestCase): + + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + self.mask = [1,0,1,0,0,1,1,0,0,0] + self.data = numeric.arange(10) + self.test_array = masked_array(self.data, mask=self.mask) + + def test_backward_fill (self): + result = masked_array(self.data, mask=self.mask) + result[0] = 1 + result[2] = 3 + + assert_equal(backward_fill(self.test_array, maxgap=1), result) + + result[5] = 7 + result[6] = 7 + + assert_equal(backward_fill(self.test_array), result) + + def test_forward_fill (self): + result = masked_array(self.data, mask=self.mask) + result[2] = 1 + + assert_equal(forward_fill(self.test_array, maxgap=1), result) + + result[5] = 4 + result[6] = 4 + + assert_equal(forward_fill(self.test_array), result) + + def test_interp_fill(self): + result_lin = masked_array(self.data).astype(float_) + result_lin[0] = masked + + approx(interp_masked1d(self.test_array.astype(float_), kind='linear'), result_lin) + +############################################################################### +#------------------------------------------------------------------------------ +if __name__ == "__main__": + NumpyTest().run() \ No newline at end of file Property changes on: trunk/Lib/sandbox/timeseries/addons/tests/test_interpolate.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id From scipy-svn at scipy.org Fri Mar 2 03:48:46 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Mar 2007 02:48:46 -0600 (CST) Subject: [Scipy-svn] r2808 - trunk/Lib/sandbox/timeseries Message-ID: <20070302084846.186E239C34C@new.scipy.org> Author: pierregm Date: 2007-03-02 02:48:36 -0600 (Fri, 02 Mar 2007) New Revision: 2808 Removed: trunk/Lib/sandbox/timeseries/extras.py trunk/Lib/sandbox/timeseries/tdates.py Log: extras : deleted, redispatched to addons/filters and addons/interpolate Deleted: trunk/Lib/sandbox/timeseries/extras.py =================================================================== --- trunk/Lib/sandbox/timeseries/extras.py 2007-03-02 08:48:04 UTC (rev 2807) +++ trunk/Lib/sandbox/timeseries/extras.py 2007-03-02 08:48:36 UTC (rev 2808) @@ -1,148 +0,0 @@ -"""Time Series add-ons. - -A collection of utilities for timeseries - -:author: Pierre GF Gerard-Marchant & Matt Knox -:contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com -:version: $Id$ -""" -__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" -__version__ = '1.0' -__revision__ = "$Revision$" -__date__ = '$Date$' - -__all__ = [ - 'forward_fill', 'backward_fill', 'interp_masked1d', - 'expmave' - ] - -import numpy as N -from scipy.interpolate import fitpack -import maskedarray as MA -from maskedarray import masked, nomask, getmask, MaskedArray -import numpy.core.numeric as numeric - -#####--------------------------------------------------------------------------- -#---- --- Functions for filling in masked values in a masked array --- -#####--------------------------------------------------------------------------- - -def forward_fill(marr, maxgap=None): - """forward_fill(marr, maxgap=None) - -Forward fill masked values in a 1-d array when there are <= maxgap -consecutive masked values. If maxgap is None, then forward fill all -masked values.""" - - if numeric.ndim(marr) > 1: - raise ValueError,"The input array should be 1D only!" - - marr = MA.array(marr, copy=True) - if getmask(marr) is nomask or marr.size == 0: - return marr - - currGap = 0 - - if maxgap is not None: - for i in range(1, marr.size): - if marr._mask[i]: - currGap += 1 - if currGap <= maxgap and not marr._mask[i-1]: - marr._data[i] = marr._data[i-1] - marr._mask[i] = False - elif currGap == maxgap + 1: - marr._mask[i-maxgap:i] = True - else: - currGap = 0 - else: - for i in range(1, marr.size): - if marr._mask[i] and not marr._mask[i-1]: - marr._data[i] = marr._data[i-1] - marr._mask[i] = False - return marr - - -def backward_fill(marr, maxgap=None): - """backward_fill(marr, maxgap=None) - -backward fill masked values in a 1-d array when there are <= maxgap -consecutive masked values. If maxgap is None, then backward fill all -masked values.""" - return forward_fill(marr[::-1], maxgap=maxgap)[::-1] - - -def interp_masked1d(marr, kind='linear'): - """interp_masked1d(marr, king='linear') - -Interpolate masked values in marr according to method kind. -kind must be one of 'constant', 'linear', 'cubic', quintic' -""" - if numeric.ndim(marr) > 1: - raise ValueError("array must be 1 dimensional!") - # - marr = MA.array(marr, copy=True) - if getmask(marr) is nomask: - return marr - # - unmaskedIndices = (~marr._mask).nonzero()[0] - if unmaskedIndices.size < 2: - return marr - # - kind = kind.lower() - if kind == 'constant': - return forward_fill(marr) - try: - k = {'linear' : 1, - 'cubic' : 3, - 'quintic' : 5}[kind.lower()] - except KeyError: - raise ValueError("Unsupported interpolation type.") - - first_unmasked, last_unmasked = MA.extras.flatnotmasked_edges(marr) - - vals = marr.data[unmaskedIndices] - - tck = fitpack.splrep(unmaskedIndices, vals, k=k) - - maskedIndices = marr._mask.nonzero()[0] - interpIndices = maskedIndices[(maskedIndices > first_unmasked) & \ - (maskedIndices < last_unmasked)] - marr[interpIndices] = fitpack.splev(interpIndices, tck).astype(marr.dtype) - return marr - - -#####--------------------------------------------------------------------------- -#---- --- Moving average functions --- -#####--------------------------------------------------------------------------- - -def expmave(data, n, tol=1e-6): - """calculate exponential moving average of a series. - -:Parameters: - - `data` (ndarray, MaskedArray) : data is a valid ndarray or MaskedArray - or an instance of a subclass of these types. In particular, TimeSeries - objects are valid here. - - `n` (int) : time periods. Where the smoothing factor is 2/(n + 1) - - `tol` (float, *[1e-6]*) : when `data` contains masked values, this - parameter will determine what points in the result should be masked. - Values in the result that would not be "significantly" impacted (as - determined by this parameter) by the masked values are left unmasked. -""" - if isinstance(data, MaskedArray): - ismasked = (data._mask is not nomask) - else: - ismasked = False - - k = 2./float(n + 1) - def expmave_sub(a, b): - return b + k * (a - b) - - if ismasked: - data = data.filled(0) - - result = N.frompyfunc(expmave_sub, 2, 1).accumulate(data).astype(data.dtype) - if ismasked: - _unmasked = N.logical_not(MA.getmask(data)).astype(N.float_) - marker = 1 - N.frompyfunc(expmave_sub, 2, 1).accumulate(_unmasked) - result[marker > tol] = masked - - return result Deleted: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-02 08:48:04 UTC (rev 2807) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-02 08:48:36 UTC (rev 2808) @@ -1,1064 +0,0 @@ -""" -Classes definition for the support of individual dates and array of dates. - -:author: Pierre GF Gerard-Marchant & Matt Knox -:contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com -:version: $Id$ -""" -__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" -__version__ = '1.0' -__revision__ = "$Revision$" -__date__ = '$Date$' - -import datetime as dt - -import itertools -import warnings -import types - - -import numpy -from numpy import bool_, float_, int_, object_ -from numpy import ndarray -import numpy.core.numeric as numeric -import numpy.core.fromnumeric as fromnumeric -import numpy.core.numerictypes as ntypes -from numpy.core.numerictypes import generic - -import maskedarray as MA - -try: - from mx.DateTime import DateTimeType -except ImportError: - class DateTimeType: pass - -from parser import DateFromString, DateTimeFromString - -import tcore as corelib -import cseries - - - -__all__ = [ -'Date', 'DateArray','isDate','isDateArray', -'DateError', 'ArithmeticDateError', 'FrequencyDateError','InsufficientDateError', -'datearray','date_array', 'date_array_fromlist', 'date_array_fromrange', -'day_of_week','day_of_year','day','month','quarter','year','hour','minute','second', -'truncateDate','monthToQuarter','thisday','today','prevbusday','asfreq', -'period_break' - ] - - -#####--------------------------------------------------------------------------- -#---- --- Date Info --- -#####--------------------------------------------------------------------------- - -OriginDate = dt.datetime(1970, 1, 1) -secondlyOriginDate = OriginDate - dt.timedelta(seconds=1) -minutelyOriginDate = OriginDate - dt.timedelta(minutes=1) -hourlyOriginDate = OriginDate - dt.timedelta(hours=1) - - -#####--------------------------------------------------------------------------- -#---- --- Date Exceptions --- -#####--------------------------------------------------------------------------- -class DateError(Exception): - """Defines a generic DateArrayError.""" - def __init__ (self, args=None): - "Create an exception" - Exception.__init__(self) - self.args = args - def __str__(self): - "Calculate the string representation" - return str(self.args) - __repr__ = __str__ - -class InsufficientDateError(DateError): - """Defines the exception raised when there is not enough information - to create a Date object.""" - def __init__(self, msg=None): - if msg is None: - msg = "Insufficient parameters given to create a date at the given frequency" - DateError.__init__(self, msg) - -class FrequencyDateError(DateError): - """Defines the exception raised when the frequencies are incompatible.""" - def __init__(self, msg, freql=None, freqr=None): - msg += " : Incompatible frequencies!" - if not (freql is None or freqr is None): - msg += " (%s<>%s)" % (freql, freqr) - DateError.__init__(self, msg) - -class ArithmeticDateError(DateError): - """Defines the exception raised when dates are used in arithmetic expressions.""" - def __init__(self, msg=''): - msg += " Cannot use dates for arithmetics!" - DateError.__init__(self, msg) - -#####--------------------------------------------------------------------------- -#---- --- Date Class --- -#####--------------------------------------------------------------------------- - -class Date: - """Defines a Date object, as the combination of a date and a frequency. - Several options are available to construct a Date object explicitly: - - - Give appropriate values to the `year`, `month`, `day`, `quarter`, `hours`, - `minutes`, `seconds` arguments. - - >>> td.Date(freq='Q',year=2004,quarter=3) - >>> td.Date(freq='D',year=2001,month=1,day=1) - - - Use the `string` keyword. This method calls the `mx.DateTime.Parser` - submodule, more information is available in its documentation. - - >>> ts.Date('D', '2007-01-01') - - - Use the `datetime` keyword with an existing datetime.datetime object. - - >>> td.Date('D', datetime=datetime.datetime.now()) - """ - default_fmtstr = {'A': "%Y", - 'Q': "%YQ%q", - 'M': "%b-%Y", - 'W': "%d-%b-%Y", - 'B': "%d-%b-%Y", - 'D': "%d-%b-%Y", - 'U': "%d-%b-%Y", - 'H': "%d-%b-%Y %H:00", - 'T': "%d-%b-%Y %H:%M", - 'S': "%d-%b-%Y %H:%M:%S" - } - - def __init__(self, freq, value=None, string=None, - year=None, month=None, day=None, quarter=None, - hour=None, minute=None, second=None, - datetime=None): - - if hasattr(freq, 'freq'): - self.freq = corelib.check_freq(freq.freq) - else: - self.freq = corelib.check_freq(freq) - self.freqstr = corelib.freq_tostr(self.freq) - - - if value is not None: - if isinstance(value, ndarray): - value = int(value) - - if isinstance(value, str): - if self.freqstr in ('H', 'T', 'S'): - self.datetime = DateTimeFromString(value) - else: - self.datetime = DateFromString(value) - elif self.freqstr == 'A': - self.datetime = dt.datetime(value, 1, 1) - elif self.freqstr == 'B': - valtmp = (value - 1)//5 - self.datetime = dt.datetime.fromordinal(value + valtmp*2) - elif self.freqstr in ['D','U']: - self.datetime = dt.datetime.fromordinal(value) - elif self.freqstr == 'H': - self.datetime = hourlyOriginDate + dt.timedelta(hours=value) - elif self.freqstr == 'M': - year = (value - 1)//12 + 1 - month = value - (year - 1)*12 - self.datetime = dt.datetime(year, month, 1) - elif self.freqstr == 'Q': - year = (value - 1)//4 + 1 - month = (value - (year - 1)*4)*3 - self.datetime = dt.datetime(year, month, 1) - elif self.freqstr == 'S': - self.datetime = secondlyOriginDate + dt.timedelta(seconds=value) - elif self.freqstr == 'T': - self.datetime = minutelyOriginDate + dt.timedelta(minutes=value) - elif self.freqstr == 'W': - self.datetime = dt.datetime(1,1,7) + \ - dt.timedelta(days=(value-1)*7) - - elif string is not None: - if self.freqstr in ('H', 'T', 'S'): - self.datetime = DateTimeFromString(string) - else: - self.datetime = DateFromString(string) - - elif datetime is not None: - if isinstance(datetime, DateTimeType): - datetime = mx_to_datetime(datetime) - self.datetime = truncateDate(self.freq, datetime) - - else: - # First, some basic checks..... - if year is None: - raise InsufficientDateError - if self.freqstr in 'BDWU': - if month is None or day is None: - raise InsufficientDateError - elif self.freqstr == 'M': - if month is None: - raise InsufficientDateError - day = 1 - elif self.freqstr == 'Q': - if quarter is None: - raise InsufficientDateError - month = quarter * 3 - day = 1 - elif self.freqstr == 'A': - month = 1 - day = 1 - elif self.freqstr == 'S': - if month is None or day is None or second is None: - raise InsufficientDateError - - if self.freqstr in ['A','B','D','M','Q','W']: - self.datetime = truncateDate(self.freq, dt.datetime(year, month, day)) - if self.freqstr == 'B': - if self.datetime.isoweekday() in [6,7]: - raise ValueError("Weekend passed as business day") - elif self.freqstr in 'HTS': - if hour is None: - if minute is None: - if second is None: - hour = 0 - else: - hour = second//3600 - else: - hour = minute // 60 - if minute is None: - if second is None: - minute = 0 - else: - minute = (second-hour*3600)//60 - if second is None: - second = 0 - else: - second = second % 60 - self.datetime = truncateDate(self.freqstr, - dt.datetime(year, month, day, - hour, minute, second)) - self.value = self.__value() - - def __getitem__(self, indx): - return self - - @property - def day(self): - "Returns the day of month." - return self.__getdateinfo__('D') - @property - def day_of_week(self): - "Returns the day of week." - return self.__getdateinfo__('W') - @property - def day_of_year(self): - "Returns the day of year." - return self.__getdateinfo__('R') - @property - def month(self): - "Returns the month." - return self.__getdateinfo__('M') - @property - def quarter(self): - "Returns the quarter." - return self.__getdateinfo__('Q') - @property - def year(self): - "Returns the year." - return self.__getdateinfo__('Y') - @property - def second(self): - "Returns the seconds." - return self.__getdateinfo__('S') - @property - def minute(self): - "Returns the minutes." - return self.__getdateinfo__('T') - @property - def hour(self): - "Returns the hour." - return self.__getdateinfo__('H') - @property - def week(self): - "Returns the week." - return self.__getdateinfo__('I') - - def __getdateinfo__(self, info): - return int(cseries.getDateInfo(numpy.asarray(self.value), - self.freq, info)) - __getDateInfo = __getdateinfo__ - - def __add__(self, other): - if isinstance(other, Date): - raise FrequencyDateError("Cannot add dates", - self.freqstr, other.freqstr) - return Date(freq=self.freq, value=int(self) + other) - - def __radd__(self, other): - return self+other - - def __sub__(self, other): - if isinstance(other, Date): - if self.freq != other.freq: - raise FrequencyDateError("Cannot subtract dates", \ - self.freqstr, other.freqstr) - else: - return int(self) - int(other) - else: - return self + (-1) * int(other) - - def __eq__(self, other): - if not hasattr(other, 'freq'): - return False - elif self.freq != other.freq: - raise FrequencyDateError("Cannot compare dates", \ - self.freqstr, other.freqstr) - return int(self) == int(other) - - def __cmp__(self, other): - if not hasattr(other, 'freq'): - return False - elif self.freq != other.freq: - raise FrequencyDateError("Cannot compare dates", \ - self.freqstr, other.freqstr) - return int(self)-int(other) - - def __hash__(self): - return hash(int(self)) ^ hash(self.freq) - - def __int__(self): - return self.value - - def __float__(self): - return float(self.value) - - def __value(self): - "Converts the date to an integer, depending on the current frequency." - # Annual ....... - if self.freqstr == 'A': - val = self.datetime.year - # Quarterly..... - elif self.freqstr == 'Q': - val = (self.datetime.year-1)*4 + self.datetime.month//3 - # Monthly....... - elif self.freqstr == 'M': - val = (self.datetime.year-1)*12 + self.datetime.month - # Weekly........ - elif self.freqstr == 'W': - val = self.datetime.toordinal()//7 - # Business days. - elif self.freqstr == 'B': - days = self.datetime.toordinal() - weeks = days // 7 - val = days - weeks*2 - # Daily/undefined - elif self.freqstr in 'DU': - val = self.datetime.toordinal() - # Hourly........ - elif self.freqstr == 'H': - delta = (self.datetime - hourlyOriginDate) - val = delta.days*24 + delta.seconds/(3600) - # Minutely...... - elif self.freqstr == 'T': - delta = (self.datetime - minutelyOriginDate) - val = delta.days*1440 + delta.seconds/(60) - # Secondly...... - elif self.freqstr == 'S': - delta = (self.datetime - secondlyOriginDate) - val = delta.days*86400 + delta.seconds - return int(val) - #...................................................... - def strfmt(self, fmt): - "Formats the date" - if fmt is None: - fmt = self.default_fmtstr[self.freqstr] - return cseries.strfmt(self.datetime, fmt) - - def __str__(self): - return self.strfmt(self.default_fmtstr[self.freqstr]) - - def __repr__(self): - return "<%s : %s>" % (str(self.freqstr), str(self)) - #...................................................... - def toordinal(self): - "Returns the date as an ordinal." - return self.datetime.toordinal() - - def fromordinal(self, ordinal): - "Returns the date as an ordinal." - return Date(self.freq, datetime=dt.datetime.fromordinal(ordinal)) - - def tostring(self): - "Returns the date as a string." - return str(self) - - def toobject(self): - "Returns the date as itself." - return self - - def isvalid(self): - "Returns whether the DateArray is valid: no missing/duplicated dates." - # A date is always valid by itself, but we need the object to support the function - # when we're working with singletons. - return True - #...................................................... - - -#####--------------------------------------------------------------------------- -#---- --- Functions --- -#####--------------------------------------------------------------------------- - -def mx_to_datetime(mxDate): - microsecond = 1000000*(mxDate.second % 1) - return dt.datetime(mxDate.year, mxDate.month, - mxDate.day, mxDate.hour, - mxDate.minute, - int(mxDate.second), microsecond) - - -def truncateDate(freq, datetime): - "Chops off the irrelevant information from the datetime object passed in." - freqstr = corelib.check_freqstr(freq) - if freqstr == 'A': - return dt.datetime(datetime.year, 1, 1) - elif freqstr == 'Q': - return dt.datetime(datetime.year, monthToQuarter(datetime.month)*3, 1) - elif freqstr == 'M': - return dt.datetime(datetime.year, datetime.month, 1) - elif freqstr == 'W': - d = datetime.toordinal() - return dt.datetime.fromordinal(d + (7 - d % 7) % 7) - elif freqstr in 'BD': - if freq == 'B' and datetime.isoweekday() in (6,7): - raise ValueError("Weekend passed as business day") - return dt.datetime(datetime.year, datetime.month, datetime.day) - elif freqstr == 'H': - return dt.datetime(datetime.year, datetime.month, datetime.day, \ - datetime.hour) - elif freqstr == 'T': - return dt.datetime(datetime.year, datetime.month, datetime.day, \ - datetime.hour, datetime.minute) - else: - return datetime - -def monthToQuarter(monthNum): - """Returns the quarter corresponding to the month `monthnum`. - For example, December is the 4th quarter, Januray the first.""" - return int((monthNum-1)/3)+1 - -def thisday(freq): - "Returns today's date, at the given frequency `freq`." - freqstr = corelib.check_freqstr(freq) - tempDate = dt.datetime.now() - # if it is Saturday or Sunday currently, freq==B, then we want to use Friday - if freqstr == 'B' and tempDate.isoweekday() >= 6: - tempDate = tempDate - dt.timedelta(days=(tempDate.isoweekday() - 5)) - if freqstr in ('B','D','H','S','T','W','U'): - return Date(freq, datetime=tempDate) - elif freqstr == 'M': - return Date(freq, year=tempDate.year, month=tempDate.month) - elif freqstr == 'Q': - return Date(freq, year=tempDate.year, quarter=monthToQuarter(tempDate.month)) - elif freqstr == 'A': - return Date(freq, year=tempDate.year) -today = thisday - -def prevbusday(day_end_hour=18, day_end_min=0): - "Returns the previous business day." - tempDate = dt.datetime.now() - dateNum = tempDate.hour + float(tempDate.minute)/60 - checkNum = day_end_hour + float(day_end_min)/60 - if dateNum < checkNum: - return thisday('B') - 1 - else: - return thisday('B') - -def asfreq(date, toFreq, relation="BEFORE"): - """Returns a date converted to another frequency `toFreq`, according to the - relation `relation` .""" - tofreq = corelib.check_freq(toFreq) - _rel = relation.upper()[0] - if _rel not in ['B', 'A']: - msg = "Invalid relation '%s': Should be in ['before', 'after']" - raise ValueError, msg % relation - - if not isinstance(date, Date): - raise DateError, "Date should be a valid Date instance!" - - if date.freqstr == 'U': - warnings.warn("Undefined frequency: assuming daily!") - fromfreq = corelib.freq_revdict['D'] - else: - fromfreq = date.freq - - if fromfreq == tofreq: - return date - else: - value = cseries.asfreq(numeric.asarray(date.value), fromfreq, tofreq, _rel) - if value > 0: - return Date(freq=tofreq, value=value) - else: - return None -Date.asfreq = asfreq - -def isDate(data): - "Returns whether `data` is an instance of Date." - return isinstance(data, Date) or \ - (hasattr(data,'freq') and hasattr(data,'value')) - - -#####--------------------------------------------------------------------------- -#---- --- DateArray --- -#####--------------------------------------------------------------------------- -ufunc_dateOK = ['add','subtract', - 'equal','not_equal','less','less_equal', 'greater','greater_equal', - 'isnan'] - -class _datearithmetics(object): - """Defines a wrapper for arithmetic methods. -Instead of directly calling a ufunc, the corresponding method of the `array._data` -object is called instead. -If `asdates` is True, a DateArray object is returned , else a regular ndarray -is returned. - """ - def __init__ (self, methodname, asdates=True): - """ -:Parameters: - - `methodname` (String) : Method name. - """ - self.methodname = methodname - self._asdates = asdates - self.__doc__ = getattr(methodname, '__doc__') - self.obj = None - # - def __get__(self, obj, objtype=None): - self.obj = obj - return self - # - def __call__ (self, other, *args, **kwargs): - "Execute the call behavior." - instance = self.obj - freq = instance.freq - if 'context' not in kwargs: - kwargs['context'] = 'DateOK' - method = getattr(super(DateArray,instance), self.methodname) - if isinstance(other, DateArray): - if other.freq != freq: - raise FrequencyDateError("Cannot operate on dates", \ - freq, other.freq) - elif isinstance(other, Date): - if other.freq != freq: - raise FrequencyDateError("Cannot operate on dates", \ - freq, other.freq) - other = other.value - elif isinstance(other, ndarray): - if other.dtype.kind not in ['i','f']: - raise ArithmeticDateError - if self._asdates: - return instance.__class__(method(other, *args), - freq=freq) - else: - return method(other, *args) - -class DateArray(ndarray): - """Defines a ndarray of dates, as ordinals. - -When viewed globally (array-wise), DateArray is an array of integers. -When viewed element-wise, DateArray is a sequence of dates. -For example, a test such as : ->>> DateArray(...) = value -will be valid only if value is an integer, not a Date -However, a loop such as : ->>> for d in DateArray(...): -accesses the array element by element. Therefore, `d` is a Date object. - """ - _defcachedinfo = dict(toobj=None, tostr=None, toord=None, - steps=None, full=None, hasdups=None) - def __new__(cls, dates=None, freq=None, copy=False): - # Get the frequency ...... - if freq is None: - _freq = getattr(dates, 'freq', -9999) - else: - _freq = corelib.check_freq(freq) - cls._defaultfreq = corelib.check_freq(_freq) - # Get the dates .......... - _dates = numeric.array(dates, copy=copy, dtype=int_, subok=1) - if _dates.ndim == 0: - _dates.shape = (1,) - _dates = _dates.view(cls) - _dates.freq = _freq - return _dates - - def __array_wrap__(self, obj, context=None): - if context is None: - return self - elif context[0].__name__ not in ufunc_dateOK: - raise ArithmeticDateError, "(function %s)" % context[0].__name__ - - def __array_finalize__(self, obj): - self.freq = getattr(obj, 'freq', -9999) - self._cachedinfo = dict(toobj=None, tostr=None, toord=None, - steps=None, full=None, hasdups=None) - if hasattr(obj,'_cachedinfo'): - self._cachedinfo.update(obj._cachedinfo) - return - - def __getitem__(self, indx): - if isinstance(indx, Date): - indx = self.find_dates(indx) - elif numeric.asarray(indx).dtype.kind == 'O': - try: - indx = self.find_dates(indx) - except AttributeError: - pass - r = ndarray.__getitem__(self, indx) - if isinstance(r, (generic, int)): - return Date(self.freq, value=r) - elif hasattr(r, 'size') and r.size == 1: - # need to check if it has a size attribute for situations - # like when the datearray is the data for a maskedarray - # or some other subclass of ndarray with wierd getitem - # behaviour - return Date(self.freq, value=r.item()) - else: - if hasattr(r, '_cachedinfo'): - r._cachedinfo.update(dict(steps=None, full=None, hasdups=None)) - for attr in ('tostr','toobj','toord'): - if r._cachedinfo[attr] is not None: - r._cachedinfo[attr] = r._cachedinfo[attr][indx] - return r - - def __repr__(self): - return ndarray.__repr__(self) - #...................................................... - __add__ = _datearithmetics('__add__', asdates=True) - __radd__ = _datearithmetics('__add__', asdates=True) - __sub__ = _datearithmetics('__sub__', asdates=True) - __rsub__ = _datearithmetics('__rsub__', asdates=True) - __le__ = _datearithmetics('__le__', asdates=False) - __lt__ = _datearithmetics('__lt__', asdates=False) - __ge__ = _datearithmetics('__ge__', asdates=False) - __gt__ = _datearithmetics('__gt__', asdates=False) - __eq__ = _datearithmetics('__eq__', asdates=False) - __ne__ = _datearithmetics('__ne__', asdates=False) - #...................................................... - @property - def freqstr(self): - "Returns the frequency string code." - return corelib.freq_tostr(self.freq) - @property - def day(self): - "Returns the day of month." - return self.__getdateinfo__('D') - @property - def day_of_week(self): - "Returns the day of week." - return self.__getdateinfo__('W') - @property - def day_of_year(self): - "Returns the day of year." - return self.__getdateinfo__('R') - @property - def month(self): - "Returns the month." - return self.__getdateinfo__('M') - @property - def quarter(self): - "Returns the quarter." - return self.__getdateinfo__('Q') - @property - def year(self): - "Returns the year." - return self.__getdateinfo__('Y') - @property - def second(self): - "Returns the seconds." - return self.__getdateinfo__('S') - @property - def minute(self): - "Returns the minutes." - return self.__getdateinfo__('T') - @property - def hour(self): - "Returns the hour." - return self.__getdateinfo__('H') - @property - def week(self): - "Returns the week." - return self.__getdateinfo__('I') - - days = day - weekdays = day_of_week - yeardays = day_of_year - months = month - quarters = quarter - years = year - seconds = second - minutes = minute - hours = hour - weeks = week - - def __getdateinfo__(self, info): - return numeric.asarray(cseries.getDateInfo(numeric.asarray(self), - self.freq, info), - dtype=int_) - __getDateInfo = __getdateinfo__ - #.... Conversion methods .................... - # - def tovalue(self): - "Converts the dates to integer values." - return numeric.asarray(self) - # - def toordinal(self): - "Converts the dates from values to ordinals." - # Note: we better try to cache the result - if self._cachedinfo['toord'] is None: -# diter = (Date(self.freq, value=d).toordinal() for d in self) - diter = (d.toordinal() for d in self) - toord = numeric.fromiter(diter, dtype=float_) - self._cachedinfo['toord'] = toord - return self._cachedinfo['toord'] - # - def tostring(self): - "Converts the dates to strings." - # Note: we better cache the result - if self._cachedinfo['tostr'] is None: - firststr = str(self[0]) - if self.size > 0: - ncharsize = len(firststr) - tostr = numpy.fromiter((str(d) for d in self), - dtype='|S%i' % ncharsize) - else: - tostr = firststr - self._cachedinfo['tostr'] = tostr - return self._cachedinfo['tostr'] - # - def asfreq(self, freq=None, relation="BEFORE"): - "Converts the dates to another frequency." - # Note: As we define a new object, we don't need caching - if freq is None or freq == -9999: - return self - tofreq = corelib.check_freq(freq) - if tofreq == self.freq: - return self - fromfreq = self.freq - _rel = relation.upper()[0] - new = cseries.asfreq(numeric.asarray(self), fromfreq, tofreq, _rel) - return DateArray(new, freq=freq) - #...................................................... - def find_dates(self, *dates): - "Returns the indices corresponding to given dates, as an array." - ifreq = self.freq - c = numpy.zeros(self.shape, bool_) - for d in corelib.flatargs(*dates): - if d.freq != ifreq: - d = d.asfreq(ifreq) - c += (self == d.value) - c = c.nonzero() - if fromnumeric.size(c) == 0: - raise IndexError, "Date out of bounds!" - return c - - def date_to_index(self, date): - "Returns the index corresponding to one given date, as an integer." - if self.isvalid(): - index = date.value - self[0].value - if index < 0 or index > self.size: - raise IndexError, "Date out of bounds!" - return index - else: - index_asarray = (self == date.value).nonzero() - if fromnumeric.size(index_asarray) == 0: - raise IndexError, "Date out of bounds!" - return index_asarray[0][0] - #...................................................... - def get_steps(self): - """Returns the time steps between consecutive dates. - The timesteps have the same unit as the frequency of the series.""" - if self.freq == 'U': - warnings.warn("Undefined frequency: assuming integers!") - if self._cachedinfo['steps'] is None: - _cached = self._cachedinfo - val = numeric.asarray(self).ravel() - if val.size > 1: - steps = val[1:] - val[:-1] - if _cached['full'] is None: - _cached['full'] = (steps.max() == 1) - if _cached['hasdups'] is None: - _cached['hasdups'] = (steps.min() == 0) - else: - _cached['full'] = True - _cached['hasdups'] = False - steps = numeric.array([], dtype=int_) - self._cachedinfo['steps'] = steps - return self._cachedinfo['steps'] - - def has_missing_dates(self): - "Returns whether the DateArray have missing dates." - if self._cachedinfo['full'] is None: - steps = self.get_steps() - return not(self._cachedinfo['full']) - - def isfull(self): - "Returns whether the DateArray has no missing dates." - if self._cachedinfo['full'] is None: - steps = self.get_steps() - return self._cachedinfo['full'] - - def has_duplicated_dates(self): - "Returns whether the DateArray has duplicated dates." - if self._cachedinfo['hasdups'] is None: - steps = self.get_steps() - return self._cachedinfo['hasdups'] - - def isvalid(self): - "Returns whether the DateArray is valid: no missing/duplicated dates." - return (self.isfull() and not self.has_duplicated_dates()) - #...................................................... - -#............................ - - -#####--------------------------------------------------------------------------- -#---- --- DateArray functions --- -#####--------------------------------------------------------------------------- -def isDateArray(a): - "Tests whether an array is a DateArray object." - return isinstance(a,DateArray) - -def guess_freq(dates): - """Tries to estimate the frequency of a list of dates, by checking the steps - between consecutive dates The steps should be in days. - Returns a frequency code (alpha character).""" - ddif = numeric.asarray(numpy.diff(dates)) - ddif.sort() - if ddif[0] == ddif[-1] == 1.: - fcode = 'D' - elif (ddif[0] == 1.) and (ddif[-1] == 3.): - fcode = 'B' - elif (ddif[0] > 3.) and (ddif[-1] == 7.): - fcode = 'W' - elif (ddif[0] >= 28.) and (ddif[-1] <= 31.): - fcode = 'M' - elif (ddif[0] >= 90.) and (ddif[-1] <= 92.): - fcode = 'Q' - elif (ddif[0] >= 365.) and (ddif[-1] <= 366.): - fcode = 'A' - elif numpy.abs(24.*ddif[0] - 1) <= 1e-5 and \ - numpy.abs(24.*ddif[-1] - 1) <= 1e-5: - fcode = 'H' - elif numpy.abs(1440.*ddif[0] - 1) <= 1e-5 and \ - numpy.abs(1440.*ddif[-1] - 1) <= 1e-5: - fcode = 'T' - elif numpy.abs(86400.*ddif[0] - 1) <= 1e-5 and \ - numpy.abs(86400.*ddif[-1] - 1) <= 1e-5: - fcode = 'S' - else: - warnings.warn("Unable to estimate the frequency! %.3f<>%.3f" %\ - (ddif[0], ddif[-1])) - fcode = 'U' - return fcode - - -def _listparser(dlist, freq=None): - "Constructs a DateArray from a list." - dlist = numeric.asarray(dlist) - dlist.sort() - if dlist.ndim == 0: - dlist.shape = (1,) - # Case #1: dates as strings ................. - if dlist.dtype.kind == 'S': - #...construct a list of ordinals - ords = numpy.fromiter((DateTimeFromString(s).toordinal() for s in dlist), - float_) - ords += 1 - #...try to guess the frequency - if freq is None: - freq = guess_freq(ords) - #...construct a list of dates - dates = [Date(freq, string=s) for s in dlist] - # Case #2: dates as numbers ................. - elif dlist.dtype.kind in 'if': - #...hopefully, they are values - if freq is None: - freq = guess_freq(dlist) - dates = dlist - # Case #3: dates as objects ................. - elif dlist.dtype.kind == 'O': - template = dlist[0] - #...as Date objects - if isinstance(template, Date): - dates = numpy.fromiter((d.value for d in dlist), int_) - #...as mx.DateTime objects - elif hasattr(template,'absdays'): - # no freq given: try to guess it from absdays - if freq is None: - ords = numpy.fromiter((s.absdays for s in dlist), float_) - ords += 1 - freq = guess_freq(ords) - dates = [Date(freq, datetime=m) for m in dlist] - #...as datetime objects - elif hasattr(template, 'toordinal'): - ords = numpy.fromiter((d.toordinal() for d in dlist), float_) - if freq is None: - freq = guess_freq(ords) - dates = [Date(freq, datetime=dt.datetime.fromordinal(a)) for a in ords] - # - result = DateArray(dates, freq) - return result - - -def date_array(dlist=None, start_date=None, end_date=None, length=None, - include_last=True, freq=None): - """Constructs a DateArray from: - - a starting date and either an ending date or a given length. - - a list of dates. - """ - freq = corelib.check_freq(freq) - # Case #1: we have a list ................... - if dlist is not None: - # Already a DateArray.................... - if isinstance(dlist, DateArray): - if (freq is not None) and (dlist.freq != corelib.check_freq(freq)): - return dlist.asfreq(freq) - else: - return dlist - # Make sure it's a sequence, else that's a start_date - if hasattr(dlist,'__len__'): - return _listparser(dlist, freq) - elif start_date is not None: - if end_date is not None: - dmsg = "What starting date should be used ? '%s' or '%s' ?" - raise DateError, dmsg % (dlist, start_date) - else: - (start_date, end_date) = (dlist, start_date) - else: - start_date = dlist - # Case #2: we have a starting date .......... - if start_date is None: - if length == 0: - return DateArray([], freq=freq) - raise InsufficientDateError - if not isDate(start_date): - dmsg = "Starting date should be a valid Date instance! " - dmsg += "(got '%s' instead)" % type(start_date) - raise DateError, dmsg - # Check if we have an end_date - if end_date is None: - if length is None: -# raise ValueError,"No length precised!" - length = 1 - else: - if not isDate(end_date): - raise DateError, "Ending date should be a valid Date instance!" - length = int(end_date - start_date) - if include_last: - length += 1 -# dlist = [(start_date+i).value for i in range(length)] - dlist = numeric.arange(length, dtype=int_) - dlist += start_date.value - if freq is None: - freq = start_date.freq - return DateArray(dlist, freq=freq) -datearray = date_array - -def date_array_fromlist(dlist, freq=None): - "Constructs a DateArray from a list of dates." - return date_array(dlist=dlist, freq=freq) - -def date_array_fromrange(start_date, end_date=None, length=None, - include_last=True, freq=None): - """Constructs a DateArray from a starting date and either an ending date or - a length.""" - return date_array(start_date=start_date, end_date=end_date, - length=length, include_last=include_last, freq=freq) - -#####--------------------------------------------------------------------------- -#---- --- Definition of functions from the corresponding methods --- -#####--------------------------------------------------------------------------- -class _frommethod(object): - """Defines functions from existing MaskedArray methods. -:ivar _methodname (String): Name of the method to transform. - """ - def __init__(self, methodname): - self._methodname = methodname - self.__doc__ = self.getdoc() - def getdoc(self): - "Returns the doc of the function (from the doc of the method)." - try: - return getattr(DateArray, self._methodname).__doc__ - except AttributeError: - return "???" - # - def __call__(self, caller, *args, **params): - if hasattr(caller, self._methodname): - method = getattr(caller, self._methodname) - # If method is not callable, it's a property, and don't call it - if hasattr(method, '__call__'): - return method.__call__(*args, **params) - return method - method = getattr(fromnumeric.asarray(caller), self._methodname) - try: - return method(*args, **params) - except SystemError: - return getattr(numpy,self._methodname).__call__(caller, *args, **params) -#............................ -day_of_week = _frommethod('day_of_week') -day_of_year = _frommethod('day_of_year') -year = _frommethod('year') -quarter = _frommethod('quarter') -month = _frommethod('month') -day = _frommethod('day') -hour = _frommethod('hour') -minute = _frommethod('minute') -second = _frommethod('second') - - -def period_break(dates, period): - """Returns the indices where the given period changes. - -:Parameters: - dates : DateArray - Array of dates to monitor. - period : string - Name of the period to monitor. - """ - current = getattr(dates, period) - previous = getattr(dates-1, period) - return (current - previous).nonzero()[0] - - -################################################################################ - -if __name__ == '__main__': - import maskedarray.testutils - from maskedarray.testutils import assert_equal - if 1: - dlist = ['2007-%02i' % i for i in range(1,5)+range(7,13)] - mdates = date_array_fromlist(dlist, 'M') - # Using an integer - assert_equal(mdates[0].value, 24073) - assert_equal(mdates[-1].value, 24084) - # Using a date - lag = mdates.find_dates(mdates[0]) - print mdates[lag] - assert_equal(mdates[lag], mdates[0]) - if 1: - hodie = today('D') - D = DateArray(today('D')) - assert_equal(D.freq, 6000) - - if 1: - freqs = [x[0] for x in corelib.freq_dict.values() if x[0] != 'U'] - print freqs - for f in freqs: - print f - today = thisday(f) - assert(Date(freq=f, value=today.value) == today) - - if 1: - D = date_array(start_date=thisday('D'), length=5) - Dstr = D.tostring() - assert_equal(D.tostring(), Dstr) - DL = D[[0,-1]] - assert_equal(DL.tostring(), Dstr[[0,-1]]) - \ No newline at end of file From scipy-svn at scipy.org Fri Mar 2 03:49:32 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Mar 2007 02:49:32 -0600 (CST) Subject: [Scipy-svn] r2809 - trunk/Lib/sandbox/timeseries Message-ID: <20070302084932.1DD8339C29C@new.scipy.org> Author: pierregm Date: 2007-03-02 02:49:29 -0600 (Fri, 02 Mar 2007) New Revision: 2809 Added: trunk/Lib/sandbox/timeseries/tdates.py Log: tdates : oops, it disappeared... Added: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-02 08:48:36 UTC (rev 2808) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-02 08:49:29 UTC (rev 2809) @@ -0,0 +1,1064 @@ +""" +Classes definition for the support of individual dates and array of dates. + +:author: Pierre GF Gerard-Marchant & Matt Knox +:contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com +:version: $Id$ +""" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" +__version__ = '1.0' +__revision__ = "$Revision$" +__date__ = '$Date$' + +import datetime as dt + +import itertools +import warnings +import types + + +import numpy +from numpy import bool_, float_, int_, object_ +from numpy import ndarray +import numpy.core.numeric as numeric +import numpy.core.fromnumeric as fromnumeric +import numpy.core.numerictypes as ntypes +from numpy.core.numerictypes import generic + +import maskedarray as MA + +try: + from mx.DateTime import DateTimeType +except ImportError: + class DateTimeType: pass + +from parser import DateFromString, DateTimeFromString + +import tcore as corelib +import cseries + + + +__all__ = [ +'Date', 'DateArray','isDate','isDateArray', +'DateError', 'ArithmeticDateError', 'FrequencyDateError','InsufficientDateError', +'datearray','date_array', 'date_array_fromlist', 'date_array_fromrange', +'day_of_week','day_of_year','day','month','quarter','year','hour','minute','second', +'truncateDate','monthToQuarter','thisday','today','prevbusday','asfreq', +'period_break' + ] + + +#####--------------------------------------------------------------------------- +#---- --- Date Info --- +#####--------------------------------------------------------------------------- + +OriginDate = dt.datetime(1970, 1, 1) +secondlyOriginDate = OriginDate - dt.timedelta(seconds=1) +minutelyOriginDate = OriginDate - dt.timedelta(minutes=1) +hourlyOriginDate = OriginDate - dt.timedelta(hours=1) + + +#####--------------------------------------------------------------------------- +#---- --- Date Exceptions --- +#####--------------------------------------------------------------------------- +class DateError(Exception): + """Defines a generic DateArrayError.""" + def __init__ (self, args=None): + "Create an exception" + Exception.__init__(self) + self.args = args + def __str__(self): + "Calculate the string representation" + return str(self.args) + __repr__ = __str__ + +class InsufficientDateError(DateError): + """Defines the exception raised when there is not enough information + to create a Date object.""" + def __init__(self, msg=None): + if msg is None: + msg = "Insufficient parameters given to create a date at the given frequency" + DateError.__init__(self, msg) + +class FrequencyDateError(DateError): + """Defines the exception raised when the frequencies are incompatible.""" + def __init__(self, msg, freql=None, freqr=None): + msg += " : Incompatible frequencies!" + if not (freql is None or freqr is None): + msg += " (%s<>%s)" % (freql, freqr) + DateError.__init__(self, msg) + +class ArithmeticDateError(DateError): + """Defines the exception raised when dates are used in arithmetic expressions.""" + def __init__(self, msg=''): + msg += " Cannot use dates for arithmetics!" + DateError.__init__(self, msg) + +#####--------------------------------------------------------------------------- +#---- --- Date Class --- +#####--------------------------------------------------------------------------- + +class Date: + """Defines a Date object, as the combination of a date and a frequency. + Several options are available to construct a Date object explicitly: + + - Give appropriate values to the `year`, `month`, `day`, `quarter`, `hours`, + `minutes`, `seconds` arguments. + + >>> td.Date(freq='Q',year=2004,quarter=3) + >>> td.Date(freq='D',year=2001,month=1,day=1) + + - Use the `string` keyword. This method calls the `mx.DateTime.Parser` + submodule, more information is available in its documentation. + + >>> ts.Date('D', '2007-01-01') + + - Use the `datetime` keyword with an existing datetime.datetime object. + + >>> td.Date('D', datetime=datetime.datetime.now()) + """ + default_fmtstr = {'A': "%Y", + 'Q': "%YQ%q", + 'M': "%b-%Y", + 'W': "%d-%b-%Y", + 'B': "%d-%b-%Y", + 'D': "%d-%b-%Y", + 'U': "%d-%b-%Y", + 'H': "%d-%b-%Y %H:00", + 'T': "%d-%b-%Y %H:%M", + 'S': "%d-%b-%Y %H:%M:%S" + } + + def __init__(self, freq, value=None, string=None, + year=None, month=None, day=None, quarter=None, + hour=None, minute=None, second=None, + datetime=None): + + if hasattr(freq, 'freq'): + self.freq = corelib.check_freq(freq.freq) + else: + self.freq = corelib.check_freq(freq) + self.freqstr = corelib.freq_tostr(self.freq) + + + if value is not None: + if isinstance(value, ndarray): + value = int(value) + + if isinstance(value, str): + if self.freqstr in ('H', 'T', 'S'): + self.datetime = DateTimeFromString(value) + else: + self.datetime = DateFromString(value) + elif self.freqstr == 'A': + self.datetime = dt.datetime(value, 1, 1) + elif self.freqstr == 'B': + valtmp = (value - 1)//5 + self.datetime = dt.datetime.fromordinal(value + valtmp*2) + elif self.freqstr in ['D','U']: + self.datetime = dt.datetime.fromordinal(value) + elif self.freqstr == 'H': + self.datetime = hourlyOriginDate + dt.timedelta(hours=value) + elif self.freqstr == 'M': + year = (value - 1)//12 + 1 + month = value - (year - 1)*12 + self.datetime = dt.datetime(year, month, 1) + elif self.freqstr == 'Q': + year = (value - 1)//4 + 1 + month = (value - (year - 1)*4)*3 + self.datetime = dt.datetime(year, month, 1) + elif self.freqstr == 'S': + self.datetime = secondlyOriginDate + dt.timedelta(seconds=value) + elif self.freqstr == 'T': + self.datetime = minutelyOriginDate + dt.timedelta(minutes=value) + elif self.freqstr == 'W': + self.datetime = dt.datetime(1,1,7) + \ + dt.timedelta(days=(value-1)*7) + + elif string is not None: + if self.freqstr in ('H', 'T', 'S'): + self.datetime = DateTimeFromString(string) + else: + self.datetime = DateFromString(string) + + elif datetime is not None: + if isinstance(datetime, DateTimeType): + datetime = mx_to_datetime(datetime) + self.datetime = truncateDate(self.freq, datetime) + + else: + # First, some basic checks..... + if year is None: + raise InsufficientDateError + if self.freqstr in 'BDWU': + if month is None or day is None: + raise InsufficientDateError + elif self.freqstr == 'M': + if month is None: + raise InsufficientDateError + day = 1 + elif self.freqstr == 'Q': + if quarter is None: + raise InsufficientDateError + month = quarter * 3 + day = 1 + elif self.freqstr == 'A': + month = 1 + day = 1 + elif self.freqstr == 'S': + if month is None or day is None or second is None: + raise InsufficientDateError + + if self.freqstr in ['A','B','D','M','Q','W']: + self.datetime = truncateDate(self.freq, dt.datetime(year, month, day)) + if self.freqstr == 'B': + if self.datetime.isoweekday() in [6,7]: + raise ValueError("Weekend passed as business day") + elif self.freqstr in 'HTS': + if hour is None: + if minute is None: + if second is None: + hour = 0 + else: + hour = second//3600 + else: + hour = minute // 60 + if minute is None: + if second is None: + minute = 0 + else: + minute = (second-hour*3600)//60 + if second is None: + second = 0 + else: + second = second % 60 + self.datetime = truncateDate(self.freqstr, + dt.datetime(year, month, day, + hour, minute, second)) + self.value = self.__value() + + def __getitem__(self, indx): + return self + + @property + def day(self): + "Returns the day of month." + return self.__getdateinfo__('D') + @property + def day_of_week(self): + "Returns the day of week." + return self.__getdateinfo__('W') + @property + def day_of_year(self): + "Returns the day of year." + return self.__getdateinfo__('R') + @property + def month(self): + "Returns the month." + return self.__getdateinfo__('M') + @property + def quarter(self): + "Returns the quarter." + return self.__getdateinfo__('Q') + @property + def year(self): + "Returns the year." + return self.__getdateinfo__('Y') + @property + def second(self): + "Returns the seconds." + return self.__getdateinfo__('S') + @property + def minute(self): + "Returns the minutes." + return self.__getdateinfo__('T') + @property + def hour(self): + "Returns the hour." + return self.__getdateinfo__('H') + @property + def week(self): + "Returns the week." + return self.__getdateinfo__('I') + + def __getdateinfo__(self, info): + return int(cseries.getDateInfo(numpy.asarray(self.value), + self.freq, info)) + __getDateInfo = __getdateinfo__ + + def __add__(self, other): + if isinstance(other, Date): + raise FrequencyDateError("Cannot add dates", + self.freqstr, other.freqstr) + return Date(freq=self.freq, value=int(self) + other) + + def __radd__(self, other): + return self+other + + def __sub__(self, other): + if isinstance(other, Date): + if self.freq != other.freq: + raise FrequencyDateError("Cannot subtract dates", \ + self.freqstr, other.freqstr) + else: + return int(self) - int(other) + else: + return self + (-1) * int(other) + + def __eq__(self, other): + if not hasattr(other, 'freq'): + return False + elif self.freq != other.freq: + raise FrequencyDateError("Cannot compare dates", \ + self.freqstr, other.freqstr) + return int(self) == int(other) + + def __cmp__(self, other): + if not hasattr(other, 'freq'): + return False + elif self.freq != other.freq: + raise FrequencyDateError("Cannot compare dates", \ + self.freqstr, other.freqstr) + return int(self)-int(other) + + def __hash__(self): + return hash(int(self)) ^ hash(self.freq) + + def __int__(self): + return self.value + + def __float__(self): + return float(self.value) + + def __value(self): + "Converts the date to an integer, depending on the current frequency." + # Annual ....... + if self.freqstr == 'A': + val = self.datetime.year + # Quarterly..... + elif self.freqstr == 'Q': + val = (self.datetime.year-1)*4 + self.datetime.month//3 + # Monthly....... + elif self.freqstr == 'M': + val = (self.datetime.year-1)*12 + self.datetime.month + # Weekly........ + elif self.freqstr == 'W': + val = self.datetime.toordinal()//7 + # Business days. + elif self.freqstr == 'B': + days = self.datetime.toordinal() + weeks = days // 7 + val = days - weeks*2 + # Daily/undefined + elif self.freqstr in 'DU': + val = self.datetime.toordinal() + # Hourly........ + elif self.freqstr == 'H': + delta = (self.datetime - hourlyOriginDate) + val = delta.days*24 + delta.seconds/(3600) + # Minutely...... + elif self.freqstr == 'T': + delta = (self.datetime - minutelyOriginDate) + val = delta.days*1440 + delta.seconds/(60) + # Secondly...... + elif self.freqstr == 'S': + delta = (self.datetime - secondlyOriginDate) + val = delta.days*86400 + delta.seconds + return int(val) + #...................................................... + def strfmt(self, fmt): + "Formats the date" + if fmt is None: + fmt = self.default_fmtstr[self.freqstr] + return cseries.strfmt(self.datetime, fmt) + + def __str__(self): + return self.strfmt(self.default_fmtstr[self.freqstr]) + + def __repr__(self): + return "<%s : %s>" % (str(self.freqstr), str(self)) + #...................................................... + def toordinal(self): + "Returns the date as an ordinal." + return self.datetime.toordinal() + + def fromordinal(self, ordinal): + "Returns the date as an ordinal." + return Date(self.freq, datetime=dt.datetime.fromordinal(ordinal)) + + def tostring(self): + "Returns the date as a string." + return str(self) + + def toobject(self): + "Returns the date as itself." + return self + + def isvalid(self): + "Returns whether the DateArray is valid: no missing/duplicated dates." + # A date is always valid by itself, but we need the object to support the function + # when we're working with singletons. + return True + #...................................................... + + +#####--------------------------------------------------------------------------- +#---- --- Functions --- +#####--------------------------------------------------------------------------- + +def mx_to_datetime(mxDate): + microsecond = 1000000*(mxDate.second % 1) + return dt.datetime(mxDate.year, mxDate.month, + mxDate.day, mxDate.hour, + mxDate.minute, + int(mxDate.second), microsecond) + + +def truncateDate(freq, datetime): + "Chops off the irrelevant information from the datetime object passed in." + freqstr = corelib.check_freqstr(freq) + if freqstr == 'A': + return dt.datetime(datetime.year, 1, 1) + elif freqstr == 'Q': + return dt.datetime(datetime.year, monthToQuarter(datetime.month)*3, 1) + elif freqstr == 'M': + return dt.datetime(datetime.year, datetime.month, 1) + elif freqstr == 'W': + d = datetime.toordinal() + return dt.datetime.fromordinal(d + (7 - d % 7) % 7) + elif freqstr in 'BD': + if freq == 'B' and datetime.isoweekday() in (6,7): + raise ValueError("Weekend passed as business day") + return dt.datetime(datetime.year, datetime.month, datetime.day) + elif freqstr == 'H': + return dt.datetime(datetime.year, datetime.month, datetime.day, \ + datetime.hour) + elif freqstr == 'T': + return dt.datetime(datetime.year, datetime.month, datetime.day, \ + datetime.hour, datetime.minute) + else: + return datetime + +def monthToQuarter(monthNum): + """Returns the quarter corresponding to the month `monthnum`. + For example, December is the 4th quarter, Januray the first.""" + return int((monthNum-1)/3)+1 + +def thisday(freq): + "Returns today's date, at the given frequency `freq`." + freqstr = corelib.check_freqstr(freq) + tempDate = dt.datetime.now() + # if it is Saturday or Sunday currently, freq==B, then we want to use Friday + if freqstr == 'B' and tempDate.isoweekday() >= 6: + tempDate = tempDate - dt.timedelta(days=(tempDate.isoweekday() - 5)) + if freqstr in ('B','D','H','S','T','W','U'): + return Date(freq, datetime=tempDate) + elif freqstr == 'M': + return Date(freq, year=tempDate.year, month=tempDate.month) + elif freqstr == 'Q': + return Date(freq, year=tempDate.year, quarter=monthToQuarter(tempDate.month)) + elif freqstr == 'A': + return Date(freq, year=tempDate.year) +today = thisday + +def prevbusday(day_end_hour=18, day_end_min=0): + "Returns the previous business day." + tempDate = dt.datetime.now() + dateNum = tempDate.hour + float(tempDate.minute)/60 + checkNum = day_end_hour + float(day_end_min)/60 + if dateNum < checkNum: + return thisday('B') - 1 + else: + return thisday('B') + +def asfreq(date, toFreq, relation="BEFORE"): + """Returns a date converted to another frequency `toFreq`, according to the + relation `relation` .""" + tofreq = corelib.check_freq(toFreq) + _rel = relation.upper()[0] + if _rel not in ['B', 'A']: + msg = "Invalid relation '%s': Should be in ['before', 'after']" + raise ValueError, msg % relation + + if not isinstance(date, Date): + raise DateError, "Date should be a valid Date instance!" + + if date.freqstr == 'U': + warnings.warn("Undefined frequency: assuming daily!") + fromfreq = corelib.freq_revdict['D'] + else: + fromfreq = date.freq + + if fromfreq == tofreq: + return date + else: + value = cseries.asfreq(numeric.asarray(date.value), fromfreq, tofreq, _rel) + if value > 0: + return Date(freq=tofreq, value=value) + else: + return None +Date.asfreq = asfreq + +def isDate(data): + "Returns whether `data` is an instance of Date." + return isinstance(data, Date) or \ + (hasattr(data,'freq') and hasattr(data,'value')) + + +#####--------------------------------------------------------------------------- +#---- --- DateArray --- +#####--------------------------------------------------------------------------- +ufunc_dateOK = ['add','subtract', + 'equal','not_equal','less','less_equal', 'greater','greater_equal', + 'isnan'] + +class _datearithmetics(object): + """Defines a wrapper for arithmetic methods. +Instead of directly calling a ufunc, the corresponding method of the `array._data` +object is called instead. +If `asdates` is True, a DateArray object is returned , else a regular ndarray +is returned. + """ + def __init__ (self, methodname, asdates=True): + """ +:Parameters: + - `methodname` (String) : Method name. + """ + self.methodname = methodname + self._asdates = asdates + self.__doc__ = getattr(methodname, '__doc__') + self.obj = None + # + def __get__(self, obj, objtype=None): + self.obj = obj + return self + # + def __call__ (self, other, *args, **kwargs): + "Execute the call behavior." + instance = self.obj + freq = instance.freq + if 'context' not in kwargs: + kwargs['context'] = 'DateOK' + method = getattr(super(DateArray,instance), self.methodname) + if isinstance(other, DateArray): + if other.freq != freq: + raise FrequencyDateError("Cannot operate on dates", \ + freq, other.freq) + elif isinstance(other, Date): + if other.freq != freq: + raise FrequencyDateError("Cannot operate on dates", \ + freq, other.freq) + other = other.value + elif isinstance(other, ndarray): + if other.dtype.kind not in ['i','f']: + raise ArithmeticDateError + if self._asdates: + return instance.__class__(method(other, *args), + freq=freq) + else: + return method(other, *args) + +class DateArray(ndarray): + """Defines a ndarray of dates, as ordinals. + +When viewed globally (array-wise), DateArray is an array of integers. +When viewed element-wise, DateArray is a sequence of dates. +For example, a test such as : +>>> DateArray(...) = value +will be valid only if value is an integer, not a Date +However, a loop such as : +>>> for d in DateArray(...): +accesses the array element by element. Therefore, `d` is a Date object. + """ + _defcachedinfo = dict(toobj=None, tostr=None, toord=None, + steps=None, full=None, hasdups=None) + def __new__(cls, dates=None, freq=None, copy=False): + # Get the frequency ...... + if freq is None: + _freq = getattr(dates, 'freq', -9999) + else: + _freq = corelib.check_freq(freq) + cls._defaultfreq = corelib.check_freq(_freq) + # Get the dates .......... + _dates = numeric.array(dates, copy=copy, dtype=int_, subok=1) + if _dates.ndim == 0: + _dates.shape = (1,) + _dates = _dates.view(cls) + _dates.freq = _freq + return _dates + + def __array_wrap__(self, obj, context=None): + if context is None: + return self + elif context[0].__name__ not in ufunc_dateOK: + raise ArithmeticDateError, "(function %s)" % context[0].__name__ + + def __array_finalize__(self, obj): + self.freq = getattr(obj, 'freq', -9999) + self._cachedinfo = dict(toobj=None, tostr=None, toord=None, + steps=None, full=None, hasdups=None) + if hasattr(obj,'_cachedinfo'): + self._cachedinfo.update(obj._cachedinfo) + return + + def __getitem__(self, indx): + if isinstance(indx, Date): + indx = self.find_dates(indx) + elif numeric.asarray(indx).dtype.kind == 'O': + try: + indx = self.find_dates(indx) + except AttributeError: + pass + r = ndarray.__getitem__(self, indx) + if isinstance(r, (generic, int)): + return Date(self.freq, value=r) + elif hasattr(r, 'size') and r.size == 1: + # need to check if it has a size attribute for situations + # like when the datearray is the data for a maskedarray + # or some other subclass of ndarray with wierd getitem + # behaviour + return Date(self.freq, value=r.item()) + else: + if hasattr(r, '_cachedinfo'): + r._cachedinfo.update(dict(steps=None, full=None, hasdups=None)) + for attr in ('tostr','toobj','toord'): + if r._cachedinfo[attr] is not None: + r._cachedinfo[attr] = r._cachedinfo[attr][indx] + return r + + def __repr__(self): + return ndarray.__repr__(self) + #...................................................... + __add__ = _datearithmetics('__add__', asdates=True) + __radd__ = _datearithmetics('__add__', asdates=True) + __sub__ = _datearithmetics('__sub__', asdates=True) + __rsub__ = _datearithmetics('__rsub__', asdates=True) + __le__ = _datearithmetics('__le__', asdates=False) + __lt__ = _datearithmetics('__lt__', asdates=False) + __ge__ = _datearithmetics('__ge__', asdates=False) + __gt__ = _datearithmetics('__gt__', asdates=False) + __eq__ = _datearithmetics('__eq__', asdates=False) + __ne__ = _datearithmetics('__ne__', asdates=False) + #...................................................... + @property + def freqstr(self): + "Returns the frequency string code." + return corelib.freq_tostr(self.freq) + @property + def day(self): + "Returns the day of month." + return self.__getdateinfo__('D') + @property + def day_of_week(self): + "Returns the day of week." + return self.__getdateinfo__('W') + @property + def day_of_year(self): + "Returns the day of year." + return self.__getdateinfo__('R') + @property + def month(self): + "Returns the month." + return self.__getdateinfo__('M') + @property + def quarter(self): + "Returns the quarter." + return self.__getdateinfo__('Q') + @property + def year(self): + "Returns the year." + return self.__getdateinfo__('Y') + @property + def second(self): + "Returns the seconds." + return self.__getdateinfo__('S') + @property + def minute(self): + "Returns the minutes." + return self.__getdateinfo__('T') + @property + def hour(self): + "Returns the hour." + return self.__getdateinfo__('H') + @property + def week(self): + "Returns the week." + return self.__getdateinfo__('I') + + days = day + weekdays = day_of_week + yeardays = day_of_year + months = month + quarters = quarter + years = year + seconds = second + minutes = minute + hours = hour + weeks = week + + def __getdateinfo__(self, info): + return numeric.asarray(cseries.getDateInfo(numeric.asarray(self), + self.freq, info), + dtype=int_) + __getDateInfo = __getdateinfo__ + #.... Conversion methods .................... + # + def tovalue(self): + "Converts the dates to integer values." + return numeric.asarray(self) + # + def toordinal(self): + "Converts the dates from values to ordinals." + # Note: we better try to cache the result + if self._cachedinfo['toord'] is None: +# diter = (Date(self.freq, value=d).toordinal() for d in self) + diter = (d.toordinal() for d in self) + toord = numeric.fromiter(diter, dtype=float_) + self._cachedinfo['toord'] = toord + return self._cachedinfo['toord'] + # + def tostring(self): + "Converts the dates to strings." + # Note: we better cache the result + if self._cachedinfo['tostr'] is None: + firststr = str(self[0]) + if self.size > 0: + ncharsize = len(firststr) + tostr = numpy.fromiter((str(d) for d in self), + dtype='|S%i' % ncharsize) + else: + tostr = firststr + self._cachedinfo['tostr'] = tostr + return self._cachedinfo['tostr'] + # + def asfreq(self, freq=None, relation="BEFORE"): + "Converts the dates to another frequency." + # Note: As we define a new object, we don't need caching + if freq is None or freq == -9999: + return self + tofreq = corelib.check_freq(freq) + if tofreq == self.freq: + return self + fromfreq = self.freq + _rel = relation.upper()[0] + new = cseries.asfreq(numeric.asarray(self), fromfreq, tofreq, _rel) + return DateArray(new, freq=freq) + #...................................................... + def find_dates(self, *dates): + "Returns the indices corresponding to given dates, as an array." + ifreq = self.freq + c = numpy.zeros(self.shape, bool_) + for d in corelib.flatargs(*dates): + if d.freq != ifreq: + d = d.asfreq(ifreq) + c += (self == d.value) + c = c.nonzero() + if fromnumeric.size(c) == 0: + raise IndexError, "Date out of bounds!" + return c + + def date_to_index(self, date): + "Returns the index corresponding to one given date, as an integer." + if self.isvalid(): + index = date.value - self[0].value + if index < 0 or index > self.size: + raise IndexError, "Date out of bounds!" + return index + else: + index_asarray = (self == date.value).nonzero() + if fromnumeric.size(index_asarray) == 0: + raise IndexError, "Date out of bounds!" + return index_asarray[0][0] + #...................................................... + def get_steps(self): + """Returns the time steps between consecutive dates. + The timesteps have the same unit as the frequency of the series.""" + if self.freq == 'U': + warnings.warn("Undefined frequency: assuming integers!") + if self._cachedinfo['steps'] is None: + _cached = self._cachedinfo + val = numeric.asarray(self).ravel() + if val.size > 1: + steps = val[1:] - val[:-1] + if _cached['full'] is None: + _cached['full'] = (steps.max() == 1) + if _cached['hasdups'] is None: + _cached['hasdups'] = (steps.min() == 0) + else: + _cached['full'] = True + _cached['hasdups'] = False + steps = numeric.array([], dtype=int_) + self._cachedinfo['steps'] = steps + return self._cachedinfo['steps'] + + def has_missing_dates(self): + "Returns whether the DateArray have missing dates." + if self._cachedinfo['full'] is None: + steps = self.get_steps() + return not(self._cachedinfo['full']) + + def isfull(self): + "Returns whether the DateArray has no missing dates." + if self._cachedinfo['full'] is None: + steps = self.get_steps() + return self._cachedinfo['full'] + + def has_duplicated_dates(self): + "Returns whether the DateArray has duplicated dates." + if self._cachedinfo['hasdups'] is None: + steps = self.get_steps() + return self._cachedinfo['hasdups'] + + def isvalid(self): + "Returns whether the DateArray is valid: no missing/duplicated dates." + return (self.isfull() and not self.has_duplicated_dates()) + #...................................................... + +#............................ + + +#####--------------------------------------------------------------------------- +#---- --- DateArray functions --- +#####--------------------------------------------------------------------------- +def isDateArray(a): + "Tests whether an array is a DateArray object." + return isinstance(a,DateArray) + +def guess_freq(dates): + """Tries to estimate the frequency of a list of dates, by checking the steps + between consecutive dates The steps should be in days. + Returns a frequency code (alpha character).""" + ddif = numeric.asarray(numpy.diff(dates)) + ddif.sort() + if ddif[0] == ddif[-1] == 1.: + fcode = 'D' + elif (ddif[0] == 1.) and (ddif[-1] == 3.): + fcode = 'B' + elif (ddif[0] > 3.) and (ddif[-1] == 7.): + fcode = 'W' + elif (ddif[0] >= 28.) and (ddif[-1] <= 31.): + fcode = 'M' + elif (ddif[0] >= 90.) and (ddif[-1] <= 92.): + fcode = 'Q' + elif (ddif[0] >= 365.) and (ddif[-1] <= 366.): + fcode = 'A' + elif numpy.abs(24.*ddif[0] - 1) <= 1e-5 and \ + numpy.abs(24.*ddif[-1] - 1) <= 1e-5: + fcode = 'H' + elif numpy.abs(1440.*ddif[0] - 1) <= 1e-5 and \ + numpy.abs(1440.*ddif[-1] - 1) <= 1e-5: + fcode = 'T' + elif numpy.abs(86400.*ddif[0] - 1) <= 1e-5 and \ + numpy.abs(86400.*ddif[-1] - 1) <= 1e-5: + fcode = 'S' + else: + warnings.warn("Unable to estimate the frequency! %.3f<>%.3f" %\ + (ddif[0], ddif[-1])) + fcode = 'U' + return fcode + + +def _listparser(dlist, freq=None): + "Constructs a DateArray from a list." + dlist = numeric.asarray(dlist) + dlist.sort() + if dlist.ndim == 0: + dlist.shape = (1,) + # Case #1: dates as strings ................. + if dlist.dtype.kind == 'S': + #...construct a list of ordinals + ords = numpy.fromiter((DateTimeFromString(s).toordinal() for s in dlist), + float_) + ords += 1 + #...try to guess the frequency + if freq is None: + freq = guess_freq(ords) + #...construct a list of dates + dates = [Date(freq, string=s) for s in dlist] + # Case #2: dates as numbers ................. + elif dlist.dtype.kind in 'if': + #...hopefully, they are values + if freq is None: + freq = guess_freq(dlist) + dates = dlist + # Case #3: dates as objects ................. + elif dlist.dtype.kind == 'O': + template = dlist[0] + #...as Date objects + if isinstance(template, Date): + dates = numpy.fromiter((d.value for d in dlist), int_) + #...as mx.DateTime objects + elif hasattr(template,'absdays'): + # no freq given: try to guess it from absdays + if freq is None: + ords = numpy.fromiter((s.absdays for s in dlist), float_) + ords += 1 + freq = guess_freq(ords) + dates = [Date(freq, datetime=m) for m in dlist] + #...as datetime objects + elif hasattr(template, 'toordinal'): + ords = numpy.fromiter((d.toordinal() for d in dlist), float_) + if freq is None: + freq = guess_freq(ords) + dates = [Date(freq, datetime=dt.datetime.fromordinal(a)) for a in ords] + # + result = DateArray(dates, freq) + return result + + +def date_array(dlist=None, start_date=None, end_date=None, length=None, + include_last=True, freq=None): + """Constructs a DateArray from: + - a starting date and either an ending date or a given length. + - a list of dates. + """ + freq = corelib.check_freq(freq) + # Case #1: we have a list ................... + if dlist is not None: + # Already a DateArray.................... + if isinstance(dlist, DateArray): + if (freq is not None) and (dlist.freq != corelib.check_freq(freq)): + return dlist.asfreq(freq) + else: + return dlist + # Make sure it's a sequence, else that's a start_date + if hasattr(dlist,'__len__'): + return _listparser(dlist, freq) + elif start_date is not None: + if end_date is not None: + dmsg = "What starting date should be used ? '%s' or '%s' ?" + raise DateError, dmsg % (dlist, start_date) + else: + (start_date, end_date) = (dlist, start_date) + else: + start_date = dlist + # Case #2: we have a starting date .......... + if start_date is None: + if length == 0: + return DateArray([], freq=freq) + raise InsufficientDateError + if not isDate(start_date): + dmsg = "Starting date should be a valid Date instance! " + dmsg += "(got '%s' instead)" % type(start_date) + raise DateError, dmsg + # Check if we have an end_date + if end_date is None: + if length is None: +# raise ValueError,"No length precised!" + length = 1 + else: + if not isDate(end_date): + raise DateError, "Ending date should be a valid Date instance!" + length = int(end_date - start_date) + if include_last: + length += 1 +# dlist = [(start_date+i).value for i in range(length)] + dlist = numeric.arange(length, dtype=int_) + dlist += start_date.value + if freq is None: + freq = start_date.freq + return DateArray(dlist, freq=freq) +datearray = date_array + +def date_array_fromlist(dlist, freq=None): + "Constructs a DateArray from a list of dates." + return date_array(dlist=dlist, freq=freq) + +def date_array_fromrange(start_date, end_date=None, length=None, + include_last=True, freq=None): + """Constructs a DateArray from a starting date and either an ending date or + a length.""" + return date_array(start_date=start_date, end_date=end_date, + length=length, include_last=include_last, freq=freq) + +#####--------------------------------------------------------------------------- +#---- --- Definition of functions from the corresponding methods --- +#####--------------------------------------------------------------------------- +class _frommethod(object): + """Defines functions from existing MaskedArray methods. +:ivar _methodname (String): Name of the method to transform. + """ + def __init__(self, methodname): + self._methodname = methodname + self.__doc__ = self.getdoc() + def getdoc(self): + "Returns the doc of the function (from the doc of the method)." + try: + return getattr(DateArray, self._methodname).__doc__ + except AttributeError: + return "???" + # + def __call__(self, caller, *args, **params): + if hasattr(caller, self._methodname): + method = getattr(caller, self._methodname) + # If method is not callable, it's a property, and don't call it + if hasattr(method, '__call__'): + return method.__call__(*args, **params) + return method + method = getattr(fromnumeric.asarray(caller), self._methodname) + try: + return method(*args, **params) + except SystemError: + return getattr(numpy,self._methodname).__call__(caller, *args, **params) +#............................ +day_of_week = _frommethod('day_of_week') +day_of_year = _frommethod('day_of_year') +year = _frommethod('year') +quarter = _frommethod('quarter') +month = _frommethod('month') +day = _frommethod('day') +hour = _frommethod('hour') +minute = _frommethod('minute') +second = _frommethod('second') + + +def period_break(dates, period): + """Returns the indices where the given period changes. + +:Parameters: + dates : DateArray + Array of dates to monitor. + period : string + Name of the period to monitor. + """ + current = getattr(dates, period) + previous = getattr(dates-1, period) + return (current - previous).nonzero()[0] + + +################################################################################ + +if __name__ == '__main__': + import maskedarray.testutils + from maskedarray.testutils import assert_equal + if 1: + dlist = ['2007-%02i' % i for i in range(1,5)+range(7,13)] + mdates = date_array_fromlist(dlist, 'M') + # Using an integer + assert_equal(mdates[0].value, 24073) + assert_equal(mdates[-1].value, 24084) + # Using a date + lag = mdates.find_dates(mdates[0]) + print mdates[lag] + assert_equal(mdates[lag], mdates[0]) + if 1: + hodie = today('D') + D = DateArray(today('D')) + assert_equal(D.freq, 6000) + + if 1: + freqs = [x[0] for x in corelib.freq_dict.values() if x[0] != 'U'] + print freqs + for f in freqs: + print f + today = thisday(f) + assert(Date(freq=f, value=today.value) == today) + + if 1: + D = date_array(start_date=thisday('D'), length=5) + Dstr = D.tostring() + assert_equal(D.tostring(), Dstr) + DL = D[[0,-1]] + assert_equal(DL.tostring(), Dstr[[0,-1]]) + \ No newline at end of file Property changes on: trunk/Lib/sandbox/timeseries/tdates.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id From scipy-svn at scipy.org Fri Mar 2 03:54:09 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Mar 2007 02:54:09 -0600 (CST) Subject: [Scipy-svn] r2810 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070302085409.5F12539C29C@new.scipy.org> Author: pierregm Date: 2007-03-02 02:54:05 -0600 (Fri, 02 Mar 2007) New Revision: 2810 Removed: trunk/Lib/sandbox/timeseries/tests/test_misc.py Log: tests/test_misc : deleted, dispatched to addons/tests/ Deleted: trunk/Lib/sandbox/timeseries/tests/test_misc.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_misc.py 2007-03-02 08:49:29 UTC (rev 2809) +++ trunk/Lib/sandbox/timeseries/tests/test_misc.py 2007-03-02 08:54:05 UTC (rev 2810) @@ -1,70 +0,0 @@ -# pylint: disable-msg=W0611, W0612, W0511,R0201 -"""Tests suite for miscellaneous functions in timeseries module. -Adapted from the original test_ma by Pierre Gerard-Marchant - -:author: Pierre Gerard-Marchant & Matt Knox -:contact: pierregm_at_uga_dot_edu & mattknox_ca_at_hotmail_dot_com -:version: $Id$ -""" -__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" -__version__ = '1.0' -__revision__ = "$Revision$" -__date__ = '$Date$' - -import numpy as N -from numpy import bool_, complex_, float_, int_, object_ -import numpy.core.fromnumeric as fromnumeric -import numpy.core.numeric as numeric -from numpy.testing import NumpyTest, NumpyTestCase -from numpy.testing.utils import build_err_msg - -import maskedarray -from maskedarray import masked_array, masked, nomask - -import maskedarray.testutils -from maskedarray.testutils import assert_equal, assert_array_equal, approx - -from timeseries import extras - -class test_funcs(NumpyTestCase): - - def __init__(self, *args, **kwds): - NumpyTestCase.__init__(self, *args, **kwds) - self.mask = [1,0,1,0,0,1,1,0,0,0] - self.data = numeric.arange(10) - self.test_array = masked_array(self.data, mask=self.mask) - - def test_backward_fill (self): - result = masked_array(self.data, mask=self.mask) - result[0] = 1 - result[2] = 3 - - assert_equal(extras.backward_fill(self.test_array, maxgap=1), result) - - result[5] = 7 - result[6] = 7 - - assert_equal(extras.backward_fill(self.test_array), result) - - def test_forward_fill (self): - result = masked_array(self.data, mask=self.mask) - result[2] = 1 - - assert_equal(extras.forward_fill(self.test_array, maxgap=1), result) - - result[5] = 4 - result[6] = 4 - - assert_equal(extras.forward_fill(self.test_array), result) - - def test_interp_fill(self): - result_lin = masked_array(self.data).astype(float_) - result_lin[0] = masked - - approx(extras.interp_masked1d(self.test_array.astype(float_), kind='linear'), result_lin) - - -############################################################################### -#------------------------------------------------------------------------------ -if __name__ == "__main__": - NumpyTest().run() \ No newline at end of file From scipy-svn at scipy.org Fri Mar 2 06:30:05 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Mar 2007 05:30:05 -0600 (CST) Subject: [Scipy-svn] r2811 - in trunk/Lib/sandbox/timeseries: . addons Message-ID: <20070302113005.48F9339C353@new.scipy.org> Author: pierregm Date: 2007-03-02 05:30:02 -0600 (Fri, 02 Mar 2007) New Revision: 2811 Modified: trunk/Lib/sandbox/timeseries/addons/filters.py trunk/Lib/sandbox/timeseries/setup.py Log: setup : update to the new folder hierarchy addons/filters : added weighted_moving_average + running_window Modified: trunk/Lib/sandbox/timeseries/addons/filters.py =================================================================== --- trunk/Lib/sandbox/timeseries/addons/filters.py 2007-03-02 08:54:05 UTC (rev 2810) +++ trunk/Lib/sandbox/timeseries/addons/filters.py 2007-03-02 11:30:02 UTC (rev 2811) @@ -30,38 +30,60 @@ #---- --- Moving average functions --- #####--------------------------------------------------------------------------- def expmave(data, n, tol=1e-6): - """Calculate the exponential moving average of a series. + """Calculates the exponential moving average of a series. :Parameters: - - `data` (ndarray, MaskedArray) : data is a valid ndarray or MaskedArray - or an instance of a subclass of these types. In particular, TimeSeries - objects are valid here. - - `n` (int) : time periods. Where the smoothing factor is 2/(n + 1) - - `tol` (float, *[1e-6]*) : when `data` contains masked values, this - parameter will determine what points in the result should be masked. - Values in the result that would not be "significantly" impacted (as - determined by this parameter) by the masked values are left unmasked. + data : ndarray + Data as a valid (subclass of) ndarray or MaskedArray. In particular, + TimeSeries objects are valid here. + n : int + Time periods. The smoothing factor is 2/(n + 1) + tol : float, *[1e-6]* + Tolerance for the definition of the mask. When data contains masked + values, this parameter determinea what points in the result should be masked. + Values in the result that would not be "significantly" impacted (as + determined by this parameter) by the masked values are left unmasked. """ - if isinstance(data, MaskedArray): - ismasked = (data._mask is not nomask) - else: - ismasked = False + data = marray(data, copy=True, subok=True) + ismasked = (data._mask is not nomask) + data._mask = N.zeros(data.shape, bool_) + _data = data._data # k = 2./float(n + 1) def expmave_sub(a, b): return b + k * (a - b) - # - if ismasked: - data = data.filled(0) # - result = N.frompyfunc(expmave_sub, 2, 1).accumulate(data).astype(data.dtype) + data._data.flat = N.frompyfunc(expmave_sub, 2, 1).accumulate(_data) if ismasked: - _unmasked = N.logical_not(getmask(data)).astype(float_) - marker = 1 - N.frompyfunc(expmave_sub, 2, 1).accumulate(_unmasked) - result[marker > tol] = masked + _unmasked = N.logical_not(data._mask).astype(float_) + marker = 1. - N.frompyfunc(expmave_sub, 2, 1).accumulate(_unmasked) + data._mask[marker > tol] = True + data._mask[0] = True # - return result + return data +def weightmave(data, n): + data = marray(data, subok=True, copy=True) + data._mask = N.zeros(data.shape, bool_) + # Set the data + _data = data._data + tmp = N.empty_like(_data) + tmp[:n] = _data[:n] + s = 0 + for i in range(n, len(data)): + s += _data[i] - _data[i-n] + tmp[i] = n*_data[i] + tmp[i-1] - s + tmp *= 2./(n*(n+1)) + data._data.flat = tmp + # Set the mask + if data._mask is not nomask: + msk = data._mask.nonzero()[0].repeat(n).reshape(-1,n) + msk += range(n) + data._mask[msk.ravel()] = True + data._mask[:n] = True + return data + + #............................................................................... def running_window(data, window_type, window_size): """Applies a running window of type window_type and size window_size on the @@ -134,4 +156,5 @@ if __name__ == '__main__': from maskedarray.testutils import assert_equal, assert_almost_equal from timeseries import time_series, thisday - + # + data = MA.arange(100) Modified: trunk/Lib/sandbox/timeseries/setup.py =================================================================== --- trunk/Lib/sandbox/timeseries/setup.py 2007-03-02 08:54:05 UTC (rev 2810) +++ trunk/Lib/sandbox/timeseries/setup.py 2007-03-02 11:30:02 UTC (rev 2811) @@ -15,8 +15,11 @@ sources=[sources,], include_dirs=[nxheader], ) - confgr.add_data_dir('doc') - confgr.add_data_dir('examples') + confgr.add_data_dir('docs') + confgr.add_subpackage('addons') + confgr.add_subpackage('io') + confgr.add_subpackage('plotlib') + confgr.add_subpackage('tests') return confgr if __name__ == "__main__": From scipy-svn at scipy.org Fri Mar 2 10:03:10 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Mar 2007 09:03:10 -0600 (CST) Subject: [Scipy-svn] r2812 - trunk/Lib/sandbox/timeseries Message-ID: <20070302150310.36CD039C0D0@new.scipy.org> Author: mattknox_ca Date: 2007-03-02 09:03:05 -0600 (Fri, 02 Mar 2007) New Revision: 2812 Added: trunk/Lib/sandbox/timeseries/tdates.py Removed: trunk/Lib/sandbox/timeseries/tdates.py Log: attempting to restore original svn branch of tdates.py Deleted: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-02 11:30:02 UTC (rev 2811) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-02 15:03:05 UTC (rev 2812) @@ -1,1064 +0,0 @@ -""" -Classes definition for the support of individual dates and array of dates. - -:author: Pierre GF Gerard-Marchant & Matt Knox -:contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com -:version: $Id$ -""" -__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" -__version__ = '1.0' -__revision__ = "$Revision$" -__date__ = '$Date$' - -import datetime as dt - -import itertools -import warnings -import types - - -import numpy -from numpy import bool_, float_, int_, object_ -from numpy import ndarray -import numpy.core.numeric as numeric -import numpy.core.fromnumeric as fromnumeric -import numpy.core.numerictypes as ntypes -from numpy.core.numerictypes import generic - -import maskedarray as MA - -try: - from mx.DateTime import DateTimeType -except ImportError: - class DateTimeType: pass - -from parser import DateFromString, DateTimeFromString - -import tcore as corelib -import cseries - - - -__all__ = [ -'Date', 'DateArray','isDate','isDateArray', -'DateError', 'ArithmeticDateError', 'FrequencyDateError','InsufficientDateError', -'datearray','date_array', 'date_array_fromlist', 'date_array_fromrange', -'day_of_week','day_of_year','day','month','quarter','year','hour','minute','second', -'truncateDate','monthToQuarter','thisday','today','prevbusday','asfreq', -'period_break' - ] - - -#####--------------------------------------------------------------------------- -#---- --- Date Info --- -#####--------------------------------------------------------------------------- - -OriginDate = dt.datetime(1970, 1, 1) -secondlyOriginDate = OriginDate - dt.timedelta(seconds=1) -minutelyOriginDate = OriginDate - dt.timedelta(minutes=1) -hourlyOriginDate = OriginDate - dt.timedelta(hours=1) - - -#####--------------------------------------------------------------------------- -#---- --- Date Exceptions --- -#####--------------------------------------------------------------------------- -class DateError(Exception): - """Defines a generic DateArrayError.""" - def __init__ (self, args=None): - "Create an exception" - Exception.__init__(self) - self.args = args - def __str__(self): - "Calculate the string representation" - return str(self.args) - __repr__ = __str__ - -class InsufficientDateError(DateError): - """Defines the exception raised when there is not enough information - to create a Date object.""" - def __init__(self, msg=None): - if msg is None: - msg = "Insufficient parameters given to create a date at the given frequency" - DateError.__init__(self, msg) - -class FrequencyDateError(DateError): - """Defines the exception raised when the frequencies are incompatible.""" - def __init__(self, msg, freql=None, freqr=None): - msg += " : Incompatible frequencies!" - if not (freql is None or freqr is None): - msg += " (%s<>%s)" % (freql, freqr) - DateError.__init__(self, msg) - -class ArithmeticDateError(DateError): - """Defines the exception raised when dates are used in arithmetic expressions.""" - def __init__(self, msg=''): - msg += " Cannot use dates for arithmetics!" - DateError.__init__(self, msg) - -#####--------------------------------------------------------------------------- -#---- --- Date Class --- -#####--------------------------------------------------------------------------- - -class Date: - """Defines a Date object, as the combination of a date and a frequency. - Several options are available to construct a Date object explicitly: - - - Give appropriate values to the `year`, `month`, `day`, `quarter`, `hours`, - `minutes`, `seconds` arguments. - - >>> td.Date(freq='Q',year=2004,quarter=3) - >>> td.Date(freq='D',year=2001,month=1,day=1) - - - Use the `string` keyword. This method calls the `mx.DateTime.Parser` - submodule, more information is available in its documentation. - - >>> ts.Date('D', '2007-01-01') - - - Use the `datetime` keyword with an existing datetime.datetime object. - - >>> td.Date('D', datetime=datetime.datetime.now()) - """ - default_fmtstr = {'A': "%Y", - 'Q': "%YQ%q", - 'M': "%b-%Y", - 'W': "%d-%b-%Y", - 'B': "%d-%b-%Y", - 'D': "%d-%b-%Y", - 'U': "%d-%b-%Y", - 'H': "%d-%b-%Y %H:00", - 'T': "%d-%b-%Y %H:%M", - 'S': "%d-%b-%Y %H:%M:%S" - } - - def __init__(self, freq, value=None, string=None, - year=None, month=None, day=None, quarter=None, - hour=None, minute=None, second=None, - datetime=None): - - if hasattr(freq, 'freq'): - self.freq = corelib.check_freq(freq.freq) - else: - self.freq = corelib.check_freq(freq) - self.freqstr = corelib.freq_tostr(self.freq) - - - if value is not None: - if isinstance(value, ndarray): - value = int(value) - - if isinstance(value, str): - if self.freqstr in ('H', 'T', 'S'): - self.datetime = DateTimeFromString(value) - else: - self.datetime = DateFromString(value) - elif self.freqstr == 'A': - self.datetime = dt.datetime(value, 1, 1) - elif self.freqstr == 'B': - valtmp = (value - 1)//5 - self.datetime = dt.datetime.fromordinal(value + valtmp*2) - elif self.freqstr in ['D','U']: - self.datetime = dt.datetime.fromordinal(value) - elif self.freqstr == 'H': - self.datetime = hourlyOriginDate + dt.timedelta(hours=value) - elif self.freqstr == 'M': - year = (value - 1)//12 + 1 - month = value - (year - 1)*12 - self.datetime = dt.datetime(year, month, 1) - elif self.freqstr == 'Q': - year = (value - 1)//4 + 1 - month = (value - (year - 1)*4)*3 - self.datetime = dt.datetime(year, month, 1) - elif self.freqstr == 'S': - self.datetime = secondlyOriginDate + dt.timedelta(seconds=value) - elif self.freqstr == 'T': - self.datetime = minutelyOriginDate + dt.timedelta(minutes=value) - elif self.freqstr == 'W': - self.datetime = dt.datetime(1,1,7) + \ - dt.timedelta(days=(value-1)*7) - - elif string is not None: - if self.freqstr in ('H', 'T', 'S'): - self.datetime = DateTimeFromString(string) - else: - self.datetime = DateFromString(string) - - elif datetime is not None: - if isinstance(datetime, DateTimeType): - datetime = mx_to_datetime(datetime) - self.datetime = truncateDate(self.freq, datetime) - - else: - # First, some basic checks..... - if year is None: - raise InsufficientDateError - if self.freqstr in 'BDWU': - if month is None or day is None: - raise InsufficientDateError - elif self.freqstr == 'M': - if month is None: - raise InsufficientDateError - day = 1 - elif self.freqstr == 'Q': - if quarter is None: - raise InsufficientDateError - month = quarter * 3 - day = 1 - elif self.freqstr == 'A': - month = 1 - day = 1 - elif self.freqstr == 'S': - if month is None or day is None or second is None: - raise InsufficientDateError - - if self.freqstr in ['A','B','D','M','Q','W']: - self.datetime = truncateDate(self.freq, dt.datetime(year, month, day)) - if self.freqstr == 'B': - if self.datetime.isoweekday() in [6,7]: - raise ValueError("Weekend passed as business day") - elif self.freqstr in 'HTS': - if hour is None: - if minute is None: - if second is None: - hour = 0 - else: - hour = second//3600 - else: - hour = minute // 60 - if minute is None: - if second is None: - minute = 0 - else: - minute = (second-hour*3600)//60 - if second is None: - second = 0 - else: - second = second % 60 - self.datetime = truncateDate(self.freqstr, - dt.datetime(year, month, day, - hour, minute, second)) - self.value = self.__value() - - def __getitem__(self, indx): - return self - - @property - def day(self): - "Returns the day of month." - return self.__getdateinfo__('D') - @property - def day_of_week(self): - "Returns the day of week." - return self.__getdateinfo__('W') - @property - def day_of_year(self): - "Returns the day of year." - return self.__getdateinfo__('R') - @property - def month(self): - "Returns the month." - return self.__getdateinfo__('M') - @property - def quarter(self): - "Returns the quarter." - return self.__getdateinfo__('Q') - @property - def year(self): - "Returns the year." - return self.__getdateinfo__('Y') - @property - def second(self): - "Returns the seconds." - return self.__getdateinfo__('S') - @property - def minute(self): - "Returns the minutes." - return self.__getdateinfo__('T') - @property - def hour(self): - "Returns the hour." - return self.__getdateinfo__('H') - @property - def week(self): - "Returns the week." - return self.__getdateinfo__('I') - - def __getdateinfo__(self, info): - return int(cseries.getDateInfo(numpy.asarray(self.value), - self.freq, info)) - __getDateInfo = __getdateinfo__ - - def __add__(self, other): - if isinstance(other, Date): - raise FrequencyDateError("Cannot add dates", - self.freqstr, other.freqstr) - return Date(freq=self.freq, value=int(self) + other) - - def __radd__(self, other): - return self+other - - def __sub__(self, other): - if isinstance(other, Date): - if self.freq != other.freq: - raise FrequencyDateError("Cannot subtract dates", \ - self.freqstr, other.freqstr) - else: - return int(self) - int(other) - else: - return self + (-1) * int(other) - - def __eq__(self, other): - if not hasattr(other, 'freq'): - return False - elif self.freq != other.freq: - raise FrequencyDateError("Cannot compare dates", \ - self.freqstr, other.freqstr) - return int(self) == int(other) - - def __cmp__(self, other): - if not hasattr(other, 'freq'): - return False - elif self.freq != other.freq: - raise FrequencyDateError("Cannot compare dates", \ - self.freqstr, other.freqstr) - return int(self)-int(other) - - def __hash__(self): - return hash(int(self)) ^ hash(self.freq) - - def __int__(self): - return self.value - - def __float__(self): - return float(self.value) - - def __value(self): - "Converts the date to an integer, depending on the current frequency." - # Annual ....... - if self.freqstr == 'A': - val = self.datetime.year - # Quarterly..... - elif self.freqstr == 'Q': - val = (self.datetime.year-1)*4 + self.datetime.month//3 - # Monthly....... - elif self.freqstr == 'M': - val = (self.datetime.year-1)*12 + self.datetime.month - # Weekly........ - elif self.freqstr == 'W': - val = self.datetime.toordinal()//7 - # Business days. - elif self.freqstr == 'B': - days = self.datetime.toordinal() - weeks = days // 7 - val = days - weeks*2 - # Daily/undefined - elif self.freqstr in 'DU': - val = self.datetime.toordinal() - # Hourly........ - elif self.freqstr == 'H': - delta = (self.datetime - hourlyOriginDate) - val = delta.days*24 + delta.seconds/(3600) - # Minutely...... - elif self.freqstr == 'T': - delta = (self.datetime - minutelyOriginDate) - val = delta.days*1440 + delta.seconds/(60) - # Secondly...... - elif self.freqstr == 'S': - delta = (self.datetime - secondlyOriginDate) - val = delta.days*86400 + delta.seconds - return int(val) - #...................................................... - def strfmt(self, fmt): - "Formats the date" - if fmt is None: - fmt = self.default_fmtstr[self.freqstr] - return cseries.strfmt(self.datetime, fmt) - - def __str__(self): - return self.strfmt(self.default_fmtstr[self.freqstr]) - - def __repr__(self): - return "<%s : %s>" % (str(self.freqstr), str(self)) - #...................................................... - def toordinal(self): - "Returns the date as an ordinal." - return self.datetime.toordinal() - - def fromordinal(self, ordinal): - "Returns the date as an ordinal." - return Date(self.freq, datetime=dt.datetime.fromordinal(ordinal)) - - def tostring(self): - "Returns the date as a string." - return str(self) - - def toobject(self): - "Returns the date as itself." - return self - - def isvalid(self): - "Returns whether the DateArray is valid: no missing/duplicated dates." - # A date is always valid by itself, but we need the object to support the function - # when we're working with singletons. - return True - #...................................................... - - -#####--------------------------------------------------------------------------- -#---- --- Functions --- -#####--------------------------------------------------------------------------- - -def mx_to_datetime(mxDate): - microsecond = 1000000*(mxDate.second % 1) - return dt.datetime(mxDate.year, mxDate.month, - mxDate.day, mxDate.hour, - mxDate.minute, - int(mxDate.second), microsecond) - - -def truncateDate(freq, datetime): - "Chops off the irrelevant information from the datetime object passed in." - freqstr = corelib.check_freqstr(freq) - if freqstr == 'A': - return dt.datetime(datetime.year, 1, 1) - elif freqstr == 'Q': - return dt.datetime(datetime.year, monthToQuarter(datetime.month)*3, 1) - elif freqstr == 'M': - return dt.datetime(datetime.year, datetime.month, 1) - elif freqstr == 'W': - d = datetime.toordinal() - return dt.datetime.fromordinal(d + (7 - d % 7) % 7) - elif freqstr in 'BD': - if freq == 'B' and datetime.isoweekday() in (6,7): - raise ValueError("Weekend passed as business day") - return dt.datetime(datetime.year, datetime.month, datetime.day) - elif freqstr == 'H': - return dt.datetime(datetime.year, datetime.month, datetime.day, \ - datetime.hour) - elif freqstr == 'T': - return dt.datetime(datetime.year, datetime.month, datetime.day, \ - datetime.hour, datetime.minute) - else: - return datetime - -def monthToQuarter(monthNum): - """Returns the quarter corresponding to the month `monthnum`. - For example, December is the 4th quarter, Januray the first.""" - return int((monthNum-1)/3)+1 - -def thisday(freq): - "Returns today's date, at the given frequency `freq`." - freqstr = corelib.check_freqstr(freq) - tempDate = dt.datetime.now() - # if it is Saturday or Sunday currently, freq==B, then we want to use Friday - if freqstr == 'B' and tempDate.isoweekday() >= 6: - tempDate = tempDate - dt.timedelta(days=(tempDate.isoweekday() - 5)) - if freqstr in ('B','D','H','S','T','W','U'): - return Date(freq, datetime=tempDate) - elif freqstr == 'M': - return Date(freq, year=tempDate.year, month=tempDate.month) - elif freqstr == 'Q': - return Date(freq, year=tempDate.year, quarter=monthToQuarter(tempDate.month)) - elif freqstr == 'A': - return Date(freq, year=tempDate.year) -today = thisday - -def prevbusday(day_end_hour=18, day_end_min=0): - "Returns the previous business day." - tempDate = dt.datetime.now() - dateNum = tempDate.hour + float(tempDate.minute)/60 - checkNum = day_end_hour + float(day_end_min)/60 - if dateNum < checkNum: - return thisday('B') - 1 - else: - return thisday('B') - -def asfreq(date, toFreq, relation="BEFORE"): - """Returns a date converted to another frequency `toFreq`, according to the - relation `relation` .""" - tofreq = corelib.check_freq(toFreq) - _rel = relation.upper()[0] - if _rel not in ['B', 'A']: - msg = "Invalid relation '%s': Should be in ['before', 'after']" - raise ValueError, msg % relation - - if not isinstance(date, Date): - raise DateError, "Date should be a valid Date instance!" - - if date.freqstr == 'U': - warnings.warn("Undefined frequency: assuming daily!") - fromfreq = corelib.freq_revdict['D'] - else: - fromfreq = date.freq - - if fromfreq == tofreq: - return date - else: - value = cseries.asfreq(numeric.asarray(date.value), fromfreq, tofreq, _rel) - if value > 0: - return Date(freq=tofreq, value=value) - else: - return None -Date.asfreq = asfreq - -def isDate(data): - "Returns whether `data` is an instance of Date." - return isinstance(data, Date) or \ - (hasattr(data,'freq') and hasattr(data,'value')) - - -#####--------------------------------------------------------------------------- -#---- --- DateArray --- -#####--------------------------------------------------------------------------- -ufunc_dateOK = ['add','subtract', - 'equal','not_equal','less','less_equal', 'greater','greater_equal', - 'isnan'] - -class _datearithmetics(object): - """Defines a wrapper for arithmetic methods. -Instead of directly calling a ufunc, the corresponding method of the `array._data` -object is called instead. -If `asdates` is True, a DateArray object is returned , else a regular ndarray -is returned. - """ - def __init__ (self, methodname, asdates=True): - """ -:Parameters: - - `methodname` (String) : Method name. - """ - self.methodname = methodname - self._asdates = asdates - self.__doc__ = getattr(methodname, '__doc__') - self.obj = None - # - def __get__(self, obj, objtype=None): - self.obj = obj - return self - # - def __call__ (self, other, *args, **kwargs): - "Execute the call behavior." - instance = self.obj - freq = instance.freq - if 'context' not in kwargs: - kwargs['context'] = 'DateOK' - method = getattr(super(DateArray,instance), self.methodname) - if isinstance(other, DateArray): - if other.freq != freq: - raise FrequencyDateError("Cannot operate on dates", \ - freq, other.freq) - elif isinstance(other, Date): - if other.freq != freq: - raise FrequencyDateError("Cannot operate on dates", \ - freq, other.freq) - other = other.value - elif isinstance(other, ndarray): - if other.dtype.kind not in ['i','f']: - raise ArithmeticDateError - if self._asdates: - return instance.__class__(method(other, *args), - freq=freq) - else: - return method(other, *args) - -class DateArray(ndarray): - """Defines a ndarray of dates, as ordinals. - -When viewed globally (array-wise), DateArray is an array of integers. -When viewed element-wise, DateArray is a sequence of dates. -For example, a test such as : ->>> DateArray(...) = value -will be valid only if value is an integer, not a Date -However, a loop such as : ->>> for d in DateArray(...): -accesses the array element by element. Therefore, `d` is a Date object. - """ - _defcachedinfo = dict(toobj=None, tostr=None, toord=None, - steps=None, full=None, hasdups=None) - def __new__(cls, dates=None, freq=None, copy=False): - # Get the frequency ...... - if freq is None: - _freq = getattr(dates, 'freq', -9999) - else: - _freq = corelib.check_freq(freq) - cls._defaultfreq = corelib.check_freq(_freq) - # Get the dates .......... - _dates = numeric.array(dates, copy=copy, dtype=int_, subok=1) - if _dates.ndim == 0: - _dates.shape = (1,) - _dates = _dates.view(cls) - _dates.freq = _freq - return _dates - - def __array_wrap__(self, obj, context=None): - if context is None: - return self - elif context[0].__name__ not in ufunc_dateOK: - raise ArithmeticDateError, "(function %s)" % context[0].__name__ - - def __array_finalize__(self, obj): - self.freq = getattr(obj, 'freq', -9999) - self._cachedinfo = dict(toobj=None, tostr=None, toord=None, - steps=None, full=None, hasdups=None) - if hasattr(obj,'_cachedinfo'): - self._cachedinfo.update(obj._cachedinfo) - return - - def __getitem__(self, indx): - if isinstance(indx, Date): - indx = self.find_dates(indx) - elif numeric.asarray(indx).dtype.kind == 'O': - try: - indx = self.find_dates(indx) - except AttributeError: - pass - r = ndarray.__getitem__(self, indx) - if isinstance(r, (generic, int)): - return Date(self.freq, value=r) - elif hasattr(r, 'size') and r.size == 1: - # need to check if it has a size attribute for situations - # like when the datearray is the data for a maskedarray - # or some other subclass of ndarray with wierd getitem - # behaviour - return Date(self.freq, value=r.item()) - else: - if hasattr(r, '_cachedinfo'): - r._cachedinfo.update(dict(steps=None, full=None, hasdups=None)) - for attr in ('tostr','toobj','toord'): - if r._cachedinfo[attr] is not None: - r._cachedinfo[attr] = r._cachedinfo[attr][indx] - return r - - def __repr__(self): - return ndarray.__repr__(self) - #...................................................... - __add__ = _datearithmetics('__add__', asdates=True) - __radd__ = _datearithmetics('__add__', asdates=True) - __sub__ = _datearithmetics('__sub__', asdates=True) - __rsub__ = _datearithmetics('__rsub__', asdates=True) - __le__ = _datearithmetics('__le__', asdates=False) - __lt__ = _datearithmetics('__lt__', asdates=False) - __ge__ = _datearithmetics('__ge__', asdates=False) - __gt__ = _datearithmetics('__gt__', asdates=False) - __eq__ = _datearithmetics('__eq__', asdates=False) - __ne__ = _datearithmetics('__ne__', asdates=False) - #...................................................... - @property - def freqstr(self): - "Returns the frequency string code." - return corelib.freq_tostr(self.freq) - @property - def day(self): - "Returns the day of month." - return self.__getdateinfo__('D') - @property - def day_of_week(self): - "Returns the day of week." - return self.__getdateinfo__('W') - @property - def day_of_year(self): - "Returns the day of year." - return self.__getdateinfo__('R') - @property - def month(self): - "Returns the month." - return self.__getdateinfo__('M') - @property - def quarter(self): - "Returns the quarter." - return self.__getdateinfo__('Q') - @property - def year(self): - "Returns the year." - return self.__getdateinfo__('Y') - @property - def second(self): - "Returns the seconds." - return self.__getdateinfo__('S') - @property - def minute(self): - "Returns the minutes." - return self.__getdateinfo__('T') - @property - def hour(self): - "Returns the hour." - return self.__getdateinfo__('H') - @property - def week(self): - "Returns the week." - return self.__getdateinfo__('I') - - days = day - weekdays = day_of_week - yeardays = day_of_year - months = month - quarters = quarter - years = year - seconds = second - minutes = minute - hours = hour - weeks = week - - def __getdateinfo__(self, info): - return numeric.asarray(cseries.getDateInfo(numeric.asarray(self), - self.freq, info), - dtype=int_) - __getDateInfo = __getdateinfo__ - #.... Conversion methods .................... - # - def tovalue(self): - "Converts the dates to integer values." - return numeric.asarray(self) - # - def toordinal(self): - "Converts the dates from values to ordinals." - # Note: we better try to cache the result - if self._cachedinfo['toord'] is None: -# diter = (Date(self.freq, value=d).toordinal() for d in self) - diter = (d.toordinal() for d in self) - toord = numeric.fromiter(diter, dtype=float_) - self._cachedinfo['toord'] = toord - return self._cachedinfo['toord'] - # - def tostring(self): - "Converts the dates to strings." - # Note: we better cache the result - if self._cachedinfo['tostr'] is None: - firststr = str(self[0]) - if self.size > 0: - ncharsize = len(firststr) - tostr = numpy.fromiter((str(d) for d in self), - dtype='|S%i' % ncharsize) - else: - tostr = firststr - self._cachedinfo['tostr'] = tostr - return self._cachedinfo['tostr'] - # - def asfreq(self, freq=None, relation="BEFORE"): - "Converts the dates to another frequency." - # Note: As we define a new object, we don't need caching - if freq is None or freq == -9999: - return self - tofreq = corelib.check_freq(freq) - if tofreq == self.freq: - return self - fromfreq = self.freq - _rel = relation.upper()[0] - new = cseries.asfreq(numeric.asarray(self), fromfreq, tofreq, _rel) - return DateArray(new, freq=freq) - #...................................................... - def find_dates(self, *dates): - "Returns the indices corresponding to given dates, as an array." - ifreq = self.freq - c = numpy.zeros(self.shape, bool_) - for d in corelib.flatargs(*dates): - if d.freq != ifreq: - d = d.asfreq(ifreq) - c += (self == d.value) - c = c.nonzero() - if fromnumeric.size(c) == 0: - raise IndexError, "Date out of bounds!" - return c - - def date_to_index(self, date): - "Returns the index corresponding to one given date, as an integer." - if self.isvalid(): - index = date.value - self[0].value - if index < 0 or index > self.size: - raise IndexError, "Date out of bounds!" - return index - else: - index_asarray = (self == date.value).nonzero() - if fromnumeric.size(index_asarray) == 0: - raise IndexError, "Date out of bounds!" - return index_asarray[0][0] - #...................................................... - def get_steps(self): - """Returns the time steps between consecutive dates. - The timesteps have the same unit as the frequency of the series.""" - if self.freq == 'U': - warnings.warn("Undefined frequency: assuming integers!") - if self._cachedinfo['steps'] is None: - _cached = self._cachedinfo - val = numeric.asarray(self).ravel() - if val.size > 1: - steps = val[1:] - val[:-1] - if _cached['full'] is None: - _cached['full'] = (steps.max() == 1) - if _cached['hasdups'] is None: - _cached['hasdups'] = (steps.min() == 0) - else: - _cached['full'] = True - _cached['hasdups'] = False - steps = numeric.array([], dtype=int_) - self._cachedinfo['steps'] = steps - return self._cachedinfo['steps'] - - def has_missing_dates(self): - "Returns whether the DateArray have missing dates." - if self._cachedinfo['full'] is None: - steps = self.get_steps() - return not(self._cachedinfo['full']) - - def isfull(self): - "Returns whether the DateArray has no missing dates." - if self._cachedinfo['full'] is None: - steps = self.get_steps() - return self._cachedinfo['full'] - - def has_duplicated_dates(self): - "Returns whether the DateArray has duplicated dates." - if self._cachedinfo['hasdups'] is None: - steps = self.get_steps() - return self._cachedinfo['hasdups'] - - def isvalid(self): - "Returns whether the DateArray is valid: no missing/duplicated dates." - return (self.isfull() and not self.has_duplicated_dates()) - #...................................................... - -#............................ - - -#####--------------------------------------------------------------------------- -#---- --- DateArray functions --- -#####--------------------------------------------------------------------------- -def isDateArray(a): - "Tests whether an array is a DateArray object." - return isinstance(a,DateArray) - -def guess_freq(dates): - """Tries to estimate the frequency of a list of dates, by checking the steps - between consecutive dates The steps should be in days. - Returns a frequency code (alpha character).""" - ddif = numeric.asarray(numpy.diff(dates)) - ddif.sort() - if ddif[0] == ddif[-1] == 1.: - fcode = 'D' - elif (ddif[0] == 1.) and (ddif[-1] == 3.): - fcode = 'B' - elif (ddif[0] > 3.) and (ddif[-1] == 7.): - fcode = 'W' - elif (ddif[0] >= 28.) and (ddif[-1] <= 31.): - fcode = 'M' - elif (ddif[0] >= 90.) and (ddif[-1] <= 92.): - fcode = 'Q' - elif (ddif[0] >= 365.) and (ddif[-1] <= 366.): - fcode = 'A' - elif numpy.abs(24.*ddif[0] - 1) <= 1e-5 and \ - numpy.abs(24.*ddif[-1] - 1) <= 1e-5: - fcode = 'H' - elif numpy.abs(1440.*ddif[0] - 1) <= 1e-5 and \ - numpy.abs(1440.*ddif[-1] - 1) <= 1e-5: - fcode = 'T' - elif numpy.abs(86400.*ddif[0] - 1) <= 1e-5 and \ - numpy.abs(86400.*ddif[-1] - 1) <= 1e-5: - fcode = 'S' - else: - warnings.warn("Unable to estimate the frequency! %.3f<>%.3f" %\ - (ddif[0], ddif[-1])) - fcode = 'U' - return fcode - - -def _listparser(dlist, freq=None): - "Constructs a DateArray from a list." - dlist = numeric.asarray(dlist) - dlist.sort() - if dlist.ndim == 0: - dlist.shape = (1,) - # Case #1: dates as strings ................. - if dlist.dtype.kind == 'S': - #...construct a list of ordinals - ords = numpy.fromiter((DateTimeFromString(s).toordinal() for s in dlist), - float_) - ords += 1 - #...try to guess the frequency - if freq is None: - freq = guess_freq(ords) - #...construct a list of dates - dates = [Date(freq, string=s) for s in dlist] - # Case #2: dates as numbers ................. - elif dlist.dtype.kind in 'if': - #...hopefully, they are values - if freq is None: - freq = guess_freq(dlist) - dates = dlist - # Case #3: dates as objects ................. - elif dlist.dtype.kind == 'O': - template = dlist[0] - #...as Date objects - if isinstance(template, Date): - dates = numpy.fromiter((d.value for d in dlist), int_) - #...as mx.DateTime objects - elif hasattr(template,'absdays'): - # no freq given: try to guess it from absdays - if freq is None: - ords = numpy.fromiter((s.absdays for s in dlist), float_) - ords += 1 - freq = guess_freq(ords) - dates = [Date(freq, datetime=m) for m in dlist] - #...as datetime objects - elif hasattr(template, 'toordinal'): - ords = numpy.fromiter((d.toordinal() for d in dlist), float_) - if freq is None: - freq = guess_freq(ords) - dates = [Date(freq, datetime=dt.datetime.fromordinal(a)) for a in ords] - # - result = DateArray(dates, freq) - return result - - -def date_array(dlist=None, start_date=None, end_date=None, length=None, - include_last=True, freq=None): - """Constructs a DateArray from: - - a starting date and either an ending date or a given length. - - a list of dates. - """ - freq = corelib.check_freq(freq) - # Case #1: we have a list ................... - if dlist is not None: - # Already a DateArray.................... - if isinstance(dlist, DateArray): - if (freq is not None) and (dlist.freq != corelib.check_freq(freq)): - return dlist.asfreq(freq) - else: - return dlist - # Make sure it's a sequence, else that's a start_date - if hasattr(dlist,'__len__'): - return _listparser(dlist, freq) - elif start_date is not None: - if end_date is not None: - dmsg = "What starting date should be used ? '%s' or '%s' ?" - raise DateError, dmsg % (dlist, start_date) - else: - (start_date, end_date) = (dlist, start_date) - else: - start_date = dlist - # Case #2: we have a starting date .......... - if start_date is None: - if length == 0: - return DateArray([], freq=freq) - raise InsufficientDateError - if not isDate(start_date): - dmsg = "Starting date should be a valid Date instance! " - dmsg += "(got '%s' instead)" % type(start_date) - raise DateError, dmsg - # Check if we have an end_date - if end_date is None: - if length is None: -# raise ValueError,"No length precised!" - length = 1 - else: - if not isDate(end_date): - raise DateError, "Ending date should be a valid Date instance!" - length = int(end_date - start_date) - if include_last: - length += 1 -# dlist = [(start_date+i).value for i in range(length)] - dlist = numeric.arange(length, dtype=int_) - dlist += start_date.value - if freq is None: - freq = start_date.freq - return DateArray(dlist, freq=freq) -datearray = date_array - -def date_array_fromlist(dlist, freq=None): - "Constructs a DateArray from a list of dates." - return date_array(dlist=dlist, freq=freq) - -def date_array_fromrange(start_date, end_date=None, length=None, - include_last=True, freq=None): - """Constructs a DateArray from a starting date and either an ending date or - a length.""" - return date_array(start_date=start_date, end_date=end_date, - length=length, include_last=include_last, freq=freq) - -#####--------------------------------------------------------------------------- -#---- --- Definition of functions from the corresponding methods --- -#####--------------------------------------------------------------------------- -class _frommethod(object): - """Defines functions from existing MaskedArray methods. -:ivar _methodname (String): Name of the method to transform. - """ - def __init__(self, methodname): - self._methodname = methodname - self.__doc__ = self.getdoc() - def getdoc(self): - "Returns the doc of the function (from the doc of the method)." - try: - return getattr(DateArray, self._methodname).__doc__ - except AttributeError: - return "???" - # - def __call__(self, caller, *args, **params): - if hasattr(caller, self._methodname): - method = getattr(caller, self._methodname) - # If method is not callable, it's a property, and don't call it - if hasattr(method, '__call__'): - return method.__call__(*args, **params) - return method - method = getattr(fromnumeric.asarray(caller), self._methodname) - try: - return method(*args, **params) - except SystemError: - return getattr(numpy,self._methodname).__call__(caller, *args, **params) -#............................ -day_of_week = _frommethod('day_of_week') -day_of_year = _frommethod('day_of_year') -year = _frommethod('year') -quarter = _frommethod('quarter') -month = _frommethod('month') -day = _frommethod('day') -hour = _frommethod('hour') -minute = _frommethod('minute') -second = _frommethod('second') - - -def period_break(dates, period): - """Returns the indices where the given period changes. - -:Parameters: - dates : DateArray - Array of dates to monitor. - period : string - Name of the period to monitor. - """ - current = getattr(dates, period) - previous = getattr(dates-1, period) - return (current - previous).nonzero()[0] - - -################################################################################ - -if __name__ == '__main__': - import maskedarray.testutils - from maskedarray.testutils import assert_equal - if 1: - dlist = ['2007-%02i' % i for i in range(1,5)+range(7,13)] - mdates = date_array_fromlist(dlist, 'M') - # Using an integer - assert_equal(mdates[0].value, 24073) - assert_equal(mdates[-1].value, 24084) - # Using a date - lag = mdates.find_dates(mdates[0]) - print mdates[lag] - assert_equal(mdates[lag], mdates[0]) - if 1: - hodie = today('D') - D = DateArray(today('D')) - assert_equal(D.freq, 6000) - - if 1: - freqs = [x[0] for x in corelib.freq_dict.values() if x[0] != 'U'] - print freqs - for f in freqs: - print f - today = thisday(f) - assert(Date(freq=f, value=today.value) == today) - - if 1: - D = date_array(start_date=thisday('D'), length=5) - Dstr = D.tostring() - assert_equal(D.tostring(), Dstr) - DL = D[[0,-1]] - assert_equal(DL.tostring(), Dstr[[0,-1]]) - \ No newline at end of file Copied: trunk/Lib/sandbox/timeseries/tdates.py (from rev 2807, trunk/Lib/sandbox/timeseries/tdates.py) From scipy-svn at scipy.org Fri Mar 2 10:44:24 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Mar 2007 09:44:24 -0600 (CST) Subject: [Scipy-svn] r2813 - trunk/Lib/sandbox/timeseries/addons Message-ID: <20070302154424.803CA39C35E@new.scipy.org> Author: mattknox_ca Date: 2007-03-02 09:44:21 -0600 (Fri, 02 Mar 2007) New Revision: 2813 Modified: trunk/Lib/sandbox/timeseries/addons/filters.py Log: added "centered" and "trailing" option to running_window and running_mean functions Modified: trunk/Lib/sandbox/timeseries/addons/filters.py =================================================================== --- trunk/Lib/sandbox/timeseries/addons/filters.py 2007-03-02 15:03:05 UTC (rev 2812) +++ trunk/Lib/sandbox/timeseries/addons/filters.py 2007-03-02 15:44:21 UTC (rev 2813) @@ -85,23 +85,31 @@ #............................................................................... -def running_window(data, window_type, window_size): - """Applies a running window of type window_type and size window_size on the - data. - - Returns a (subclass of) MaskedArray. The k first and k last data are always - masked (with k=window_size//2). When data has a missing value at position i, - the result has missing values in the interval [i-k:i+k+1]. - - +def running_window(data, window_type, window_size, + centered=False, trailing=False): + """Applies a running window of type window_type and size window_size on the +data. Returns a (subclass of) MaskedArray. + :Parameters: data : ndarray - Data to process. The array should be at most 2D. On 2D arrays, the window + Data to process. The array should be at most 2D. On 2D arrays, the + window is applied recursively on each column. window_type : string/tuple/float Window type (see Notes) window_size : integer The width of the window. + centered : boolean, *[False]* + If both centered and trailing are False, then centered is forced to + True. If centered, the result at position i uses data points from + [i-k:i+k+1] in the calculation. The k first and k last data are always + masked (with k=window_size//2). When data has a missing value at + position i, the result has missing values in the interval [i-k:i+k+1]. + trailing : boolean, *[False]* + If trailing is True, the result at position i uses data points from + [i-window_size:i+1] in the calculation.the first "window_size" data + points are always masked. When data has a missing value at position i, + the result has missing values in the interval [i-window_size:i+1]. Notes ----- @@ -116,14 +124,24 @@ Note also that only boxcar has been thoroughly tested. """ - # + + if not centered and not trailing: + centered = True + elif centered and trailing: + raise ValueError("Cannot specify both centered and trailing") + + data = marray(data, copy=True, subok=True) if data._mask is nomask: data._mask = N.zeros(data.shape, bool_) window = get_window(window_type, window_size, fftbins=False) - (n, k) = (len(data), window_size//2) - # + n = len(data) + + if centered: k = window_size//2 + else: k = 0 + if data.ndim == 1: + data._data.flat = convolve(data._data, window)[k:n+k] / float(window_size) data._mask[:] = ((convolve(getmaskarray(data), window) > 0)[k:n+k]) elif data.ndim == 2: @@ -133,25 +151,39 @@ data._mask[:,i] = (convolve(data._mask[:,i], window) > 0)[k:n+k] else: raise ValueError, "Data should be at most 2D" - data._mask[:k] = data._mask[-k:] = True + + if centered: + data._mask[:k] = data._mask[-k:] = True + else: + data._mask[:window_size] = True return data -def running_mean(data, width): - """Computes the running mean of size width on the data. - - Returns a (subclass of) MaskedArray. The k first and k last data are always - masked (with k=window_size//2). When data has a missing value at position i, - the result has missing values in the interval [i-k:i+k+1]. - +def running_mean(data, width, + centered=False, trailing=False): + """Computes the running mean of size width on the data. Returns a +(subclass of) MaskedArray. + :Parameters: data : ndarray Data to process. The array should be at most 2D. On 2D arrays, the window is applied recursively on each column. window_size : integer - The width of the window. - """ - return running_window(data, 'boxcar', width) + The width of the window. + centered : boolean, *[False]* + If both centered and trailing are False, then centered is forced to + True. If centered, the result at position i uses data points from + [i-k:i+k+1] in the calculation. The k first and k last data are always + masked (with k=window_size//2). When data has a missing value at + position i, the result has missing values in the interval [i-k:i+k+1]. + trailing : boolean, *[False]* + If trailing is True, the result at position i uses data points from + [i-window_size:i+1] in the calculation.the first "window_size" data + points are always masked. When data has a missing value at position i, + the result has missing values in the interval [i-window_size:i+1].""" + return running_window(data, 'boxcar', width, + centered=centered, trailing=trailing) + ################################################################################ if __name__ == '__main__': from maskedarray.testutils import assert_equal, assert_almost_equal From scipy-svn at scipy.org Fri Mar 2 10:53:46 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Mar 2007 09:53:46 -0600 (CST) Subject: [Scipy-svn] r2814 - trunk/Lib/sandbox/timeseries Message-ID: <20070302155346.6193239C368@new.scipy.org> Author: mattknox_ca Date: 2007-03-02 09:53:42 -0600 (Fri, 02 Mar 2007) New Revision: 2814 Modified: trunk/Lib/sandbox/timeseries/__init__.py Log: removed reference to "extras" Modified: trunk/Lib/sandbox/timeseries/__init__.py =================================================================== --- trunk/Lib/sandbox/timeseries/__init__.py 2007-03-02 15:44:21 UTC (rev 2813) +++ trunk/Lib/sandbox/timeseries/__init__.py 2007-03-02 15:53:42 UTC (rev 2814) @@ -23,12 +23,11 @@ from tmulti import * import reportlib from reportlib import * -import extras -from extras import * + __all__ = ['tdates', 'tseries','tmulti','reportlib'] __all__ += tdates.__all__ __all__ += tseries.__all__ __all__ += tmulti.__all__ __all__ += reportlib.__all__ -__all__ += extras.__all__ + From scipy-svn at scipy.org Fri Mar 2 11:39:10 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Mar 2007 10:39:10 -0600 (CST) Subject: [Scipy-svn] r2815 - trunk/Lib/sandbox/timeseries Message-ID: <20070302163910.5B42C39C0B0@new.scipy.org> Author: mattknox_ca Date: 2007-03-02 10:39:07 -0600 (Fri, 02 Mar 2007) New Revision: 2815 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: changed code to use frequency constants internally instead of strings Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-02 15:53:42 UTC (rev 2814) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-02 16:39:07 UTC (rev 2815) @@ -3,12 +3,12 @@ :author: Pierre GF Gerard-Marchant & Matt Knox :contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com -:version: $Id$ +:version: $Id: tdates.py 2805 2007-03-01 21:40:02Z mattknox_ca $ """ -__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author: mattknox_ca $)" __version__ = '1.0' -__revision__ = "$Revision$" -__date__ = '$Date$' +__revision__ = "$Revision: 2805 $" +__date__ = '$Date: 2007-03-01 16:40:02 -0500 (Thu, 01 Mar 2007) $' import datetime as dt @@ -35,6 +35,7 @@ from parser import DateFromString, DateTimeFromString import tcore as corelib +import tcore as _c import cseries @@ -48,7 +49,6 @@ 'period_break' ] - #####--------------------------------------------------------------------------- #---- --- Date Info --- #####--------------------------------------------------------------------------- @@ -147,37 +147,40 @@ value = int(value) if isinstance(value, str): - if self.freqstr in ('H', 'T', 'S'): + if self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): self.datetime = DateTimeFromString(value) else: self.datetime = DateFromString(value) - elif self.freqstr == 'A': - self.datetime = dt.datetime(value, 1, 1) - elif self.freqstr == 'B': + + elif self.freq == _c.FR_SEC: + self.datetime = secondlyOriginDate + dt.timedelta(seconds=value) + elif self.freq == _c.FR_MIN: + self.datetime = minutelyOriginDate + dt.timedelta(minutes=value) + elif self.freq == _c.FR_HR: + self.datetime = hourlyOriginDate + dt.timedelta(hours=value) + elif self.freq in (_c.FR_DAY, _c.FR_UND): + self.datetime = dt.datetime.fromordinal(value) + elif self.freq == _c.FR_BUS: valtmp = (value - 1)//5 self.datetime = dt.datetime.fromordinal(value + valtmp*2) - elif self.freqstr in ['D','U']: - self.datetime = dt.datetime.fromordinal(value) - elif self.freqstr == 'H': - self.datetime = hourlyOriginDate + dt.timedelta(hours=value) - elif self.freqstr == 'M': + elif self.freq == _c.FR_WK: + self.datetime = dt.datetime(1,1,7) + \ + dt.timedelta(days=(value-1)*7) + elif self.freq == _c.FR_MTH: year = (value - 1)//12 + 1 month = value - (year - 1)*12 self.datetime = dt.datetime(year, month, 1) - elif self.freqstr == 'Q': + elif self.freq == _c.FR_QTR: year = (value - 1)//4 + 1 month = (value - (year - 1)*4)*3 self.datetime = dt.datetime(year, month, 1) - elif self.freqstr == 'S': - self.datetime = secondlyOriginDate + dt.timedelta(seconds=value) - elif self.freqstr == 'T': - self.datetime = minutelyOriginDate + dt.timedelta(minutes=value) - elif self.freqstr == 'W': - self.datetime = dt.datetime(1,1,7) + \ - dt.timedelta(days=(value-1)*7) + elif self.freq == _c.FR_ANN: + self.datetime = dt.datetime(value, 1, 1) + else: + raise ValueError("unrecognized frequency: "+str(self.freq)) elif string is not None: - if self.freqstr in ('H', 'T', 'S'): + if self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): self.datetime = DateTimeFromString(string) else: self.datetime = DateFromString(string) @@ -191,31 +194,32 @@ # First, some basic checks..... if year is None: raise InsufficientDateError - if self.freqstr in 'BDWU': + if self.freq in (_c.FR_BUS, _c.FR_DAY, _c.FR_WK, _c.FR_UND): if month is None or day is None: raise InsufficientDateError - elif self.freqstr == 'M': + elif self.freq == _c.FR_MTH: if month is None: raise InsufficientDateError day = 1 - elif self.freqstr == 'Q': + elif self.freq == _c.FR_QTR: if quarter is None: raise InsufficientDateError month = quarter * 3 day = 1 - elif self.freqstr == 'A': + elif self.freq == _c.FR_ANN: month = 1 day = 1 - elif self.freqstr == 'S': + elif self.freq == _c.FR_SEC: if month is None or day is None or second is None: raise InsufficientDateError - if self.freqstr in ['A','B','D','M','Q','W']: + if self.freq in (_c.FR_BUS, _c.FR_DAY, _c.FR_WK, + _c.FR_MTH, _c.FR_QTR, _c.FR_ANN): self.datetime = truncateDate(self.freq, dt.datetime(year, month, day)) - if self.freqstr == 'B': + if self.freq == _c.FR_BUS: if self.datetime.isoweekday() in [6,7]: raise ValueError("Weekend passed as business day") - elif self.freqstr in 'HTS': + elif self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): if hour is None: if minute is None: if second is None: @@ -236,6 +240,9 @@ self.datetime = truncateDate(self.freqstr, dt.datetime(year, month, day, hour, minute, second)) + else: + raise ValueError("unrecognized frequency: "+str(self.freq)) + self.value = self.__value() def __getitem__(self, indx): @@ -333,38 +340,39 @@ def __value(self): "Converts the date to an integer, depending on the current frequency." - # Annual ....... - if self.freqstr == 'A': - val = self.datetime.year - # Quarterly..... - elif self.freqstr == 'Q': - val = (self.datetime.year-1)*4 + self.datetime.month//3 - # Monthly....... - elif self.freqstr == 'M': - val = (self.datetime.year-1)*12 + self.datetime.month - # Weekly........ - elif self.freqstr == 'W': - val = self.datetime.toordinal()//7 + # Secondly...... + if self.freq == _c.FR_SEC: + delta = (self.datetime - secondlyOriginDate) + val = delta.days*86400 + delta.seconds + # Minutely...... + elif self.freq == _c.FR_MIN: + delta = (self.datetime - minutelyOriginDate) + val = delta.days*1440 + delta.seconds/(60) + # Hourly........ + elif self.freq == _c.FR_HR: + delta = (self.datetime - hourlyOriginDate) + val = delta.days*24 + delta.seconds/(3600) + # Daily/undefined + elif self.freq in (_c.FR_DAY, _c.FR_UND): + val = self.datetime.toordinal() # Business days. - elif self.freqstr == 'B': + elif self.freq == _c.FR_BUS: days = self.datetime.toordinal() weeks = days // 7 val = days - weeks*2 - # Daily/undefined - elif self.freqstr in 'DU': - val = self.datetime.toordinal() - # Hourly........ - elif self.freqstr == 'H': - delta = (self.datetime - hourlyOriginDate) - val = delta.days*24 + delta.seconds/(3600) - # Minutely...... - elif self.freqstr == 'T': - delta = (self.datetime - minutelyOriginDate) - val = delta.days*1440 + delta.seconds/(60) - # Secondly...... - elif self.freqstr == 'S': - delta = (self.datetime - secondlyOriginDate) - val = delta.days*86400 + delta.seconds + # Weekly........ + elif self.freq == _c.FR_WK: + val = self.datetime.toordinal()//7 + # Monthly....... + elif self.freq == _c.FR_MTH: + val = (self.datetime.year-1)*12 + self.datetime.month + # Quarterly..... + elif self.freq == _c.FR_QTR: + val = (self.datetime.year-1)*4 + self.datetime.month//3 + # Annual ....... + elif self.freq == _c.FR_ANN: + val = self.datetime.year + return int(val) #...................................................... def strfmt(self, fmt): @@ -417,26 +425,26 @@ def truncateDate(freq, datetime): "Chops off the irrelevant information from the datetime object passed in." - freqstr = corelib.check_freqstr(freq) - if freqstr == 'A': - return dt.datetime(datetime.year, 1, 1) - elif freqstr == 'Q': - return dt.datetime(datetime.year, monthToQuarter(datetime.month)*3, 1) - elif freqstr == 'M': - return dt.datetime(datetime.year, datetime.month, 1) - elif freqstr == 'W': + freq = corelib.check_freq(freq) + if freq == _c.FR_MIN: + return dt.datetime(datetime.year, datetime.month, datetime.day, \ + datetime.hour, datetime.minute) + elif freq == _c.FR_HR: + return dt.datetime(datetime.year, datetime.month, datetime.day, \ + datetime.hour) + elif freq in (_c.FR_BUS, _c.FR_DAY): + if freq == _c.FR_BUS and datetime.isoweekday() in (6,7): + raise ValueError("Weekend passed as business day") + return dt.datetime(datetime.year, datetime.month, datetime.day) + elif freq == _c.FR_WK: d = datetime.toordinal() return dt.datetime.fromordinal(d + (7 - d % 7) % 7) - elif freqstr in 'BD': - if freq == 'B' and datetime.isoweekday() in (6,7): - raise ValueError("Weekend passed as business day") - return dt.datetime(datetime.year, datetime.month, datetime.day) - elif freqstr == 'H': - return dt.datetime(datetime.year, datetime.month, datetime.day, \ - datetime.hour) - elif freqstr == 'T': - return dt.datetime(datetime.year, datetime.month, datetime.day, \ - datetime.hour, datetime.minute) + elif freq == _c.FR_MTH: + return dt.datetime(datetime.year, datetime.month, 1) + elif freq == _c.FR_QTR: + return dt.datetime(datetime.year, monthToQuarter(datetime.month)*3, 1) + elif freq == _c.FR_ANN: + return dt.datetime(datetime.year, 1, 1) else: return datetime @@ -447,18 +455,20 @@ def thisday(freq): "Returns today's date, at the given frequency `freq`." - freqstr = corelib.check_freqstr(freq) + freq = corelib.check_freq(freq) tempDate = dt.datetime.now() # if it is Saturday or Sunday currently, freq==B, then we want to use Friday - if freqstr == 'B' and tempDate.isoweekday() >= 6: + if freq == _c.FR_BUS and tempDate.isoweekday() >= 6: tempDate = tempDate - dt.timedelta(days=(tempDate.isoweekday() - 5)) - if freqstr in ('B','D','H','S','T','W','U'): + if freq in (_c.FR_BUS,_c.FR_DAY, + _c.FR_HR,_c.FR_SEC,_c.FR_MIN, + _c.FR_WK,_c.FR_UND): return Date(freq, datetime=tempDate) - elif freqstr == 'M': + elif freq == _c.FR_MTH: return Date(freq, year=tempDate.year, month=tempDate.month) - elif freqstr == 'Q': + elif freq == _c.FR_QTR: return Date(freq, year=tempDate.year, quarter=monthToQuarter(tempDate.month)) - elif freqstr == 'A': + elif freq == _c.FR_ANN: return Date(freq, year=tempDate.year) today = thisday @@ -468,9 +478,9 @@ dateNum = tempDate.hour + float(tempDate.minute)/60 checkNum = day_end_hour + float(day_end_min)/60 if dateNum < checkNum: - return thisday('B') - 1 + return thisday(_c.FR_BUS) - 1 else: - return thisday('B') + return thisday(_c.FR_BUS) def asfreq(date, toFreq, relation="BEFORE"): """Returns a date converted to another frequency `toFreq`, according to the @@ -484,9 +494,9 @@ if not isinstance(date, Date): raise DateError, "Date should be a valid Date instance!" - if date.freqstr == 'U': + if date.freq == _c.FR_UND: warnings.warn("Undefined frequency: assuming daily!") - fromfreq = corelib.freq_revdict['D'] + fromfreq = _c.FR_DAY else: fromfreq = date.freq @@ -832,30 +842,30 @@ ddif = numeric.asarray(numpy.diff(dates)) ddif.sort() if ddif[0] == ddif[-1] == 1.: - fcode = 'D' + fcode = _c.FR_DAY elif (ddif[0] == 1.) and (ddif[-1] == 3.): - fcode = 'B' + fcode = _c.FR_BUS elif (ddif[0] > 3.) and (ddif[-1] == 7.): - fcode = 'W' + fcode = _c.FR_WK elif (ddif[0] >= 28.) and (ddif[-1] <= 31.): - fcode = 'M' + fcode = _c.FR_MTH elif (ddif[0] >= 90.) and (ddif[-1] <= 92.): - fcode = 'Q' + fcode = _c.FR_QTR elif (ddif[0] >= 365.) and (ddif[-1] <= 366.): - fcode = 'A' + fcode = _c.FR_ANN elif numpy.abs(24.*ddif[0] - 1) <= 1e-5 and \ numpy.abs(24.*ddif[-1] - 1) <= 1e-5: - fcode = 'H' + fcode = _c.FR_HR elif numpy.abs(1440.*ddif[0] - 1) <= 1e-5 and \ numpy.abs(1440.*ddif[-1] - 1) <= 1e-5: - fcode = 'T' + fcode = _c.FR_MIN elif numpy.abs(86400.*ddif[0] - 1) <= 1e-5 and \ numpy.abs(86400.*ddif[-1] - 1) <= 1e-5: - fcode = 'S' + fcode = _c.FR_SEC else: warnings.warn("Unable to estimate the frequency! %.3f<>%.3f" %\ (ddif[0], ddif[-1])) - fcode = 'U' + fcode = _c.FR_UND return fcode From scipy-svn at scipy.org Fri Mar 2 11:40:10 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Mar 2007 10:40:10 -0600 (CST) Subject: [Scipy-svn] r2816 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070302164010.15F4839C356@new.scipy.org> Author: mattknox_ca Date: 2007-03-02 10:40:06 -0600 (Fri, 02 Mar 2007) New Revision: 2816 Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py Log: changed import statements to be consistent with recommended usage Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-03-02 16:39:07 UTC (rev 2815) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-03-02 16:40:06 UTC (rev 2816) @@ -25,9 +25,8 @@ import maskedarray.testutils from maskedarray.testutils import assert_equal, assert_array_equal -from timeseries import tseries -from timeseries.tseries import Date, date_array_fromlist, date_array, thisday -from timeseries.tseries import time_series, TimeSeries, adjust_endpoints, \ +from timeseries import Date, date_array_fromlist, date_array, thisday +from timeseries import time_series, TimeSeries, adjust_endpoints, \ mask_period, align_series, fill_missing_dates, tsmasked, concatenate_series class test_creation(NumpyTestCase): From scipy-svn at scipy.org Fri Mar 2 13:27:34 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Mar 2007 12:27:34 -0600 (CST) Subject: [Scipy-svn] r2817 - trunk/Lib/sandbox/timeseries Message-ID: <20070302182734.A907239C041@new.scipy.org> Author: pierregm Date: 2007-03-02 12:27:31 -0600 (Fri, 02 Mar 2007) New Revision: 2817 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: tseries : fixed mask_period for inplace modifications and handling of subclasses Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-03-02 16:40:06 UTC (rev 2816) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-03-02 18:27:31 UTC (rev 2817) @@ -926,20 +926,21 @@ as well as where data are initially missing (masked). :Parameters: - `data` : Timeseries + data : Timeseries Data to process - `start_date` : Date *[None]* - Starting date. If None, uses the first date. - `end_date` : Date *[None]* - Ending date. If None, uses the last date. - `inside` : Boolean *[True]* + start_date : string/Date *[None]* + Starting date. If None, uses the first date of the series. + end_date : string/Date *[None]* + Ending date. If None, uses the last date of the series. + inside : Boolean *[True]* Whether the dates inside the range should be masked. If not, masks outside. - `include_edges` : Boolean *[True]* + include_edges : Boolean *[True]* Whether the starting and ending dates should be masked. - `inplace` : Boolean *[True]* + inplace : Boolean *[True]* Whether the data mask should be modified in place. If not, returns a new TimeSeries. -""" + """ + data = masked_array(data, subok=True, copy=not inplace) if not isTimeSeries(data): raise ValueError,"Data should be a valid TimeSeries!" # Check the starting date .............. @@ -970,13 +971,10 @@ else: selection = (data.dates < start_date) | (data.dates > end_date) # Process the data: - if inplace: - if data._mask is nomask: - data._mask = selection - else: - data._mask += selection + if data._mask is nomask: + data._mask = selection else: - return TimeSeries(data, mask=selection, keep_mask=True) + data._mask += selection return data def mask_inside_period(data, start_date=None, end_date=None, @@ -1388,34 +1386,20 @@ assert_equal(sertrans.shape, (2,5)) if 1: - hodie = today('D') - ser2d = time_series(N.arange(10).reshape(5,2), start_date=hodie, - mask=[[1,1],[0,0],[0,0],[0,0],[0,0]]) - try: - ser2d_transpose = ser2d.transpose() - except TimeSeriesError: - pass - if 1: - hodie = today('D') - ser3d = time_series(N.arange(30).reshape(5,3,2), start_date=hodie,) - try: - ser3d_transpose = ser3d.transpose() - except TimeSeriesError: - pass - assert_equal(ser3d.transpose(0,2,1).shape, (5,2,3)) - - if 1: - dlist = ['2007-01-%02i' % i for i in range(1,11)] - dates = date_array_fromlist(dlist) - data = masked_array(numeric.arange(10), mask=[1,0,0,0,0]*2, dtype=float_) + dlist = ['2007-01-%02i' % i for i in range(1,16)] + data = masked_array(numeric.arange(15), mask=[1,0,0,0,0]*3, dtype=float_) series = time_series(data, dlist) -# tostr = series._dates.tostring() - # - import cPickle - series_pickled = cPickle.loads(series.dumps()) - assert_equal(series_pickled._dates, series._dates) - assert_equal(series_pickled._data, series._data) - assert_equal(series_pickled._mask, series._mask) - # - - \ No newline at end of file + series.mask = nomask + (start, end) = ('2007-01-06', '2007-01-12') + mask = mask_period(series, start, end, inside=True, include_edges=True, + inplace=False) + assert_equal(mask._mask, N.array([0,0,0,0,0,1,1,1,1,1,1,1,0,0,0])) + mask = mask_period(series, start, end, inside=True, include_edges=False, + inplace=False) + assert_equal(mask._mask, [0,0,0,0,0,0,1,1,1,1,1,0,0,0,0]) + mask = mask_period(series, start, end, inside=False, include_edges=True, + inplace=False) + assert_equal(mask._mask, [1,1,1,1,1,1,0,0,0,0,0,1,1,1,1]) + mask = mask_period(series, start, end, inside=False, include_edges=False, + inplace=False) + assert_equal(mask._mask, [1,1,1,1,1,0,0,0,0,0,0,0,1,1,1]) \ No newline at end of file From scipy-svn at scipy.org Fri Mar 2 13:54:59 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 2 Mar 2007 12:54:59 -0600 (CST) Subject: [Scipy-svn] r2818 - trunk/Lib/sandbox/timeseries/addons Message-ID: <20070302185459.7E4C739C041@new.scipy.org> Author: mattknox_ca Date: 2007-03-02 12:54:55 -0600 (Fri, 02 Mar 2007) New Revision: 2818 Modified: trunk/Lib/sandbox/timeseries/addons/filters.py Log: added centered and trailing option to expmave Modified: trunk/Lib/sandbox/timeseries/addons/filters.py =================================================================== --- trunk/Lib/sandbox/timeseries/addons/filters.py 2007-03-02 18:27:31 UTC (rev 2817) +++ trunk/Lib/sandbox/timeseries/addons/filters.py 2007-03-02 18:54:55 UTC (rev 2818) @@ -29,21 +29,8 @@ #####--------------------------------------------------------------------------- #---- --- Moving average functions --- #####--------------------------------------------------------------------------- -def expmave(data, n, tol=1e-6): - """Calculates the exponential moving average of a series. - -:Parameters: - data : ndarray - Data as a valid (subclass of) ndarray or MaskedArray. In particular, - TimeSeries objects are valid here. - n : int - Time periods. The smoothing factor is 2/(n + 1) - tol : float, *[1e-6]* - Tolerance for the definition of the mask. When data contains masked - values, this parameter determinea what points in the result should be masked. - Values in the result that would not be "significantly" impacted (as - determined by this parameter) by the masked values are left unmasked. -""" +def __expmave(data, n, tol): + """helper function for expmave""" data = marray(data, copy=True, subok=True) ismasked = (data._mask is not nomask) data._mask = N.zeros(data.shape, bool_) @@ -61,7 +48,44 @@ data._mask[0] = True # return data + +def expmave(data, n, tol=1e-6, + centered=False, trailing=False): + """Calculates the exponential moving average of a series. +:Parameters: + data : ndarray + Data as a valid (subclass of) ndarray or MaskedArray. In particular, + TimeSeries objects are valid here. + n : int + Time periods. The smoothing factor is 2/(n + 1). + tol : float, *[1e-6]* + Tolerance for the definition of the mask. When data contains masked + values, this parameter determinea what points in the result should be masked. + Values in the result that would not be "significantly" impacted (as + determined by this parameter) by the masked values are left unmasked. + centered : boolean, *[False]* + If both centered and trailing are False, then centered is forced to + True. If centered, the result at position i is the average of the + trailing result with n=n//2, and an equivalent calculation operating in + the reverse direction on the series. + trailing : boolean, *[False]* + If trailing is True, the result at position i uses only data points at, + or before, position i. +""" + if not centered and not trailing: + centered = True + elif centered and trailing: + raise ValueError("Cannot specify both centered and trailing") + + if trailing: + return __expmave(data, n, tol=tol) + else: + rev_result = __expmave(data[::-1], n//2, tol=tol)[::-1] + fwd_result = __expmave(data, n//2, tol=tol) + return (rev_result + fwd_result)/N.array(2, dtype=data.dtype) + + def weightmave(data, n): data = marray(data, subok=True, copy=True) data._mask = N.zeros(data.shape, bool_) From scipy-svn at scipy.org Sat Mar 3 18:00:26 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 3 Mar 2007 17:00:26 -0600 (CST) Subject: [Scipy-svn] r2819 - in trunk/Lib/sandbox/timeseries: . addons addons/tests tests Message-ID: <20070303230026.5E55039C011@new.scipy.org> Author: pierregm Date: 2007-03-03 17:00:20 -0600 (Sat, 03 Mar 2007) New Revision: 2819 Modified: trunk/Lib/sandbox/timeseries/__init__.py trunk/Lib/sandbox/timeseries/addons/filters.py trunk/Lib/sandbox/timeseries/addons/tests/test_filters.py trunk/Lib/sandbox/timeseries/addons/tests/test_interpolate.py trunk/Lib/sandbox/timeseries/tdates.py trunk/Lib/sandbox/timeseries/tests/test_dates.py trunk/Lib/sandbox/timeseries/tests/test_timeseries.py trunk/Lib/sandbox/timeseries/tseries.py Log: tdates : separated the case 'D'/'U' in Date : improved the handling of 'U' freq tseries : mask_period : fixed mask_period for multivariables got rid of extra condition on end_date, start_date set the default to inplace=False : TimeSeries : fixed a bug when length was not None : fixed end/start_date for multivariables. filters : revert to initial implementation Modified: trunk/Lib/sandbox/timeseries/__init__.py =================================================================== --- trunk/Lib/sandbox/timeseries/__init__.py 2007-03-02 18:54:55 UTC (rev 2818) +++ trunk/Lib/sandbox/timeseries/__init__.py 2007-03-03 23:00:20 UTC (rev 2819) @@ -23,6 +23,8 @@ from tmulti import * import reportlib from reportlib import * +import plotlib +import addons __all__ = ['tdates', 'tseries','tmulti','reportlib'] Modified: trunk/Lib/sandbox/timeseries/addons/filters.py =================================================================== --- trunk/Lib/sandbox/timeseries/addons/filters.py 2007-03-02 18:54:55 UTC (rev 2818) +++ trunk/Lib/sandbox/timeseries/addons/filters.py 2007-03-03 23:00:20 UTC (rev 2819) @@ -29,8 +29,21 @@ #####--------------------------------------------------------------------------- #---- --- Moving average functions --- #####--------------------------------------------------------------------------- -def __expmave(data, n, tol): - """helper function for expmave""" +def expmave(data, n, tol=1e-6): + """Calculates the exponential moving average of a series. + +:Parameters: + data : ndarray + Data as a valid (subclass of) ndarray or MaskedArray. In particular, + TimeSeries objects are valid here. + n : int + Time periods. The smoothing factor is 2/(n + 1) + tol : float, *[1e-6]* + Tolerance for the definition of the mask. When data contains masked + values, this parameter determinea what points in the result should be masked. + Values in the result that would not be "significantly" impacted (as + determined by this parameter) by the masked values are left unmasked. +""" data = marray(data, copy=True, subok=True) ismasked = (data._mask is not nomask) data._mask = N.zeros(data.shape, bool_) @@ -48,44 +61,7 @@ data._mask[0] = True # return data - -def expmave(data, n, tol=1e-6, - centered=False, trailing=False): - """Calculates the exponential moving average of a series. -:Parameters: - data : ndarray - Data as a valid (subclass of) ndarray or MaskedArray. In particular, - TimeSeries objects are valid here. - n : int - Time periods. The smoothing factor is 2/(n + 1). - tol : float, *[1e-6]* - Tolerance for the definition of the mask. When data contains masked - values, this parameter determinea what points in the result should be masked. - Values in the result that would not be "significantly" impacted (as - determined by this parameter) by the masked values are left unmasked. - centered : boolean, *[False]* - If both centered and trailing are False, then centered is forced to - True. If centered, the result at position i is the average of the - trailing result with n=n//2, and an equivalent calculation operating in - the reverse direction on the series. - trailing : boolean, *[False]* - If trailing is True, the result at position i uses only data points at, - or before, position i. -""" - if not centered and not trailing: - centered = True - elif centered and trailing: - raise ValueError("Cannot specify both centered and trailing") - - if trailing: - return __expmave(data, n, tol=tol) - else: - rev_result = __expmave(data[::-1], n//2, tol=tol)[::-1] - fwd_result = __expmave(data, n//2, tol=tol) - return (rev_result + fwd_result)/N.array(2, dtype=data.dtype) - - def weightmave(data, n): data = marray(data, subok=True, copy=True) data._mask = N.zeros(data.shape, bool_) @@ -109,31 +85,23 @@ #............................................................................... -def running_window(data, window_type, window_size, - centered=False, trailing=False): - """Applies a running window of type window_type and size window_size on the -data. Returns a (subclass of) MaskedArray. - +def running_window(data, window_type, window_size): + """Applies a running window of type window_type and size window_size on the + data. + + Returns a (subclass of) MaskedArray. The k first and k last data are always + masked (with k=window_size//2). When data has a missing value at position i, + the result has missing values in the interval [i-k:i+k+1]. + + :Parameters: data : ndarray - Data to process. The array should be at most 2D. On 2D arrays, the - window + Data to process. The array should be at most 2D. On 2D arrays, the window is applied recursively on each column. window_type : string/tuple/float Window type (see Notes) window_size : integer The width of the window. - centered : boolean, *[False]* - If both centered and trailing are False, then centered is forced to - True. If centered, the result at position i uses data points from - [i-k:i+k+1] in the calculation. The k first and k last data are always - masked (with k=window_size//2). When data has a missing value at - position i, the result has missing values in the interval [i-k:i+k+1]. - trailing : boolean, *[False]* - If trailing is True, the result at position i uses data points from - [i-window_size:i+1] in the calculation.the first "window_size" data - points are always masked. When data has a missing value at position i, - the result has missing values in the interval [i-window_size:i+1]. Notes ----- @@ -148,24 +116,14 @@ Note also that only boxcar has been thoroughly tested. """ - - if not centered and not trailing: - centered = True - elif centered and trailing: - raise ValueError("Cannot specify both centered and trailing") - - + # data = marray(data, copy=True, subok=True) if data._mask is nomask: data._mask = N.zeros(data.shape, bool_) window = get_window(window_type, window_size, fftbins=False) - n = len(data) - - if centered: k = window_size//2 - else: k = 0 - + (n, k) = (len(data), window_size//2) + # if data.ndim == 1: - data._data.flat = convolve(data._data, window)[k:n+k] / float(window_size) data._mask[:] = ((convolve(getmaskarray(data), window) > 0)[k:n+k]) elif data.ndim == 2: @@ -175,39 +133,25 @@ data._mask[:,i] = (convolve(data._mask[:,i], window) > 0)[k:n+k] else: raise ValueError, "Data should be at most 2D" - - if centered: - data._mask[:k] = data._mask[-k:] = True - else: - data._mask[:window_size] = True + data._mask[:k] = data._mask[-k:] = True return data -def running_mean(data, width, - centered=False, trailing=False): - """Computes the running mean of size width on the data. Returns a -(subclass of) MaskedArray. - +def running_mean(data, width): + """Computes the running mean of size width on the data. + + Returns a (subclass of) MaskedArray. The k first and k last data are always + masked (with k=window_size//2). When data has a missing value at position i, + the result has missing values in the interval [i-k:i+k+1]. + :Parameters: data : ndarray Data to process. The array should be at most 2D. On 2D arrays, the window is applied recursively on each column. window_size : integer - The width of the window. - centered : boolean, *[False]* - If both centered and trailing are False, then centered is forced to - True. If centered, the result at position i uses data points from - [i-k:i+k+1] in the calculation. The k first and k last data are always - masked (with k=window_size//2). When data has a missing value at - position i, the result has missing values in the interval [i-k:i+k+1]. - trailing : boolean, *[False]* - If trailing is True, the result at position i uses data points from - [i-window_size:i+1] in the calculation.the first "window_size" data - points are always masked. When data has a missing value at position i, - the result has missing values in the interval [i-window_size:i+1].""" + The width of the window. + """ + return running_window(data, 'boxcar', width) - return running_window(data, 'boxcar', width, - centered=centered, trailing=trailing) - ################################################################################ if __name__ == '__main__': from maskedarray.testutils import assert_equal, assert_almost_equal Modified: trunk/Lib/sandbox/timeseries/addons/tests/test_filters.py =================================================================== --- trunk/Lib/sandbox/timeseries/addons/tests/test_filters.py 2007-03-02 18:54:55 UTC (rev 2818) +++ trunk/Lib/sandbox/timeseries/addons/tests/test_filters.py 2007-03-03 23:00:20 UTC (rev 2819) @@ -16,18 +16,15 @@ from numpy.testing import NumpyTest, NumpyTestCase import maskedarray.testutils -#reload(maskedarray.testutils) from maskedarray.testutils import * import maskedarray.core as coremodule -#reload(coremodule) from maskedarray.core import MaskedArray, masked import tseries from tseries import time_series, thisday import addons.filters -reload(addons.filters) from addons.filters import running_mean Modified: trunk/Lib/sandbox/timeseries/addons/tests/test_interpolate.py =================================================================== --- trunk/Lib/sandbox/timeseries/addons/tests/test_interpolate.py 2007-03-02 18:54:55 UTC (rev 2818) +++ trunk/Lib/sandbox/timeseries/addons/tests/test_interpolate.py 2007-03-03 23:00:20 UTC (rev 2819) @@ -14,11 +14,9 @@ from numpy.testing import NumpyTest, NumpyTestCase import maskedarray.testutils -#reload(maskedarray.testutils) from maskedarray.testutils import * import maskedarray.core as coremodule -#reload(coremodule) from maskedarray.core import MaskedArray, masked from addons.interpolate import backward_fill, forward_fill, interp_masked1d Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-02 18:54:55 UTC (rev 2818) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-03 23:00:20 UTC (rev 2819) @@ -3,12 +3,12 @@ :author: Pierre GF Gerard-Marchant & Matt Knox :contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com -:version: $Id: tdates.py 2805 2007-03-01 21:40:02Z mattknox_ca $ +:version: $Id$ """ -__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author: mattknox_ca $)" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" __version__ = '1.0' -__revision__ = "$Revision: 2805 $" -__date__ = '$Date: 2007-03-01 16:40:02 -0500 (Thu, 01 Mar 2007) $' +__revision__ = "$Revision$" +__date__ = '$Date$' import datetime as dt @@ -35,7 +35,6 @@ from parser import DateFromString, DateTimeFromString import tcore as corelib -import tcore as _c import cseries @@ -49,6 +48,7 @@ 'period_break' ] + #####--------------------------------------------------------------------------- #---- --- Date Info --- #####--------------------------------------------------------------------------- @@ -147,40 +147,40 @@ value = int(value) if isinstance(value, str): - if self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): + if self.freqstr in ('H', 'T', 'S'): self.datetime = DateTimeFromString(value) else: self.datetime = DateFromString(value) - - elif self.freq == _c.FR_SEC: - self.datetime = secondlyOriginDate + dt.timedelta(seconds=value) - elif self.freq == _c.FR_MIN: - self.datetime = minutelyOriginDate + dt.timedelta(minutes=value) - elif self.freq == _c.FR_HR: - self.datetime = hourlyOriginDate + dt.timedelta(hours=value) - elif self.freq in (_c.FR_DAY, _c.FR_UND): - self.datetime = dt.datetime.fromordinal(value) - elif self.freq == _c.FR_BUS: + elif self.freqstr == 'A': + self.datetime = dt.datetime(value, 1, 1) + elif self.freqstr == 'B': valtmp = (value - 1)//5 self.datetime = dt.datetime.fromordinal(value + valtmp*2) - elif self.freq == _c.FR_WK: - self.datetime = dt.datetime(1,1,7) + \ - dt.timedelta(days=(value-1)*7) - elif self.freq == _c.FR_MTH: +# elif self.freqstr in 'DU': + elif self.freqstr == 'D': + self.datetime = dt.datetime.fromordinal(value) + elif self.freqstr == 'U': + self.datetime = int(value) + elif self.freqstr == 'H': + self.datetime = hourlyOriginDate + dt.timedelta(hours=value) + elif self.freqstr == 'M': year = (value - 1)//12 + 1 month = value - (year - 1)*12 self.datetime = dt.datetime(year, month, 1) - elif self.freq == _c.FR_QTR: + elif self.freqstr == 'Q': year = (value - 1)//4 + 1 month = (value - (year - 1)*4)*3 self.datetime = dt.datetime(year, month, 1) - elif self.freq == _c.FR_ANN: - self.datetime = dt.datetime(value, 1, 1) - else: - raise ValueError("unrecognized frequency: "+str(self.freq)) + elif self.freqstr == 'S': + self.datetime = secondlyOriginDate + dt.timedelta(seconds=value) + elif self.freqstr == 'T': + self.datetime = minutelyOriginDate + dt.timedelta(minutes=value) + elif self.freqstr == 'W': + self.datetime = dt.datetime(1,1,7) + \ + dt.timedelta(days=(value-1)*7) elif string is not None: - if self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): + if self.freqstr in ('H', 'T', 'S'): self.datetime = DateTimeFromString(string) else: self.datetime = DateFromString(string) @@ -194,32 +194,31 @@ # First, some basic checks..... if year is None: raise InsufficientDateError - if self.freq in (_c.FR_BUS, _c.FR_DAY, _c.FR_WK, _c.FR_UND): + if self.freqstr in 'BDWU': if month is None or day is None: raise InsufficientDateError - elif self.freq == _c.FR_MTH: + elif self.freqstr == 'M': if month is None: raise InsufficientDateError day = 1 - elif self.freq == _c.FR_QTR: + elif self.freqstr == 'Q': if quarter is None: raise InsufficientDateError month = quarter * 3 day = 1 - elif self.freq == _c.FR_ANN: + elif self.freqstr == 'A': month = 1 day = 1 - elif self.freq == _c.FR_SEC: + elif self.freqstr == 'S': if month is None or day is None or second is None: raise InsufficientDateError - if self.freq in (_c.FR_BUS, _c.FR_DAY, _c.FR_WK, - _c.FR_MTH, _c.FR_QTR, _c.FR_ANN): + if self.freqstr in ['A','B','D','M','Q','W']: self.datetime = truncateDate(self.freq, dt.datetime(year, month, day)) - if self.freq == _c.FR_BUS: + if self.freqstr == 'B': if self.datetime.isoweekday() in [6,7]: raise ValueError("Weekend passed as business day") - elif self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): + elif self.freqstr in 'HTS': if hour is None: if minute is None: if second is None: @@ -240,9 +239,6 @@ self.datetime = truncateDate(self.freqstr, dt.datetime(year, month, day, hour, minute, second)) - else: - raise ValueError("unrecognized frequency: "+str(self.freq)) - self.value = self.__value() def __getitem__(self, indx): @@ -340,45 +336,53 @@ def __value(self): "Converts the date to an integer, depending on the current frequency." - # Secondly...... - if self.freq == _c.FR_SEC: - delta = (self.datetime - secondlyOriginDate) - val = delta.days*86400 + delta.seconds - # Minutely...... - elif self.freq == _c.FR_MIN: - delta = (self.datetime - minutelyOriginDate) - val = delta.days*1440 + delta.seconds/(60) - # Hourly........ - elif self.freq == _c.FR_HR: - delta = (self.datetime - hourlyOriginDate) - val = delta.days*24 + delta.seconds/(3600) - # Daily/undefined - elif self.freq in (_c.FR_DAY, _c.FR_UND): - val = self.datetime.toordinal() + # Annual ....... + if self.freqstr == 'A': + val = self.datetime.year + # Quarterly..... + elif self.freqstr == 'Q': + val = (self.datetime.year-1)*4 + self.datetime.month//3 + # Monthly....... + elif self.freqstr == 'M': + val = (self.datetime.year-1)*12 + self.datetime.month + # Weekly........ + elif self.freqstr == 'W': + val = self.datetime.toordinal()//7 # Business days. - elif self.freq == _c.FR_BUS: + elif self.freqstr == 'B': days = self.datetime.toordinal() weeks = days // 7 val = days - weeks*2 - # Weekly........ - elif self.freq == _c.FR_WK: - val = self.datetime.toordinal()//7 - # Monthly....... - elif self.freq == _c.FR_MTH: - val = (self.datetime.year-1)*12 + self.datetime.month - # Quarterly..... - elif self.freq == _c.FR_QTR: - val = (self.datetime.year-1)*4 + self.datetime.month//3 - # Annual ....... - elif self.freq == _c.FR_ANN: - val = self.datetime.year - + # Daily......... +# elif self.freqstr in 'DU': + elif self.freqstr == 'D': + val = self.datetime.toordinal() + # Undefined..... + elif self.freqstr == 'U': + if not hasattr(self.datetime, 'toordinal'): + val = self.datetime + else: + val = self.datetime.toordinal() + # Hourly........ + elif self.freqstr == 'H': + delta = (self.datetime - hourlyOriginDate) + val = delta.days*24 + delta.seconds/(3600) + # Minutely...... + elif self.freqstr == 'T': + delta = (self.datetime - minutelyOriginDate) + val = delta.days*1440 + delta.seconds/(60) + # Secondly...... + elif self.freqstr == 'S': + delta = (self.datetime - secondlyOriginDate) + val = delta.days*86400 + delta.seconds return int(val) #...................................................... def strfmt(self, fmt): "Formats the date" if fmt is None: fmt = self.default_fmtstr[self.freqstr] + if self.freqstr == 'U': + return str(self.value) return cseries.strfmt(self.datetime, fmt) def __str__(self): @@ -389,6 +393,9 @@ #...................................................... def toordinal(self): "Returns the date as an ordinal." + # FIXME: We shouldn't need the test if we were in C + if self.freqstr == 'U': + return self.value return self.datetime.toordinal() def fromordinal(self, ordinal): @@ -425,26 +432,26 @@ def truncateDate(freq, datetime): "Chops off the irrelevant information from the datetime object passed in." - freq = corelib.check_freq(freq) - if freq == _c.FR_MIN: + freqstr = corelib.check_freqstr(freq) + if freqstr == 'A': + return dt.datetime(datetime.year, 1, 1) + elif freqstr == 'Q': + return dt.datetime(datetime.year, monthToQuarter(datetime.month)*3, 1) + elif freqstr == 'M': + return dt.datetime(datetime.year, datetime.month, 1) + elif freqstr == 'W': + d = datetime.toordinal() + return dt.datetime.fromordinal(d + (7 - d % 7) % 7) + elif freqstr in 'BD': + if freq == 'B' and datetime.isoweekday() in (6,7): + raise ValueError("Weekend passed as business day") + return dt.datetime(datetime.year, datetime.month, datetime.day) + elif freqstr == 'H': return dt.datetime(datetime.year, datetime.month, datetime.day, \ + datetime.hour) + elif freqstr == 'T': + return dt.datetime(datetime.year, datetime.month, datetime.day, \ datetime.hour, datetime.minute) - elif freq == _c.FR_HR: - return dt.datetime(datetime.year, datetime.month, datetime.day, \ - datetime.hour) - elif freq in (_c.FR_BUS, _c.FR_DAY): - if freq == _c.FR_BUS and datetime.isoweekday() in (6,7): - raise ValueError("Weekend passed as business day") - return dt.datetime(datetime.year, datetime.month, datetime.day) - elif freq == _c.FR_WK: - d = datetime.toordinal() - return dt.datetime.fromordinal(d + (7 - d % 7) % 7) - elif freq == _c.FR_MTH: - return dt.datetime(datetime.year, datetime.month, 1) - elif freq == _c.FR_QTR: - return dt.datetime(datetime.year, monthToQuarter(datetime.month)*3, 1) - elif freq == _c.FR_ANN: - return dt.datetime(datetime.year, 1, 1) else: return datetime @@ -455,20 +462,18 @@ def thisday(freq): "Returns today's date, at the given frequency `freq`." - freq = corelib.check_freq(freq) + freqstr = corelib.check_freqstr(freq) tempDate = dt.datetime.now() # if it is Saturday or Sunday currently, freq==B, then we want to use Friday - if freq == _c.FR_BUS and tempDate.isoweekday() >= 6: + if freqstr == 'B' and tempDate.isoweekday() >= 6: tempDate = tempDate - dt.timedelta(days=(tempDate.isoweekday() - 5)) - if freq in (_c.FR_BUS,_c.FR_DAY, - _c.FR_HR,_c.FR_SEC,_c.FR_MIN, - _c.FR_WK,_c.FR_UND): + if freqstr in ('B','D','H','S','T','W','U'): return Date(freq, datetime=tempDate) - elif freq == _c.FR_MTH: + elif freqstr == 'M': return Date(freq, year=tempDate.year, month=tempDate.month) - elif freq == _c.FR_QTR: + elif freqstr == 'Q': return Date(freq, year=tempDate.year, quarter=monthToQuarter(tempDate.month)) - elif freq == _c.FR_ANN: + elif freqstr == 'A': return Date(freq, year=tempDate.year) today = thisday @@ -478,9 +483,9 @@ dateNum = tempDate.hour + float(tempDate.minute)/60 checkNum = day_end_hour + float(day_end_min)/60 if dateNum < checkNum: - return thisday(_c.FR_BUS) - 1 + return thisday('B') - 1 else: - return thisday(_c.FR_BUS) + return thisday('B') def asfreq(date, toFreq, relation="BEFORE"): """Returns a date converted to another frequency `toFreq`, according to the @@ -494,9 +499,9 @@ if not isinstance(date, Date): raise DateError, "Date should be a valid Date instance!" - if date.freq == _c.FR_UND: + if date.freqstr == 'U': warnings.warn("Undefined frequency: assuming daily!") - fromfreq = _c.FR_DAY + fromfreq = corelib.freq_revdict['D'] else: fromfreq = date.freq @@ -638,7 +643,8 @@ return r def __repr__(self): - return ndarray.__repr__(self) + return ndarray.__repr__(self)[:-1] + \ + ",\n freq='%s')" % self.freqstr #...................................................... __add__ = _datearithmetics('__add__', asdates=True) __radd__ = _datearithmetics('__add__', asdates=True) @@ -723,7 +729,10 @@ # Note: we better try to cache the result if self._cachedinfo['toord'] is None: # diter = (Date(self.freq, value=d).toordinal() for d in self) - diter = (d.toordinal() for d in self) + if self.freq == -9999: + diter = (d.value for d in self) + else: + diter = (d.toordinal() for d in self) toord = numeric.fromiter(diter, dtype=float_) self._cachedinfo['toord'] = toord return self._cachedinfo['toord'] @@ -749,9 +758,11 @@ return self tofreq = corelib.check_freq(freq) if tofreq == self.freq: - return self + return self + _rel = relation.upper()[0] fromfreq = self.freq - _rel = relation.upper()[0] + if fromfreq == -9999: + fromfreq = 6000 new = cseries.asfreq(numeric.asarray(self), fromfreq, tofreq, _rel) return DateArray(new, freq=freq) #...................................................... @@ -842,30 +853,30 @@ ddif = numeric.asarray(numpy.diff(dates)) ddif.sort() if ddif[0] == ddif[-1] == 1.: - fcode = _c.FR_DAY + fcode = 'D' elif (ddif[0] == 1.) and (ddif[-1] == 3.): - fcode = _c.FR_BUS + fcode = 'B' elif (ddif[0] > 3.) and (ddif[-1] == 7.): - fcode = _c.FR_WK + fcode = 'W' elif (ddif[0] >= 28.) and (ddif[-1] <= 31.): - fcode = _c.FR_MTH + fcode = 'M' elif (ddif[0] >= 90.) and (ddif[-1] <= 92.): - fcode = _c.FR_QTR + fcode = 'Q' elif (ddif[0] >= 365.) and (ddif[-1] <= 366.): - fcode = _c.FR_ANN + fcode = 'A' elif numpy.abs(24.*ddif[0] - 1) <= 1e-5 and \ numpy.abs(24.*ddif[-1] - 1) <= 1e-5: - fcode = _c.FR_HR + fcode = 'H' elif numpy.abs(1440.*ddif[0] - 1) <= 1e-5 and \ numpy.abs(1440.*ddif[-1] - 1) <= 1e-5: - fcode = _c.FR_MIN + fcode = 'T' elif numpy.abs(86400.*ddif[0] - 1) <= 1e-5 and \ numpy.abs(86400.*ddif[-1] - 1) <= 1e-5: - fcode = _c.FR_SEC + fcode = 'S' else: warnings.warn("Unable to estimate the frequency! %.3f<>%.3f" %\ (ddif[0], ddif[-1])) - fcode = _c.FR_UND + fcode = 'U' return fcode @@ -1042,7 +1053,7 @@ if __name__ == '__main__': import maskedarray.testutils from maskedarray.testutils import assert_equal - if 1: + if 0: dlist = ['2007-%02i' % i for i in range(1,5)+range(7,13)] mdates = date_array_fromlist(dlist, 'M') # Using an integer @@ -1052,12 +1063,12 @@ lag = mdates.find_dates(mdates[0]) print mdates[lag] assert_equal(mdates[lag], mdates[0]) - if 1: + if 0: hodie = today('D') D = DateArray(today('D')) assert_equal(D.freq, 6000) - if 1: + if 0: freqs = [x[0] for x in corelib.freq_dict.values() if x[0] != 'U'] print freqs for f in freqs: @@ -1066,9 +1077,16 @@ assert(Date(freq=f, value=today.value) == today) if 1: - D = date_array(start_date=thisday('D'), length=5) - Dstr = D.tostring() - assert_equal(D.tostring(), Dstr) - DL = D[[0,-1]] - assert_equal(DL.tostring(), Dstr[[0,-1]]) - \ No newline at end of file + D = date_array(freq='U', start_date=Date('U',1), length=10) + + if 1: + dlist = ['2007-01-%02i' % i for i in (1,2,4,5,7,8,10,11,13)] + + + ords = numpy.fromiter((DateTimeFromString(s).toordinal() for s in dlist), + float_) + + if 1: + "Tests the automatic sorting of dates." + D = date_array_fromlist(dlist=['2006-01','2005-01','2004-01'],freq='M') + assert_equal(D.view(N.ndarray), [24037, 24049, 24061]) \ No newline at end of file Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-03-02 18:54:55 UTC (rev 2818) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-03-03 23:00:20 UTC (rev 2819) @@ -715,9 +715,11 @@ assert_equal(mdates>=mdates[-4], [0,0,0,0,0,0,1,1,1,1]) dlist = ['2006-%02i' % i for i in range(1,5)+range(7,13)] mdates = date_array_fromlist(dlist).asfreq('M') + #CHECK : Oops, what were we supposed to do here ? def test_getsteps(self): + "Tests the getsteps method" dlist = ['2007-01-%02i' %i for i in (1,2,3,4,8,9,10,11,12,15)] ddates = date_array_fromlist(dlist) assert_equal(ddates.get_steps(), [1,1,1,4,1,1,1,1,3]) @@ -729,8 +731,13 @@ assert_equal(empty_darray.isvalid(), True) assert_equal(empty_darray.get_steps(), None) + def test_cachedinfo(self): + D = date_array(start_date=thisday('D'), length=5) + Dstr = D.tostring() + assert_equal(D.tostring(), Dstr) + DL = D[[0,-1]] + assert_equal(DL.tostring(), Dstr[[0,-1]]) - ############################################################################### #------------------------------------------------------------------------------ if __name__ == "__main__": Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-03-02 18:54:55 UTC (rev 2818) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-03-03 23:00:20 UTC (rev 2819) @@ -25,8 +25,9 @@ import maskedarray.testutils from maskedarray.testutils import assert_equal, assert_array_equal -from timeseries import Date, date_array_fromlist, date_array, thisday -from timeseries import time_series, TimeSeries, adjust_endpoints, \ +from timeseries import tseries +from timeseries.tseries import Date, date_array_fromlist, date_array, thisday +from timeseries.tseries import time_series, TimeSeries, adjust_endpoints, \ mask_period, align_series, fill_missing_dates, tsmasked, concatenate_series class test_creation(NumpyTestCase): @@ -422,6 +423,15 @@ mask = mask_period(series, start, end, inside=False, include_edges=False, inplace=False) assert_equal(mask._mask, [1,1,1,1,1,0,0,0,0,0,0,0,1,1,1]) + # Now w/ multivariables + data = masked_array(numeric.arange(30).reshape(-1,2), dtype=float_) + series = time_series(data, dates=dates) + mask = mask_period(series, start, end, inside=True, include_edges=True, + inplace=False) + result = N.array([0,0,0,0,0,1,1,1,1,1,1,1,0,0,0]) + assert_equal(mask._mask, result.repeat(2).reshape(-1,2)) + + # def test_pickling(self): "Tests pickling/unpickling" Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-03-02 18:54:55 UTC (rev 2818) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-03-03 23:00:20 UTC (rev 2819) @@ -308,7 +308,7 @@ if len(dshape) > 0: if length is None: length = dshape[0] - newdates = date_array(start_date=start_date, length=dshape[0], + newdates = date_array(start_date=start_date, length=length, freq=freq) else: newdates = date_array([], freq=freq) @@ -610,17 +610,25 @@ @property def start_date(self): """Returns the first date of the series.""" - if self._dates.size != 0: - return self._dates[0] + _dates = self._dates + dsize = _dates.size + if dsize == 0: + return None + elif dsize == 1: + return _dates[0] else: - return None + return Date(self.freq, _dates.flat[0]) @property def end_date(self): """Returns the last date of the series.""" - if self._dates.size != 0: - return self._dates[-1] + _dates = self._dates + dsize = _dates.size + if dsize == 0: + return None + elif dsize == 1: + return _dates[-1] else: - return None + return Date(self.freq, _dates.flat[-1]) def isvalid(self): """Returns whether the series has no duplicate/missing dates.""" @@ -920,14 +928,16 @@ ##### -------------------------------------------------------------------------- #---- ... Additional functions ... ##### -------------------------------------------------------------------------- -def mask_period(data, start_date=None, end_date=None, - inside=True, include_edges=True, inplace=True): +def mask_period(data, period=None, start_date=None, end_date=None, + inside=True, include_edges=True, inplace=False): """Returns x as an array masked where dates fall outside the selection period, as well as where data are initially missing (masked). :Parameters: data : Timeseries Data to process + period : Sequence + A sequence of (starting date, ending date). start_date : string/Date *[None]* Starting date. If None, uses the first date of the series. end_date : string/Date *[None]* @@ -943,47 +953,50 @@ data = masked_array(data, subok=True, copy=not inplace) if not isTimeSeries(data): raise ValueError,"Data should be a valid TimeSeries!" + dates = data._dates + if dates.ndim == 1: + dates_lims = dates[[0,-1]] + else: + dates_lim = dates.ravel()[[0,-1]] + # Check the period ..................... + if period is not None and isinstance(period, (tuple, list, ndarray)): + (start_date, end_date) = (period[0], period[-1]) # Check the starting date .............. if start_date is None: - start_date = data._dates[0] + start_date = dates_lim[0] elif isinstance(start_date, str): start_date = Date(data.freq, string=start_date) elif not isinstance(start_date, Date): raise DateError,"Starting date should be a valid Date object!" - start_date = max(start_date, data.dates[0]) # Check the ending date ................ if end_date is None: - end_date = data._dates[-1] + end_date = dates_lim[-1] elif isinstance(end_date, str): end_date = Date(data.freq, string=end_date) elif not isinstance(end_date, Date): raise DateError,"Starting date should be a valid Date object!" - end_date = min(end_date, data.dates[-1]) # Constructs the selection mask ......... + dates = data.dates if inside: if include_edges: - selection = (data.dates >= start_date) & (data.dates <= end_date) + selection = (dates >= start_date) & (dates <= end_date) else: - selection = (data.dates > start_date) & (data.dates < end_date) + selection = (dates > start_date) & (dates < end_date) else: if include_edges: - selection = (data.dates <= start_date) | (data.dates >= end_date) + selection = (dates <= start_date) | (dates >= end_date) else: - selection = (data.dates < start_date) | (data.dates > end_date) - # Process the data: - if data._mask is nomask: - data._mask = selection - else: - data._mask += selection + selection = (dates < start_date) | (dates > end_date) + data[selection] = masked return data def mask_inside_period(data, start_date=None, end_date=None, - include_edges=True, inplace=True): + include_edges=True, inplace=False): """Masks values falling inside a given range of dates.""" return mask_period(data, start_date=start_date, end_date=end_date, inside=True, include_edges=include_edges, inplace=inplace) def mask_outside_period(data, start_date=None, end_date=None, - include_edges=True, inplace=True): + include_edges=True, inplace=False): """Masks values falling outside a given range of dates.""" return mask_period(data, start_date=start_date, end_date=end_date, inside=False, include_edges=include_edges, inplace=inplace) @@ -1374,6 +1387,8 @@ dlist = ['2007-01-%02i' % i for i in range(1,11)] dates = date_array_fromlist(dlist) data = masked_array(numeric.arange(10), mask=[1,0,0,0,0]*2, dtype=float_) + + if 0: ser1d = time_series(data, dlist) serfolded = ser1d.reshape((5,2)) @@ -1385,21 +1400,17 @@ sertrans = serfolded.transpose() assert_equal(sertrans.shape, (2,5)) - if 1: - dlist = ['2007-01-%02i' % i for i in range(1,16)] - data = masked_array(numeric.arange(15), mask=[1,0,0,0,0]*3, dtype=float_) - series = time_series(data, dlist) - series.mask = nomask - (start, end) = ('2007-01-06', '2007-01-12') - mask = mask_period(series, start, end, inside=True, include_edges=True, - inplace=False) - assert_equal(mask._mask, N.array([0,0,0,0,0,1,1,1,1,1,1,1,0,0,0])) - mask = mask_period(series, start, end, inside=True, include_edges=False, - inplace=False) - assert_equal(mask._mask, [0,0,0,0,0,0,1,1,1,1,1,0,0,0,0]) - mask = mask_period(series, start, end, inside=False, include_edges=True, - inplace=False) - assert_equal(mask._mask, [1,1,1,1,1,1,0,0,0,0,0,1,1,1,1]) - mask = mask_period(series, start, end, inside=False, include_edges=False, - inplace=False) - assert_equal(mask._mask, [1,1,1,1,1,0,0,0,0,0,0,0,1,1,1]) \ No newline at end of file + if 1: + data = dates + series = time_series(data, dates) + assert(isinstance(series, TimeSeries)) + assert_equal(series._dates, dates) + assert_equal(series._data, data) + assert_equal(series.freqstr, 'D') + + series[5] = MA.masked + + # ensure that series can be represented by a string after masking a value + # (there was a bug before that prevented this from working when using a + # DateArray for the data) + strrep = str(series) \ No newline at end of file From scipy-svn at scipy.org Mon Mar 5 13:06:38 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 Mar 2007 12:06:38 -0600 (CST) Subject: [Scipy-svn] r2820 - trunk/Lib/sandbox/timeseries Message-ID: <20070305180638.CE00C39C1DB@new.scipy.org> Author: mattknox_ca Date: 2007-03-05 12:06:34 -0600 (Mon, 05 Mar 2007) New Revision: 2820 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: changed code back to using frequency constants internally (but preserved other modifications in previous update) Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-03 23:00:20 UTC (rev 2819) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-05 18:06:34 UTC (rev 2820) @@ -3,12 +3,12 @@ :author: Pierre GF Gerard-Marchant & Matt Knox :contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com -:version: $Id$ +:version: $Id: tdates.py 2815 2007-03-02 16:39:07Z mattknox_ca $ """ -__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author: mattknox_ca $)" __version__ = '1.0' -__revision__ = "$Revision$" -__date__ = '$Date$' +__revision__ = "$Revision: 2815 $" +__date__ = '$Date: 2007-03-02 11:39:07 -0500 (Fri, 02 Mar 2007) $' import datetime as dt @@ -35,6 +35,7 @@ from parser import DateFromString, DateTimeFromString import tcore as corelib +import tcore as _c import cseries @@ -48,7 +49,6 @@ 'period_break' ] - #####--------------------------------------------------------------------------- #---- --- Date Info --- #####--------------------------------------------------------------------------- @@ -147,40 +147,42 @@ value = int(value) if isinstance(value, str): - if self.freqstr in ('H', 'T', 'S'): + if self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): self.datetime = DateTimeFromString(value) else: self.datetime = DateFromString(value) - elif self.freqstr == 'A': - self.datetime = dt.datetime(value, 1, 1) - elif self.freqstr == 'B': + + elif self.freq == _c.FR_SEC: + self.datetime = secondlyOriginDate + dt.timedelta(seconds=value) + elif self.freq == _c.FR_MIN: + self.datetime = minutelyOriginDate + dt.timedelta(minutes=value) + elif self.freq == _c.FR_HR: + self.datetime = hourlyOriginDate + dt.timedelta(hours=value) + elif self.freq == _c.FR_DAY: + self.datetime = dt.datetime.fromordinal(value) + elif self.freq == _c.FR_UND: + self.datetime = int(value) + elif self.freq == _c.FR_BUS: valtmp = (value - 1)//5 self.datetime = dt.datetime.fromordinal(value + valtmp*2) -# elif self.freqstr in 'DU': - elif self.freqstr == 'D': - self.datetime = dt.datetime.fromordinal(value) - elif self.freqstr == 'U': - self.datetime = int(value) - elif self.freqstr == 'H': - self.datetime = hourlyOriginDate + dt.timedelta(hours=value) - elif self.freqstr == 'M': + elif self.freq == _c.FR_WK: + self.datetime = dt.datetime(1,1,7) + \ + dt.timedelta(days=(value-1)*7) + elif self.freq == _c.FR_MTH: year = (value - 1)//12 + 1 month = value - (year - 1)*12 self.datetime = dt.datetime(year, month, 1) - elif self.freqstr == 'Q': + elif self.freq == _c.FR_QTR: year = (value - 1)//4 + 1 month = (value - (year - 1)*4)*3 self.datetime = dt.datetime(year, month, 1) - elif self.freqstr == 'S': - self.datetime = secondlyOriginDate + dt.timedelta(seconds=value) - elif self.freqstr == 'T': - self.datetime = minutelyOriginDate + dt.timedelta(minutes=value) - elif self.freqstr == 'W': - self.datetime = dt.datetime(1,1,7) + \ - dt.timedelta(days=(value-1)*7) + elif self.freq == _c.FR_ANN: + self.datetime = dt.datetime(value, 1, 1) + else: + raise ValueError("unrecognized frequency: "+str(self.freq)) elif string is not None: - if self.freqstr in ('H', 'T', 'S'): + if self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): self.datetime = DateTimeFromString(string) else: self.datetime = DateFromString(string) @@ -194,31 +196,32 @@ # First, some basic checks..... if year is None: raise InsufficientDateError - if self.freqstr in 'BDWU': + if self.freq in (_c.FR_BUS, _c.FR_DAY, _c.FR_WK, _c.FR_UND): if month is None or day is None: raise InsufficientDateError - elif self.freqstr == 'M': + elif self.freq == _c.FR_MTH: if month is None: raise InsufficientDateError day = 1 - elif self.freqstr == 'Q': + elif self.freq == _c.FR_QTR: if quarter is None: raise InsufficientDateError month = quarter * 3 day = 1 - elif self.freqstr == 'A': + elif self.freq == _c.FR_ANN: month = 1 day = 1 - elif self.freqstr == 'S': + elif self.freq == _c.FR_SEC: if month is None or day is None or second is None: raise InsufficientDateError - if self.freqstr in ['A','B','D','M','Q','W']: + if self.freq in (_c.FR_BUS, _c.FR_DAY, _c.FR_WK, + _c.FR_MTH, _c.FR_QTR, _c.FR_ANN): self.datetime = truncateDate(self.freq, dt.datetime(year, month, day)) - if self.freqstr == 'B': + if self.freq == _c.FR_BUS: if self.datetime.isoweekday() in [6,7]: raise ValueError("Weekend passed as business day") - elif self.freqstr in 'HTS': + elif self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): if hour is None: if minute is None: if second is None: @@ -239,6 +242,9 @@ self.datetime = truncateDate(self.freqstr, dt.datetime(year, month, day, hour, minute, second)) + else: + raise ValueError("unrecognized frequency: "+str(self.freq)) + self.value = self.__value() def __getitem__(self, indx): @@ -336,52 +342,52 @@ def __value(self): "Converts the date to an integer, depending on the current frequency." - # Annual ....... - if self.freqstr == 'A': - val = self.datetime.year - # Quarterly..... - elif self.freqstr == 'Q': - val = (self.datetime.year-1)*4 + self.datetime.month//3 - # Monthly....... - elif self.freqstr == 'M': - val = (self.datetime.year-1)*12 + self.datetime.month - # Weekly........ - elif self.freqstr == 'W': - val = self.datetime.toordinal()//7 - # Business days. - elif self.freqstr == 'B': - days = self.datetime.toordinal() - weeks = days // 7 - val = days - weeks*2 - # Daily......... -# elif self.freqstr in 'DU': - elif self.freqstr == 'D': + # Secondly...... + if self.freq == _c.FR_SEC: + delta = (self.datetime - secondlyOriginDate) + val = delta.days*86400 + delta.seconds + # Minutely...... + elif self.freq == _c.FR_MIN: + delta = (self.datetime - minutelyOriginDate) + val = delta.days*1440 + delta.seconds/(60) + # Hourly........ + elif self.freq == _c.FR_HR: + delta = (self.datetime - hourlyOriginDate) + val = delta.days*24 + delta.seconds/(3600) + # Daily + elif self.freq == _c.FR_DAY: val = self.datetime.toordinal() - # Undefined..... - elif self.freqstr == 'U': + # undefined + elif self.freq == _c.FR_UND: if not hasattr(self.datetime, 'toordinal'): val = self.datetime else: val = self.datetime.toordinal() - # Hourly........ - elif self.freqstr == 'H': - delta = (self.datetime - hourlyOriginDate) - val = delta.days*24 + delta.seconds/(3600) - # Minutely...... - elif self.freqstr == 'T': - delta = (self.datetime - minutelyOriginDate) - val = delta.days*1440 + delta.seconds/(60) - # Secondly...... - elif self.freqstr == 'S': - delta = (self.datetime - secondlyOriginDate) - val = delta.days*86400 + delta.seconds + # Business days. + elif self.freq == _c.FR_BUS: + days = self.datetime.toordinal() + weeks = days // 7 + val = days - weeks*2 + # Weekly........ + elif self.freq == _c.FR_WK: + val = self.datetime.toordinal()//7 + # Monthly....... + elif self.freq == _c.FR_MTH: + val = (self.datetime.year-1)*12 + self.datetime.month + # Quarterly..... + elif self.freq == _c.FR_QTR: + val = (self.datetime.year-1)*4 + self.datetime.month//3 + # Annual ....... + elif self.freq == _c.FR_ANN: + val = self.datetime.year + return int(val) #...................................................... def strfmt(self, fmt): "Formats the date" if fmt is None: fmt = self.default_fmtstr[self.freqstr] - if self.freqstr == 'U': + if self.freq == _c.FR_UND: return str(self.value) return cseries.strfmt(self.datetime, fmt) @@ -394,7 +400,7 @@ def toordinal(self): "Returns the date as an ordinal." # FIXME: We shouldn't need the test if we were in C - if self.freqstr == 'U': + if self.freq == _c.FR_UND: return self.value return self.datetime.toordinal() @@ -432,26 +438,26 @@ def truncateDate(freq, datetime): "Chops off the irrelevant information from the datetime object passed in." - freqstr = corelib.check_freqstr(freq) - if freqstr == 'A': - return dt.datetime(datetime.year, 1, 1) - elif freqstr == 'Q': - return dt.datetime(datetime.year, monthToQuarter(datetime.month)*3, 1) - elif freqstr == 'M': - return dt.datetime(datetime.year, datetime.month, 1) - elif freqstr == 'W': + freq = corelib.check_freq(freq) + if freq == _c.FR_MIN: + return dt.datetime(datetime.year, datetime.month, datetime.day, \ + datetime.hour, datetime.minute) + elif freq == _c.FR_HR: + return dt.datetime(datetime.year, datetime.month, datetime.day, \ + datetime.hour) + elif freq in (_c.FR_BUS, _c.FR_DAY): + if freq == _c.FR_BUS and datetime.isoweekday() in (6,7): + raise ValueError("Weekend passed as business day") + return dt.datetime(datetime.year, datetime.month, datetime.day) + elif freq == _c.FR_WK: d = datetime.toordinal() return dt.datetime.fromordinal(d + (7 - d % 7) % 7) - elif freqstr in 'BD': - if freq == 'B' and datetime.isoweekday() in (6,7): - raise ValueError("Weekend passed as business day") - return dt.datetime(datetime.year, datetime.month, datetime.day) - elif freqstr == 'H': - return dt.datetime(datetime.year, datetime.month, datetime.day, \ - datetime.hour) - elif freqstr == 'T': - return dt.datetime(datetime.year, datetime.month, datetime.day, \ - datetime.hour, datetime.minute) + elif freq == _c.FR_MTH: + return dt.datetime(datetime.year, datetime.month, 1) + elif freq == _c.FR_QTR: + return dt.datetime(datetime.year, monthToQuarter(datetime.month)*3, 1) + elif freq == _c.FR_ANN: + return dt.datetime(datetime.year, 1, 1) else: return datetime @@ -462,18 +468,20 @@ def thisday(freq): "Returns today's date, at the given frequency `freq`." - freqstr = corelib.check_freqstr(freq) + freq = corelib.check_freq(freq) tempDate = dt.datetime.now() # if it is Saturday or Sunday currently, freq==B, then we want to use Friday - if freqstr == 'B' and tempDate.isoweekday() >= 6: + if freq == _c.FR_BUS and tempDate.isoweekday() >= 6: tempDate = tempDate - dt.timedelta(days=(tempDate.isoweekday() - 5)) - if freqstr in ('B','D','H','S','T','W','U'): + if freq in (_c.FR_BUS,_c.FR_DAY, + _c.FR_HR,_c.FR_SEC,_c.FR_MIN, + _c.FR_WK,_c.FR_UND): return Date(freq, datetime=tempDate) - elif freqstr == 'M': + elif freq == _c.FR_MTH: return Date(freq, year=tempDate.year, month=tempDate.month) - elif freqstr == 'Q': + elif freq == _c.FR_QTR: return Date(freq, year=tempDate.year, quarter=monthToQuarter(tempDate.month)) - elif freqstr == 'A': + elif freq == _c.FR_ANN: return Date(freq, year=tempDate.year) today = thisday @@ -483,9 +491,9 @@ dateNum = tempDate.hour + float(tempDate.minute)/60 checkNum = day_end_hour + float(day_end_min)/60 if dateNum < checkNum: - return thisday('B') - 1 + return thisday(_c.FR_BUS) - 1 else: - return thisday('B') + return thisday(_c.FR_BUS) def asfreq(date, toFreq, relation="BEFORE"): """Returns a date converted to another frequency `toFreq`, according to the @@ -499,9 +507,9 @@ if not isinstance(date, Date): raise DateError, "Date should be a valid Date instance!" - if date.freqstr == 'U': + if date.freq == _c.FR_UND: warnings.warn("Undefined frequency: assuming daily!") - fromfreq = corelib.freq_revdict['D'] + fromfreq = _c.FR_DAY else: fromfreq = date.freq @@ -729,7 +737,7 @@ # Note: we better try to cache the result if self._cachedinfo['toord'] is None: # diter = (Date(self.freq, value=d).toordinal() for d in self) - if self.freq == -9999: + if self.freq == _c.FR_UND: diter = (d.value for d in self) else: diter = (d.toordinal() for d in self) @@ -754,17 +762,18 @@ def asfreq(self, freq=None, relation="BEFORE"): "Converts the dates to another frequency." # Note: As we define a new object, we don't need caching - if freq is None or freq == -9999: + if freq is None or freq == _c.FR_UND: return self tofreq = corelib.check_freq(freq) if tofreq == self.freq: return self _rel = relation.upper()[0] fromfreq = self.freq - if fromfreq == -9999: - fromfreq = 6000 + if fromfreq == _c.FR_UND: + fromfreq = _c.FR_DAY new = cseries.asfreq(numeric.asarray(self), fromfreq, tofreq, _rel) return DateArray(new, freq=freq) + #...................................................... def find_dates(self, *dates): "Returns the indices corresponding to given dates, as an array." @@ -853,30 +862,30 @@ ddif = numeric.asarray(numpy.diff(dates)) ddif.sort() if ddif[0] == ddif[-1] == 1.: - fcode = 'D' + fcode = _c.FR_DAY elif (ddif[0] == 1.) and (ddif[-1] == 3.): - fcode = 'B' + fcode = _c.FR_BUS elif (ddif[0] > 3.) and (ddif[-1] == 7.): - fcode = 'W' + fcode = _c.FR_WK elif (ddif[0] >= 28.) and (ddif[-1] <= 31.): - fcode = 'M' + fcode = _c.FR_MTH elif (ddif[0] >= 90.) and (ddif[-1] <= 92.): - fcode = 'Q' + fcode = _c.FR_QTR elif (ddif[0] >= 365.) and (ddif[-1] <= 366.): - fcode = 'A' + fcode = _c.FR_ANN elif numpy.abs(24.*ddif[0] - 1) <= 1e-5 and \ numpy.abs(24.*ddif[-1] - 1) <= 1e-5: - fcode = 'H' + fcode = _c.FR_HR elif numpy.abs(1440.*ddif[0] - 1) <= 1e-5 and \ numpy.abs(1440.*ddif[-1] - 1) <= 1e-5: - fcode = 'T' + fcode = _c.FR_MIN elif numpy.abs(86400.*ddif[0] - 1) <= 1e-5 and \ numpy.abs(86400.*ddif[-1] - 1) <= 1e-5: - fcode = 'S' + fcode = _c.FR_SEC else: warnings.warn("Unable to estimate the frequency! %.3f<>%.3f" %\ (ddif[0], ddif[-1])) - fcode = 'U' + fcode = _c.FR_UND return fcode From scipy-svn at scipy.org Mon Mar 5 16:57:10 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 Mar 2007 15:57:10 -0600 (CST) Subject: [Scipy-svn] r2821 - trunk/Lib/sandbox/timeseries Message-ID: <20070305215710.17EB839C1DC@new.scipy.org> Author: mattknox_ca Date: 2007-03-05 15:57:03 -0600 (Mon, 05 Mar 2007) New Revision: 2821 Modified: trunk/Lib/sandbox/timeseries/setup.py Log: fixed typo with "doc" dir Modified: trunk/Lib/sandbox/timeseries/setup.py =================================================================== --- trunk/Lib/sandbox/timeseries/setup.py 2007-03-05 18:06:34 UTC (rev 2820) +++ trunk/Lib/sandbox/timeseries/setup.py 2007-03-05 21:57:03 UTC (rev 2821) @@ -15,7 +15,7 @@ sources=[sources,], include_dirs=[nxheader], ) - confgr.add_data_dir('docs') + confgr.add_data_dir('doc') confgr.add_subpackage('addons') confgr.add_subpackage('io') confgr.add_subpackage('plotlib') From scipy-svn at scipy.org Mon Mar 5 16:57:50 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 Mar 2007 15:57:50 -0600 (CST) Subject: [Scipy-svn] r2822 - trunk/Lib/sandbox/timeseries Message-ID: <20070305215750.7EEF639C1DC@new.scipy.org> Author: mattknox_ca Date: 2007-03-05 15:57:47 -0600 (Mon, 05 Mar 2007) New Revision: 2822 Modified: trunk/Lib/sandbox/timeseries/__init__.py Log: imported filters and interpolate from addons Modified: trunk/Lib/sandbox/timeseries/__init__.py =================================================================== --- trunk/Lib/sandbox/timeseries/__init__.py 2007-03-05 21:57:03 UTC (rev 2821) +++ trunk/Lib/sandbox/timeseries/__init__.py 2007-03-05 21:57:47 UTC (rev 2822) @@ -24,10 +24,10 @@ import reportlib from reportlib import * import plotlib -import addons +from addons import filters, interpolate -__all__ = ['tdates', 'tseries','tmulti','reportlib'] +__all__ = ['tdates', 'tseries','tmulti','reportlib','filters','interpolate'] __all__ += tdates.__all__ __all__ += tseries.__all__ __all__ += tmulti.__all__ From scipy-svn at scipy.org Mon Mar 5 16:58:57 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 Mar 2007 15:58:57 -0600 (CST) Subject: [Scipy-svn] r2823 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070305215857.4758A39C1DC@new.scipy.org> Author: mattknox_ca Date: 2007-03-05 15:58:53 -0600 (Mon, 05 Mar 2007) New Revision: 2823 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: added support for different weekly frequencies (weekly-saturday, weekly-Monday, etc) Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-05 21:57:47 UTC (rev 2822) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-05 21:58:53 UTC (rev 2823) @@ -11,13 +11,22 @@ #define FR_ANN 1000 /* Annual */ #define FR_QTR 2000 /* Quarterly */ #define FR_MTH 3000 /* Monthly */ + #define FR_WK 4000 /* Weekly */ +#define FR_WKSUN FR_WK /* Weekly - Sunday end of week */ +#define FR_WKMON 4001 /* Weekly - Monday end of week */ +#define FR_WKTUE 4002 /* Weekly - Tuesday end of week */ +#define FR_WKWED 4003 /* Weekly - Wednesday end of week */ +#define FR_WKTHU 4004 /* Weekly - Thursday end of week */ +#define FR_WKFRI 4005 /* Weekly - Friday end of week */ +#define FR_WKSAT 4006 /* Weekly - Saturday end of week */ + #define FR_BUS 5000 /* Business days */ #define FR_DAY 6000 /* Daily */ #define FR_HR 7000 /* Hourly */ #define FR_MIN 8000 /* Minutely */ #define FR_SEC 9000 /* Secondly */ -#define FR_UND -9999 /* Undefined */ +#define FR_UND -10000 /* Undefined */ #define ADD_INT_TO_DICT(dict, key, val) \ {PyObject *pyval = PyInt_FromLong(val); \ @@ -28,6 +37,13 @@ #define CHECK_ASFREQ(result) if ((result) == DINFO_ERR) return NULL +struct asfreq_info{ + int to_week_end; //day the week ends on in the "to" frequency + int from_week_end; //day the week ends on in the "from" frequency +}; + +static struct asfreq_info NULL_AF_INFO; + //DERIVED FROM mx.DateTime /* ===================================================== @@ -446,7 +462,7 @@ //************ FROM DAILY *************** -static long asfreq_DtoA(long fromDate, char relation) { +static long asfreq_DtoA(long fromDate, char relation, struct asfreq_info af_info) { struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, @@ -454,7 +470,7 @@ return (long)(dinfo.year); } -static long asfreq_DtoQ(long fromDate, char relation) { +static long asfreq_DtoQ(long fromDate, char relation, struct asfreq_info af_info) { struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, @@ -462,7 +478,7 @@ return (long)((dinfo.year - 1) * 4 + dinfo.quarter); } -static long asfreq_DtoM(long fromDate, char relation) { +static long asfreq_DtoM(long fromDate, char relation, struct asfreq_info af_info) { struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, @@ -470,9 +486,11 @@ return (long)((dinfo.year - 1) * 12 + dinfo.month); } -static long asfreq_DtoW(long fromDate, char relation) { return (fromDate - 1)/7 + 1; } +static long asfreq_DtoW(long fromDate, char relation, struct asfreq_info af_info) { + return (fromDate - (1 + af_info.to_week_end))/7 + 1; +} -static long asfreq_DtoB(long fromDate, char relation) { +static long asfreq_DtoB(long fromDate, char relation, struct asfreq_info af_info) { struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, @@ -485,7 +503,7 @@ } } -static long asfreq_DtoB_forConvert(long fromDate, char relation) { +static long asfreq_DtoB_forConvert(long fromDate, char relation, struct asfreq_info af_info) { struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, @@ -499,7 +517,7 @@ } // needed for getDateInfo function -static long asfreq_DtoD(long fromDate, char relation) { return fromDate; } +static long asfreq_DtoD(long fromDate, char relation, struct asfreq_info af_info) { return fromDate; } static long asfreq_DtoHIGHFREQ(long fromDate, char relation, long periodsPerDay) { if (fromDate >= minval_D_toHighFreq) { @@ -508,115 +526,143 @@ } else { return -1; } } -static long asfreq_DtoH(long fromDate, char relation) { return asfreq_DtoHIGHFREQ(fromDate, relation, 24); } -static long asfreq_DtoT(long fromDate, char relation) { return asfreq_DtoHIGHFREQ(fromDate, relation, 24*60); } -static long asfreq_DtoS(long fromDate, char relation) { return asfreq_DtoHIGHFREQ(fromDate, relation, 24*60*60); } +static long asfreq_DtoH(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoHIGHFREQ(fromDate, relation, 24); } +static long asfreq_DtoT(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoHIGHFREQ(fromDate, relation, 24*60); } +static long asfreq_DtoS(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoHIGHFREQ(fromDate, relation, 24*60*60); } //************ FROM SECONDLY *************** -static long asfreq_StoD(long fromDate, char relation) { return (fromDate - 1)/(60*60*24) + minval_D_toHighFreq; } +static long asfreq_StoD(long fromDate, char relation, struct asfreq_info af_info) + { return (fromDate - 1)/(60*60*24) + minval_D_toHighFreq; } -static long asfreq_StoA(long fromDate, char relation) { return asfreq_DtoA(asfreq_StoD(fromDate, relation), relation); } -static long asfreq_StoQ(long fromDate, char relation) { return asfreq_DtoQ(asfreq_StoD(fromDate, relation), relation); } -static long asfreq_StoM(long fromDate, char relation) { return asfreq_DtoM(asfreq_StoD(fromDate, relation), relation); } -static long asfreq_StoW(long fromDate, char relation) { return asfreq_DtoW(asfreq_StoD(fromDate, relation), relation); } -static long asfreq_StoB(long fromDate, char relation) { return asfreq_DtoB(asfreq_StoD(fromDate, relation), relation); } -static long asfreq_StoB_forConvert(long fromDate, char relation) - { return asfreq_DtoB_forConvert(asfreq_StoD(fromDate, relation), relation); } -static long asfreq_StoT(long fromDate, char relation) { return (fromDate - 1)/60 + 1; } -static long asfreq_StoH(long fromDate, char relation) { return (fromDate - 1)/(60*60) + 1; } +static long asfreq_StoA(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoA(asfreq_StoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_StoQ(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoQ(asfreq_StoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_StoM(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoM(asfreq_StoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_StoW(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoW(asfreq_StoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } +static long asfreq_StoB(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoB(asfreq_StoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_StoB_forConvert(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoB_forConvert(asfreq_StoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_StoT(long fromDate, char relation, struct asfreq_info af_info) + { return (fromDate - 1)/60 + 1; } +static long asfreq_StoH(long fromDate, char relation, struct asfreq_info af_info) + { return (fromDate - 1)/(60*60) + 1; } //************ FROM MINUTELY *************** -static long asfreq_TtoD(long fromDate, char relation) { return (fromDate - 1)/(60*24) + minval_D_toHighFreq; } +static long asfreq_TtoD(long fromDate, char relation, struct asfreq_info af_info) + { return (fromDate - 1)/(60*24) + minval_D_toHighFreq; } -static long asfreq_TtoA(long fromDate, char relation) { return asfreq_DtoA(asfreq_TtoD(fromDate, relation), relation); } -static long asfreq_TtoQ(long fromDate, char relation) { return asfreq_DtoQ(asfreq_TtoD(fromDate, relation), relation); } -static long asfreq_TtoM(long fromDate, char relation) { return asfreq_DtoM(asfreq_TtoD(fromDate, relation), relation); } -static long asfreq_TtoW(long fromDate, char relation) { return asfreq_DtoW(asfreq_TtoD(fromDate, relation), relation); } -static long asfreq_TtoB(long fromDate, char relation) { return asfreq_DtoB(asfreq_TtoD(fromDate, relation), relation); } +static long asfreq_TtoA(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoA(asfreq_TtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_TtoQ(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoQ(asfreq_TtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_TtoM(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoM(asfreq_TtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_TtoW(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoW(asfreq_TtoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } +static long asfreq_TtoB(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoB(asfreq_TtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_TtoB_forConvert(long fromDate, char relation) - { return asfreq_DtoB_forConvert(asfreq_TtoD(fromDate, relation), relation); } +static long asfreq_TtoB_forConvert(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoB_forConvert(asfreq_TtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_TtoH(long fromDate, char relation) { return (fromDate - 1)/60 + 1; } -static long asfreq_TtoS(long fromDate, char relation) { +static long asfreq_TtoH(long fromDate, char relation, struct asfreq_info af_info) + { return (fromDate - 1)/60 + 1; } +static long asfreq_TtoS(long fromDate, char relation, struct asfreq_info af_info) { if (relation == 'B') { return fromDate*60 - 59; } else { return fromDate*60; }} //************ FROM HOURLY *************** -static long asfreq_HtoD(long fromDate, char relation) { return (fromDate - 1)/24 + minval_D_toHighFreq; } -static long asfreq_HtoA(long fromDate, char relation) { return asfreq_DtoA(asfreq_HtoD(fromDate, relation), relation); } -static long asfreq_HtoQ(long fromDate, char relation) { return asfreq_DtoQ(asfreq_HtoD(fromDate, relation), relation); } -static long asfreq_HtoM(long fromDate, char relation) { return asfreq_DtoM(asfreq_HtoD(fromDate, relation), relation); } -static long asfreq_HtoW(long fromDate, char relation) { return asfreq_DtoW(asfreq_HtoD(fromDate, relation), relation); } -static long asfreq_HtoB(long fromDate, char relation) { return asfreq_DtoB(asfreq_HtoD(fromDate, relation), relation); } +static long asfreq_HtoD(long fromDate, char relation, struct asfreq_info af_info) + { return (fromDate - 1)/24 + minval_D_toHighFreq; } +static long asfreq_HtoA(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoA(asfreq_HtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_HtoQ(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoQ(asfreq_HtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_HtoM(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoM(asfreq_HtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_HtoW(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoW(asfreq_HtoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } +static long asfreq_HtoB(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoB(asfreq_HtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_HtoB_forConvert(long fromDate, char relation) - { return asfreq_DtoB_forConvert(asfreq_HtoD(fromDate, relation), relation); } +static long asfreq_HtoB_forConvert(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoB_forConvert(asfreq_HtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } // calculation works out the same as TtoS, so we just call that function for HtoT -static long asfreq_HtoT(long fromDate, char relation) { return asfreq_TtoS(fromDate, relation); } -static long asfreq_HtoS(long fromDate, char relation) { +static long asfreq_HtoT(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_TtoS(fromDate, relation, NULL_AF_INFO); } +static long asfreq_HtoS(long fromDate, char relation, struct asfreq_info af_info) { if (relation == 'B') { return fromDate*60*60 - 60*60 + 1; } else { return fromDate*60*60; }} //************ FROM BUSINESS *************** -static long asfreq_BtoD(long fromDate, char relation) { - return ((fromDate-1)/5)*7 + (fromDate-1)%5 + 1; } +static long asfreq_BtoD(long fromDate, char relation, struct asfreq_info af_info) + { return ((fromDate-1)/5)*7 + (fromDate-1)%5 + 1; } -static long asfreq_BtoA(long fromDate, char relation) { - return asfreq_DtoA(asfreq_BtoD(fromDate, relation), relation); } +static long asfreq_BtoA(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoA(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_BtoQ(long fromDate, char relation) { - return asfreq_DtoQ(asfreq_BtoD(fromDate, relation), relation); } +static long asfreq_BtoQ(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoQ(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_BtoM(long fromDate, char relation) { - return asfreq_DtoM(asfreq_BtoD(fromDate, relation), relation); } +static long asfreq_BtoM(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoM(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_BtoW(long fromDate, char relation) { - return asfreq_DtoW(asfreq_BtoD(fromDate, relation), relation); } +static long asfreq_BtoW(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoW(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } -static long asfreq_BtoH(long fromDate, char relation) { - return asfreq_DtoH(asfreq_BtoD(fromDate, relation), relation); } +static long asfreq_BtoH(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoH(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_BtoT(long fromDate, char relation) { - return asfreq_DtoT(asfreq_BtoD(fromDate, relation), relation); } +static long asfreq_BtoT(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoT(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_BtoS(long fromDate, char relation) { - return asfreq_DtoS(asfreq_BtoD(fromDate, relation), relation); } +static long asfreq_BtoS(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoS(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } //************ FROM WEEKLY *************** -static long asfreq_WtoD(long fromDate, char relation) { - if (relation == 'B') { return fromDate * 7 - 6;} - else { return fromDate * 7; }} +static long asfreq_WtoD(long fromDate, char relation, struct asfreq_info af_info) { + if (relation == 'B') { return fromDate * 7 - 6 + af_info.from_week_end;} + else { return fromDate * 7 + af_info.from_week_end; }} -static long asfreq_WtoA(long fromDate, char relation) { - return asfreq_DtoA(asfreq_WtoD(fromDate, 'A'), relation); } -static long asfreq_WtoQ(long fromDate, char relation) { - return asfreq_DtoQ(asfreq_WtoD(fromDate, 'A'), relation); } -static long asfreq_WtoM(long fromDate, char relation) { - return asfreq_DtoM(asfreq_WtoD(fromDate, 'A'), relation); } +static long asfreq_WtoA(long fromDate, char relation, struct asfreq_info af_info) { + return asfreq_DtoA(asfreq_WtoD(fromDate, 'A', af_info), relation, NULL_AF_INFO); } +static long asfreq_WtoQ(long fromDate, char relation, struct asfreq_info af_info) { + return asfreq_DtoQ(asfreq_WtoD(fromDate, 'A', af_info), relation, NULL_AF_INFO); } +static long asfreq_WtoM(long fromDate, char relation, struct asfreq_info af_info) { + return asfreq_DtoM(asfreq_WtoD(fromDate, 'A', af_info), relation, NULL_AF_INFO); } -static long asfreq_WtoB(long fromDate, char relation) { +static long asfreq_WtoW(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoW(asfreq_WtoD(fromDate, relation, af_info), relation, NULL_AF_INFO); } +static long asfreq_WtoB(long fromDate, char relation, struct asfreq_info af_info) { + struct date_info dinfo; - if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_WtoD(fromDate, relation), + if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_WtoD(fromDate, relation, af_info), GREGORIAN_CALENDAR)) return DINFO_ERR; if (relation == 'B') { return DtoB_WeekendToMonday(dinfo); } else { return DtoB_WeekendToFriday(dinfo); } } -static long asfreq_WtoH(long fromDate, char relation) { - return asfreq_DtoH(asfreq_WtoD(fromDate, relation), relation); } -static long asfreq_WtoT(long fromDate, char relation) { - return asfreq_DtoT(asfreq_WtoD(fromDate, relation), relation); } -static long asfreq_WtoS(long fromDate, char relation) { - return asfreq_DtoS(asfreq_WtoD(fromDate, relation), relation); } +static long asfreq_WtoH(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoH(asfreq_WtoD(fromDate, relation, af_info), relation, NULL_AF_INFO); } +static long asfreq_WtoT(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoT(asfreq_WtoD(fromDate, relation, af_info), relation, NULL_AF_INFO); } +static long asfreq_WtoS(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoS(asfreq_WtoD(fromDate, relation, af_info), relation, NULL_AF_INFO); } //************ FROM MONTHLY *************** @@ -625,7 +671,7 @@ *m = fromDate - 12 * (*y) - 1; } -static long asfreq_MtoD(long fromDate, char relation) { +static long asfreq_MtoD(long fromDate, char relation, struct asfreq_info af_info) { long y, m, absdate; @@ -640,24 +686,30 @@ } } -static long asfreq_MtoA(long fromDate, char relation) { return (fromDate - 1) / 12 + 1; } -static long asfreq_MtoQ(long fromDate, char relation) { return (fromDate - 1) / 3 + 1; } +static long asfreq_MtoA(long fromDate, char relation, struct asfreq_info af_info) + { return (fromDate - 1) / 12 + 1; } +static long asfreq_MtoQ(long fromDate, char relation, struct asfreq_info af_info) + { return (fromDate - 1) / 3 + 1; } -static long asfreq_MtoW(long fromDate, char relation) { return asfreq_DtoW(asfreq_MtoD(fromDate, relation), relation); } +static long asfreq_MtoW(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoW(asfreq_MtoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } -static long asfreq_MtoB(long fromDate, char relation) { +static long asfreq_MtoB(long fromDate, char relation, struct asfreq_info af_info) { struct date_info dinfo; - if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_MtoD(fromDate, relation), + if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_MtoD(fromDate, relation, NULL_AF_INFO), GREGORIAN_CALENDAR)) return DINFO_ERR; if (relation == 'B') { return DtoB_WeekendToMonday(dinfo); } else { return DtoB_WeekendToFriday(dinfo); } } -static long asfreq_MtoH(long fromDate, char relation) { return asfreq_DtoH(asfreq_MtoD(fromDate, relation), relation); } -static long asfreq_MtoT(long fromDate, char relation) { return asfreq_DtoT(asfreq_MtoD(fromDate, relation), relation); } -static long asfreq_MtoS(long fromDate, char relation) { return asfreq_DtoS(asfreq_MtoD(fromDate, relation), relation); } +static long asfreq_MtoH(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoH(asfreq_MtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_MtoT(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoT(asfreq_MtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_MtoS(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoS(asfreq_MtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } //************ FROM QUARTERLY *************** @@ -666,7 +718,7 @@ *m = (fromDate + 4) * 3 - 12 * (*y) - 2; } -static long asfreq_QtoD(long fromDate, char relation) { +static long asfreq_QtoD(long fromDate, char relation, struct asfreq_info af_info) { long y, m, absdate; @@ -681,19 +733,21 @@ } } -static long asfreq_QtoA(long fromDate, char relation) { return (fromDate - 1)/ 4 + 1; } +static long asfreq_QtoA(long fromDate, char relation, struct asfreq_info af_info) + { return (fromDate - 1)/ 4 + 1; } -static long asfreq_QtoM(long fromDate, char relation) { +static long asfreq_QtoM(long fromDate, char relation, struct asfreq_info af_info) { if (relation == 'B') { return fromDate * 3 - 2; } else { return fromDate * 3; } } -static long asfreq_QtoW(long fromDate, char relation) { return asfreq_DtoW(asfreq_QtoD(fromDate, relation), relation); } +static long asfreq_QtoW(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoW(asfreq_QtoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } -static long asfreq_QtoB(long fromDate, char relation) { +static long asfreq_QtoB(long fromDate, char relation, struct asfreq_info af_info) { struct date_info dinfo; - if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_QtoD(fromDate, relation), + if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_QtoD(fromDate, relation, NULL_AF_INFO), GREGORIAN_CALENDAR)) return DINFO_ERR; if (relation == 'B') { return DtoB_WeekendToMonday(dinfo); } @@ -701,14 +755,17 @@ } -static long asfreq_QtoH(long fromDate, char relation) { return asfreq_DtoH(asfreq_QtoD(fromDate, relation), relation); } -static long asfreq_QtoT(long fromDate, char relation) { return asfreq_DtoT(asfreq_QtoD(fromDate, relation), relation); } -static long asfreq_QtoS(long fromDate, char relation) { return asfreq_DtoS(asfreq_QtoD(fromDate, relation), relation); } +static long asfreq_QtoH(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoH(asfreq_QtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_QtoT(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoT(asfreq_QtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_QtoS(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoS(asfreq_QtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } //************ FROM ANNUAL *************** -static long asfreq_AtoD(long fromDate, char relation) { +static long asfreq_AtoD(long fromDate, char relation, struct asfreq_info af_info) { long absdate; if (relation == 'B') { if ((absdate = absdate_from_ymd(fromDate,1,1)) == DINFO_ERR) return DINFO_ERR; @@ -719,19 +776,20 @@ } } -static long asfreq_AtoQ(long fromDate, char relation) { +static long asfreq_AtoQ(long fromDate, char relation, struct asfreq_info af_info) { if (relation == 'B') { return fromDate * 4 - 3; } else { return fromDate * 4; } } -static long asfreq_AtoM(long fromDate, char relation) { +static long asfreq_AtoM(long fromDate, char relation, struct asfreq_info af_info) { if (relation == 'B') { return fromDate * 12 - 11; } else { return fromDate * 12; } } -static long asfreq_AtoW(long fromDate, char relation) { return asfreq_DtoW(asfreq_AtoD(fromDate, relation), relation); } +static long asfreq_AtoW(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoW(asfreq_AtoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } -static long asfreq_AtoB(long fromDate, char relation) { +static long asfreq_AtoB(long fromDate, char relation, struct asfreq_info af_info) { struct date_info dailyDate; @@ -757,22 +815,28 @@ } } -static long asfreq_AtoH(long fromDate, char relation) { return asfreq_DtoH(asfreq_AtoD(fromDate, relation), relation); } -static long asfreq_AtoT(long fromDate, char relation) { return asfreq_DtoT(asfreq_AtoD(fromDate, relation), relation); } -static long asfreq_AtoS(long fromDate, char relation) { return asfreq_DtoS(asfreq_AtoD(fromDate, relation), relation); } +static long asfreq_AtoH(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoH(asfreq_AtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_AtoT(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoT(asfreq_AtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_AtoS(long fromDate, char relation, struct asfreq_info af_info) + { return asfreq_DtoS(asfreq_AtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long nofunc(long fromDate, char relation) { return -1; } +static long nofunc(long fromDate, char relation, struct asfreq_info af_info) { return -1; } // end of frequency specific conversion routines // return a pointer to appropriate conversion function -static long (*get_asfreq_func(int fromFreq, int toFreq, int forConvert))(long, char) { +static long (*get_asfreq_func(int fromFreq, int toFreq, int forConvert))(long, char, struct asfreq_info) { - switch(fromFreq) + int fromGroup = (fromFreq/1000)*1000; + int toGroup = (toFreq/1000)*1000; + + switch(fromGroup) { case FR_ANN: - switch(toFreq) + switch(toGroup) { case FR_QTR: return &asfreq_AtoQ; case FR_MTH: return &asfreq_AtoM; @@ -786,7 +850,7 @@ } case FR_QTR: - switch(toFreq) + switch(toGroup) { case FR_ANN: return &asfreq_QtoA; case FR_MTH: return &asfreq_QtoM; @@ -800,7 +864,7 @@ } case FR_MTH: - switch(toFreq) + switch(toGroup) { case FR_ANN: return &asfreq_MtoA; case FR_QTR: return &asfreq_MtoQ; @@ -814,11 +878,12 @@ } case FR_WK: - switch(toFreq) + switch(toGroup) { case FR_ANN: return &asfreq_WtoA; case FR_QTR: return &asfreq_WtoQ; case FR_MTH: return &asfreq_WtoM; + case FR_WK: return &asfreq_WtoW; case FR_BUS: return &asfreq_WtoB; case FR_DAY: return &asfreq_WtoD; case FR_HR: return &asfreq_WtoH; @@ -828,7 +893,7 @@ } case FR_BUS: - switch(toFreq) + switch(toGroup) { case FR_ANN: return &asfreq_BtoA; case FR_QTR: return &asfreq_BtoQ; @@ -842,7 +907,7 @@ } case FR_DAY: - switch(toFreq) + switch(toGroup) { case FR_ANN: return &asfreq_DtoA; case FR_QTR: return &asfreq_DtoQ; @@ -859,7 +924,7 @@ } case FR_HR: - switch(toFreq) + switch(toGroup) { case FR_ANN: return &asfreq_HtoA; case FR_QTR: return &asfreq_HtoQ; @@ -875,7 +940,7 @@ } case FR_MIN: - switch(toFreq) + switch(toGroup) { case FR_ANN: return &asfreq_TtoA; case FR_QTR: return &asfreq_TtoQ; @@ -891,7 +956,7 @@ } case FR_SEC: - switch(toFreq) + switch(toGroup) { case FR_ANN: return &asfreq_StoA; case FR_QTR: return &asfreq_StoQ; @@ -919,6 +984,9 @@ int maxBusDaysPerYear, maxBusDaysPerQuarter, maxBusDaysPerMonth; int maxDaysPerYear, maxDaysPerQuarter, maxDaysPerMonth; + int fromGroup = (fromFreq/1000)*1000; + int toGroup = (toFreq/1000)*1000; + maxBusDaysPerYear = 262; maxBusDaysPerQuarter = 66; maxBusDaysPerMonth = 23; @@ -927,24 +995,26 @@ maxDaysPerQuarter = 92; maxDaysPerMonth = 31; - switch(fromFreq) + + + switch(fromGroup) { case FR_ANN: return 1; case FR_QTR: - switch(toFreq) + switch(toGroup) { case FR_ANN: return 4; default: return 1; } case FR_MTH: //monthly - switch(toFreq) + switch(toGroup) { case FR_ANN: return 12; case FR_QTR: return 3; default: return 1; } - case FR_WK: //monthly - switch(toFreq) + case FR_WK: //weekly + switch(toGroup) { case FR_ANN: return 53; case FR_QTR: return 13; @@ -952,7 +1022,7 @@ default: return 1; } case FR_BUS: //business - switch(toFreq) + switch(toGroup) { case FR_ANN: return maxBusDaysPerYear;; case FR_QTR: return maxBusDaysPerQuarter; @@ -961,7 +1031,7 @@ default: return 1; } case FR_DAY: //daily - switch(toFreq) + switch(toGroup) { case FR_ANN: return maxDaysPerYear;; case FR_QTR: return maxDaysPerQuarter; @@ -970,7 +1040,7 @@ default: return 1; } case FR_HR: //hourly - switch(toFreq) + switch(toGroup) { case FR_ANN: return 24 * maxDaysPerYear;; case FR_QTR: return 24 * maxDaysPerQuarter; @@ -981,7 +1051,7 @@ default: return 1; } case FR_MIN: //minutely - switch(toFreq) + switch(toGroup) { case FR_ANN: return 24 * 60 * maxDaysPerYear;; case FR_QTR: return 24 * 60 * maxDaysPerQuarter; @@ -993,7 +1063,7 @@ default: return 1; } case FR_SEC: //minutely - switch(toFreq) + switch(toGroup) { case FR_ANN: return 24 * 60 * 60 * maxDaysPerYear;; case FR_QTR: return 24 * 60 * 60 * maxDaysPerQuarter; @@ -1009,7 +1079,30 @@ } } +static void *get_asfreq_info(int fromFreq, int toFreq, struct asfreq_info *af_info) { + int maxBusDaysPerYear, maxBusDaysPerQuarter, maxBusDaysPerMonth; + int maxDaysPerYear, maxDaysPerQuarter, maxDaysPerMonth; + + int fromGroup = (fromFreq/1000)*1000; + int toGroup = (toFreq/1000)*1000; + + switch(fromGroup) + { + case FR_WK: { + af_info->from_week_end = fromFreq - fromGroup; + } break; + } + + switch(toGroup) + { + case FR_WK: { + af_info->to_week_end = toFreq - toGroup; + } break; + } + +} + static char cseries_convert_doc[] = ""; static PyObject * cseries_convert(PyObject *self, PyObject *args) @@ -1032,12 +1125,13 @@ char *position; int fromFreq, toFreq; char relation; + struct asfreq_info af_info; PyObject *val, *valMask; - long (*asfreq_main)(long, char) = NULL; - long (*asfreq_endpoints)(long, char) = NULL; - long (*asfreq_reverse)(long, char) = NULL; + long (*asfreq_main)(long, char, struct asfreq_info) = NULL; + long (*asfreq_endpoints)(long, char, struct asfreq_info) = NULL; + long (*asfreq_reverse)(long, char, struct asfreq_info) = NULL; returnVal = PyDict_New(); @@ -1069,20 +1163,22 @@ break; } + get_asfreq_info(fromFreq, toFreq, &af_info); + asfreq_main = get_asfreq_func(fromFreq, toFreq, 1); asfreq_endpoints = get_asfreq_func(fromFreq, toFreq, 0); //convert start index to new frequency - CHECK_ASFREQ(newStartTemp = asfreq_main(startIndex, 'B')); + CHECK_ASFREQ(newStartTemp = asfreq_main(startIndex, 'B', af_info)); if (newStartTemp < 1) { - CHECK_ASFREQ(newStart = asfreq_endpoints(startIndex, 'A')); + CHECK_ASFREQ(newStart = asfreq_endpoints(startIndex, 'A', af_info)); } else { newStart = newStartTemp; } //convert end index to new frequency - CHECK_ASFREQ(newEndTemp = asfreq_main(startIndex+array->dimensions[0]-1, 'A')); + CHECK_ASFREQ(newEndTemp = asfreq_main(startIndex+array->dimensions[0]-1, 'A', af_info)); if (newEndTemp < 1) { - CHECK_ASFREQ(newEnd = asfreq_endpoints(startIndex+array->dimensions[0]-1, 'B')); + CHECK_ASFREQ(newEnd = asfreq_endpoints(startIndex+array->dimensions[0]-1, 'B', af_info)); } else { newEnd = newEndTemp; } @@ -1097,7 +1193,7 @@ if (newHeight > 1) { long tempval; asfreq_reverse = get_asfreq_func(toFreq, fromFreq, 0); - CHECK_ASFREQ(tempval = asfreq_reverse(newStart, 'B')); + CHECK_ASFREQ(tempval = asfreq_reverse(newStart, 'B', af_info)); currPerLen = startIndex - tempval; nd = 2; @@ -1129,7 +1225,7 @@ val = PyArray_GETITEM(array, PyArray_GetPtr(array, &i)); valMask = PyArray_GETITEM(mask, PyArray_GetPtr(mask, &i)); - CHECK_ASFREQ(currIndex = asfreq_main(startIndex + i, relation)); + CHECK_ASFREQ(currIndex = asfreq_main(startIndex + i, relation, af_info)); newIdx[0] = currIndex-newStart; if (newHeight > 1) { @@ -1179,10 +1275,13 @@ char *relation; int fromFreq, toFreq; long fromDate, toDate; - long (*asfreq_main)(long, char) = NULL; + long (*asfreq_main)(long, char, struct asfreq_info) = NULL; + struct asfreq_info af_info; if (!PyArg_ParseTuple(args, "Oiis:asfreq(fromDates, fromfreq, tofreq, relation)", &fromDates, &fromFreq, &toFreq, &relation)) return NULL; + get_asfreq_info(fromFreq, toFreq, &af_info); + asfreq_main = get_asfreq_func(fromFreq, toFreq, 0); toDates = (PyArrayObject *)PyArray_Copy(fromDates); @@ -1197,7 +1296,7 @@ fromDateObj = PyArray_GETITEM(fromDates, iterFrom->dataptr); fromDate = PyInt_AsLong(fromDateObj); - CHECK_ASFREQ(toDate = asfreq_main(fromDate, relation[0])); + CHECK_ASFREQ(toDate = asfreq_main(fromDate, relation[0], af_info)); toDateObj = PyInt_FromLong(toDate); PyArray_SETITEM(toDates, iterTo->dataptr, toDateObj); @@ -1269,8 +1368,9 @@ long absdate; double abstime; - long (*toDaily)(long, char) = NULL; + long (*toDaily)(long, char, struct asfreq_info) = NULL; int (*getDateInfo)(struct date_info) = NULL; + struct asfreq_info af_info; if (!PyArg_ParseTuple(args, "Ois:getDateInfo(array, freq, info)", &array, &freq, &info)) return NULL; newArray = (PyArrayObject *)PyArray_Copy(array); @@ -1279,6 +1379,7 @@ iterResult = (PyArrayIterObject *)PyArray_IterNew((PyObject *)newArray); toDaily = get_asfreq_func(freq, FR_DAY, 0); + get_asfreq_info(freq, FR_DAY, &af_info); switch(*info) { @@ -1321,7 +1422,7 @@ val = PyArray_GETITEM(array, iterSource->dataptr); dateNum = PyInt_AsLong(val); Py_DECREF(val); - CHECK_ASFREQ(absdate = toDaily(dateNum, 'B')); + CHECK_ASFREQ(absdate = toDaily(dateNum, 'B', af_info)); abstime = getAbsTime(freq, absdate, dateNum); if(dInfoCalc_SetFromAbsDateTime(&convDate, absdate, abstime, GREGORIAN_CALENDAR)) return NULL; @@ -1464,7 +1565,16 @@ ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANN", FR_ANN); ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_QTR", FR_QTR); ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_MTH", FR_MTH); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WK", FR_WK); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKSUN", FR_WKSUN); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKSAT", FR_WKSAT); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKFRI", FR_WKFRI); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKTHU", FR_WKTHU); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKWED", FR_WKWED); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKTUE", FR_WKTUE); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKMON", FR_WKMON); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_BUS", FR_BUS); ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_DAY", FR_DAY); ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_HR", FR_HR); From scipy-svn at scipy.org Mon Mar 5 16:59:22 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 Mar 2007 15:59:22 -0600 (CST) Subject: [Scipy-svn] r2824 - trunk/Lib/sandbox/timeseries Message-ID: <20070305215922.9C95439C1EB@new.scipy.org> Author: mattknox_ca Date: 2007-03-05 15:59:19 -0600 (Mon, 05 Mar 2007) New Revision: 2824 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: added support for different weekly frequencies Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-05 21:58:53 UTC (rev 2823) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-05 21:59:19 UTC (rev 2824) @@ -118,17 +118,19 @@ >>> td.Date('D', datetime=datetime.datetime.now()) """ - default_fmtstr = {'A': "%Y", - 'Q': "%YQ%q", - 'M': "%b-%Y", - 'W': "%d-%b-%Y", - 'B': "%d-%b-%Y", - 'D': "%d-%b-%Y", - 'U': "%d-%b-%Y", - 'H': "%d-%b-%Y %H:00", - 'T': "%d-%b-%Y %H:%M", - 'S': "%d-%b-%Y %H:%M:%S" + default_fmtstr = {_c.FR_ANN: "%Y", + _c.FR_QTR: "%YQ%q", + _c.FR_MTH: "%b-%Y", + _c.FR_WK: "%d-%b-%Y", + _c.FR_BUS: "%d-%b-%Y", + _c.FR_DAY: "%d-%b-%Y", + _c.FR_UND: "%d-%b-%Y", + _c.FR_HR: "%d-%b-%Y %H:00", + _c.FR_MIN: "%d-%b-%Y %H:%M", + _c.FR_SEC: "%d-%b-%Y %H:%M:%S" } + + for x in range(7): default_fmtstr[_c.FR_WK+x] = default_fmtstr[_c.FR_WK] def __init__(self, freq, value=None, string=None, year=None, month=None, day=None, quarter=None, @@ -141,6 +143,7 @@ self.freq = corelib.check_freq(freq) self.freqstr = corelib.freq_tostr(self.freq) + _freqGroup = get_freq_group(self.freq) if value is not None: if isinstance(value, ndarray): @@ -165,9 +168,11 @@ elif self.freq == _c.FR_BUS: valtmp = (value - 1)//5 self.datetime = dt.datetime.fromordinal(value + valtmp*2) - elif self.freq == _c.FR_WK: + elif _freqGroup == _c.FR_WK: + """value=1 must correspond to first FULL week in the year 0001 + ending on the given day of the week""" self.datetime = dt.datetime(1,1,7) + \ - dt.timedelta(days=(value-1)*7) + dt.timedelta(days=(value-1)*7 + (self.freq - _c.FR_WK)) elif self.freq == _c.FR_MTH: year = (value - 1)//12 + 1 month = value - (year - 1)*12 @@ -196,7 +201,7 @@ # First, some basic checks..... if year is None: raise InsufficientDateError - if self.freq in (_c.FR_BUS, _c.FR_DAY, _c.FR_WK, _c.FR_UND): + if _freqGroup in (_c.FR_BUS, _c.FR_DAY, _c.FR_WK, _c.FR_UND): if month is None or day is None: raise InsufficientDateError elif self.freq == _c.FR_MTH: @@ -215,7 +220,7 @@ if month is None or day is None or second is None: raise InsufficientDateError - if self.freq in (_c.FR_BUS, _c.FR_DAY, _c.FR_WK, + if _freqGroup in (_c.FR_BUS, _c.FR_DAY, _c.FR_WK, _c.FR_MTH, _c.FR_QTR, _c.FR_ANN): self.datetime = truncateDate(self.freq, dt.datetime(year, month, day)) if self.freq == _c.FR_BUS: @@ -239,7 +244,7 @@ second = 0 else: second = second % 60 - self.datetime = truncateDate(self.freqstr, + self.datetime = truncateDate(self.freq, dt.datetime(year, month, day, hour, minute, second)) else: @@ -342,6 +347,7 @@ def __value(self): "Converts the date to an integer, depending on the current frequency." + _freqGroup = get_freq_group(self.freq) # Secondly...... if self.freq == _c.FR_SEC: delta = (self.datetime - secondlyOriginDate) @@ -369,7 +375,7 @@ weeks = days // 7 val = days - weeks*2 # Weekly........ - elif self.freq == _c.FR_WK: + elif _freqGroup == _c.FR_WK: val = self.datetime.toordinal()//7 # Monthly....... elif self.freq == _c.FR_MTH: @@ -386,13 +392,13 @@ def strfmt(self, fmt): "Formats the date" if fmt is None: - fmt = self.default_fmtstr[self.freqstr] + fmt = self.default_fmtstr[self.freq] if self.freq == _c.FR_UND: return str(self.value) return cseries.strfmt(self.datetime, fmt) def __str__(self): - return self.strfmt(self.default_fmtstr[self.freqstr]) + return self.strfmt(self.default_fmtstr[self.freq]) def __repr__(self): return "<%s : %s>" % (str(self.freqstr), str(self)) @@ -428,6 +434,10 @@ #---- --- Functions --- #####--------------------------------------------------------------------------- +def get_freq_group(freq): + # truncate frequency to nearest thousand + return (freq//1000)*1000 + def mx_to_datetime(mxDate): microsecond = 1000000*(mxDate.second % 1) return dt.datetime(mxDate.year, mxDate.month, @@ -439,6 +449,7 @@ def truncateDate(freq, datetime): "Chops off the irrelevant information from the datetime object passed in." freq = corelib.check_freq(freq) + _freqGroup = get_freq_group(freq) if freq == _c.FR_MIN: return dt.datetime(datetime.year, datetime.month, datetime.day, \ datetime.hour, datetime.minute) @@ -449,9 +460,10 @@ if freq == _c.FR_BUS and datetime.isoweekday() in (6,7): raise ValueError("Weekend passed as business day") return dt.datetime(datetime.year, datetime.month, datetime.day) - elif freq == _c.FR_WK: + elif _freqGroup == _c.FR_WK: d = datetime.toordinal() - return dt.datetime.fromordinal(d + (7 - d % 7) % 7) + day_adj = (7 - (freq - _c.FR_WK)) % 7 + return dt.datetime.fromordinal(d + ((7 - day_adj) - d % 7) % 7) elif freq == _c.FR_MTH: return dt.datetime(datetime.year, datetime.month, 1) elif freq == _c.FR_QTR: @@ -469,20 +481,12 @@ def thisday(freq): "Returns today's date, at the given frequency `freq`." freq = corelib.check_freq(freq) + _freqGroup = get_freq_group(freq) tempDate = dt.datetime.now() # if it is Saturday or Sunday currently, freq==B, then we want to use Friday if freq == _c.FR_BUS and tempDate.isoweekday() >= 6: tempDate = tempDate - dt.timedelta(days=(tempDate.isoweekday() - 5)) - if freq in (_c.FR_BUS,_c.FR_DAY, - _c.FR_HR,_c.FR_SEC,_c.FR_MIN, - _c.FR_WK,_c.FR_UND): - return Date(freq, datetime=tempDate) - elif freq == _c.FR_MTH: - return Date(freq, year=tempDate.year, month=tempDate.month) - elif freq == _c.FR_QTR: - return Date(freq, year=tempDate.year, quarter=monthToQuarter(tempDate.month)) - elif freq == _c.FR_ANN: - return Date(freq, year=tempDate.year) + return Date(freq=freq, datetime=tempDate) today = thisday def prevbusday(day_end_hour=18, day_end_min=0): @@ -599,7 +603,7 @@ def __new__(cls, dates=None, freq=None, copy=False): # Get the frequency ...... if freq is None: - _freq = getattr(dates, 'freq', -9999) + _freq = getattr(dates, 'freq', _c.FR_UND) else: _freq = corelib.check_freq(freq) cls._defaultfreq = corelib.check_freq(_freq) @@ -618,7 +622,7 @@ raise ArithmeticDateError, "(function %s)" % context[0].__name__ def __array_finalize__(self, obj): - self.freq = getattr(obj, 'freq', -9999) + self.freq = getattr(obj, 'freq', _c.FR_UND) self._cachedinfo = dict(toobj=None, tostr=None, toord=None, steps=None, full=None, hasdups=None) if hasattr(obj,'_cachedinfo'): From scipy-svn at scipy.org Mon Mar 5 17:00:11 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 Mar 2007 16:00:11 -0600 (CST) Subject: [Scipy-svn] r2825 - trunk/Lib/sandbox/timeseries Message-ID: <20070305220011.6697F39C1DC@new.scipy.org> Author: mattknox_ca Date: 2007-03-05 16:00:08 -0600 (Mon, 05 Mar 2007) New Revision: 2825 Modified: trunk/Lib/sandbox/timeseries/tcore.py Log: added support for extra weekly frequencies Modified: trunk/Lib/sandbox/timeseries/tcore.py =================================================================== --- trunk/Lib/sandbox/timeseries/tcore.py 2007-03-05 21:59:19 UTC (rev 2824) +++ trunk/Lib/sandbox/timeseries/tcore.py 2007-03-05 22:00:08 UTC (rev 2825) @@ -88,12 +88,25 @@ else: raise ValueError("Invalid value for observed attribute: %s " % str(obStr)) +_weekly_prefixes = ['W','WEEK','WEEKLY'] +_week_end_map = { + FR_WKSUN:'SUNDAY', + FR_WKSAT:'SATURDAY', + FR_WKFRI:'FRIDAY', + FR_WKTHU:'THURSDAY', + FR_WKWED:'WEDNESDAY', + FR_WKTUE:'TUESDAY', + FR_WKMON:'MONDAY'} +def _gen_weekly_strs(day): + result = [] + for pr in _weekly_prefixes: + result += [pr+'-'+day_str for day_str in (day[:3], day)] + return result freq_dict = { FR_ANN: ['A','Y','ANNUAL','ANNUALLY','YEAR','YEARLY'], FR_QTR: ['Q','QUARTER','QUARTERLY',], FR_MTH: ['M','MONTH','MONTHLY',], - FR_WK: ['W','WEEK','WEEKLY',], FR_BUS: ['B','BUSINESS','BUSINESSLY'], FR_DAY: ['D','DAY','DAILY',], FR_HR: ['H','HOUR','HOURLY',], @@ -101,6 +114,11 @@ FR_SEC: ['S','SECOND','SECONDLY',], FR_UND: ['U','UNDEF','UNDEFINED'], } + +for _freq, day_str in _week_end_map.iteritems(): + freq_dict[_freq] = _gen_weekly_strs(day_str) +freq_dict[FR_WK] += _weekly_prefixes + freq_revdict = reverse_dict(freq_dict) def freq_fromstr(freq_asstr): From scipy-svn at scipy.org Mon Mar 5 17:00:42 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 Mar 2007 16:00:42 -0600 (CST) Subject: [Scipy-svn] r2826 - trunk/Lib/sandbox/timeseries Message-ID: <20070305220042.D723739C1EC@new.scipy.org> Author: mattknox_ca Date: 2007-03-05 16:00:39 -0600 (Mon, 05 Mar 2007) New Revision: 2826 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: fixed typo in mask_period Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-03-05 22:00:08 UTC (rev 2825) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-03-05 22:00:39 UTC (rev 2826) @@ -955,7 +955,7 @@ raise ValueError,"Data should be a valid TimeSeries!" dates = data._dates if dates.ndim == 1: - dates_lims = dates[[0,-1]] + dates_lim = dates[[0,-1]] else: dates_lim = dates.ravel()[[0,-1]] # Check the period ..................... From scipy-svn at scipy.org Mon Mar 5 21:10:05 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 5 Mar 2007 20:10:05 -0600 (CST) Subject: [Scipy-svn] r2827 - trunk/Lib/sandbox/timeseries Message-ID: <20070306021005.9B2FD39C131@new.scipy.org> Author: pierregm Date: 2007-03-05 20:10:02 -0600 (Mon, 05 Mar 2007) New Revision: 2827 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: tseries : mask_period : fixed a problem with the keywords order. Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-03-05 22:00:39 UTC (rev 2826) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-03-06 02:10:02 UTC (rev 2827) @@ -955,22 +955,25 @@ raise ValueError,"Data should be a valid TimeSeries!" dates = data._dates if dates.ndim == 1: - dates_lim = dates[[0,-1]] + dates_lims = dates[[0,-1]] else: - dates_lim = dates.ravel()[[0,-1]] + dates_lims = dates.ravel()[[0,-1]] # Check the period ..................... - if period is not None and isinstance(period, (tuple, list, ndarray)): - (start_date, end_date) = (period[0], period[-1]) + if period is not None: + if isinstance(period, (tuple, list, ndarray)): + (start_date, end_date) = (period[0], period[-1]) + else: + (start_date, end_date) = (period, start_date) # Check the starting date .............. if start_date is None: - start_date = dates_lim[0] + start_date = dates_lims[0] elif isinstance(start_date, str): start_date = Date(data.freq, string=start_date) elif not isinstance(start_date, Date): raise DateError,"Starting date should be a valid Date object!" # Check the ending date ................ if end_date is None: - end_date = dates_lim[-1] + end_date = dates_lims[-1] elif isinstance(end_date, str): end_date = Date(data.freq, string=end_date) elif not isinstance(end_date, Date): From scipy-svn at scipy.org Tue Mar 6 16:02:58 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 Mar 2007 15:02:58 -0600 (CST) Subject: [Scipy-svn] r2828 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070306210258.D3A6B39C1E1@new.scipy.org> Author: mattknox_ca Date: 2007-03-06 15:02:54 -0600 (Tue, 06 Mar 2007) New Revision: 2828 Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py Log: changed one "assert" statement to "assert_equal" Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-03-06 02:10:02 UTC (rev 2827) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-03-06 21:02:54 UTC (rev 2828) @@ -110,7 +110,7 @@ print freqs for f in freqs: today = tdates.thisday(f) - assert(tdates.Date(freq=f, value=today.value) == today) + assert_equal(tdates.Date(freq=f, value=today.value), today) def test_shortcuts(self): "Tests some creation shortcuts. Because I'm lazy like that." From scipy-svn at scipy.org Tue Mar 6 16:09:37 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 Mar 2007 15:09:37 -0600 (CST) Subject: [Scipy-svn] r2829 - trunk/Lib/sandbox/timeseries Message-ID: <20070306210937.E91FE39C1EA@new.scipy.org> Author: mattknox_ca Date: 2007-03-06 15:09:33 -0600 (Tue, 06 Mar 2007) New Revision: 2829 Modified: trunk/Lib/sandbox/timeseries/reportlib.py Log: fixed problem with reporting multi dimensional series Modified: trunk/Lib/sandbox/timeseries/reportlib.py =================================================================== --- trunk/Lib/sandbox/timeseries/reportlib.py 2007-03-06 21:02:54 UTC (rev 2828) +++ trunk/Lib/sandbox/timeseries/reportlib.py 2007-03-06 21:09:33 UTC (rev 2829) @@ -83,7 +83,7 @@ def __call__ (self, item): "Execute the call behavior." - if hasattr(item, "_mask") and item._mask: + if hasattr(item, "_mask") and isinstance(item._mask, bool) and item._mask: return self.mr else: return self.f(item) From scipy-svn at scipy.org Tue Mar 6 16:10:26 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 Mar 2007 15:10:26 -0600 (CST) Subject: [Scipy-svn] r2830 - trunk/Lib/sandbox/timeseries Message-ID: <20070306211026.CC6E739C1EA@new.scipy.org> Author: mattknox_ca Date: 2007-03-06 15:10:23 -0600 (Tue, 06 Mar 2007) New Revision: 2830 Modified: trunk/Lib/sandbox/timeseries/tcore.py Log: added support for new annual frequencies Modified: trunk/Lib/sandbox/timeseries/tcore.py =================================================================== --- trunk/Lib/sandbox/timeseries/tcore.py 2007-03-06 21:09:33 UTC (rev 2829) +++ trunk/Lib/sandbox/timeseries/tcore.py 2007-03-06 21:10:23 UTC (rev 2830) @@ -104,8 +104,31 @@ result += [pr+'-'+day_str for day_str in (day[:3], day)] return result -freq_dict = { FR_ANN: ['A','Y','ANNUAL','ANNUALLY','YEAR','YEARLY'], - FR_QTR: ['Q','QUARTER','QUARTERLY',], +_annual_prefixes = ['A','Y','ANNUAL','ANNUALLY','YEAR','YEARLY'] +_year_end_map = { + FR_ANNJAN:'JANUARY', + FR_ANNFEB:'FEBRUARY', + FR_ANNMAR:'MARCH', + FR_ANNAPR:'APRIL', + FR_ANNMAY:'MAY', + FR_ANNJUN:'JUNE', + FR_ANNJUL:'JULY', + FR_ANNAUG:'AUGUST', + FR_ANNSEP:'SEPTEMBER', + FR_ANNOCT:'OCTOBER', + FR_ANNNOV:'NOVEMBER', + FR_ANNDEC:'DECEMBER' + } + +def _gen_annual_strs(month): + result = [] + for pr in _annual_prefixes: + result += [pr+'-'+mth_str for mth_str in (month[:3], month)] + return result + + + +freq_dict = { FR_QTR: ['Q','QUARTER','QUARTERLY',], FR_MTH: ['M','MONTH','MONTHLY',], FR_BUS: ['B','BUSINESS','BUSINESSLY'], FR_DAY: ['D','DAY','DAILY',], @@ -118,7 +141,11 @@ for _freq, day_str in _week_end_map.iteritems(): freq_dict[_freq] = _gen_weekly_strs(day_str) freq_dict[FR_WK] += _weekly_prefixes - + +for _freq, mth_str in _year_end_map.iteritems(): + freq_dict[_freq] = _gen_annual_strs(mth_str) +freq_dict[FR_ANN] += _annual_prefixes + freq_revdict = reverse_dict(freq_dict) def freq_fromstr(freq_asstr): From scipy-svn at scipy.org Tue Mar 6 16:15:27 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 Mar 2007 15:15:27 -0600 (CST) Subject: [Scipy-svn] r2831 - trunk/Lib/sandbox/timeseries Message-ID: <20070306211527.78A1F39C1EE@new.scipy.org> Author: mattknox_ca Date: 2007-03-06 15:15:18 -0600 (Tue, 06 Mar 2007) New Revision: 2831 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: added support for new annual frequencies Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-06 21:10:23 UTC (rev 2830) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-06 21:15:18 UTC (rev 2831) @@ -131,6 +131,7 @@ } for x in range(7): default_fmtstr[_c.FR_WK+x] = default_fmtstr[_c.FR_WK] + for x in range(12): default_fmtstr[_c.FR_ANN+x] = default_fmtstr[_c.FR_ANN] def __init__(self, freq, value=None, string=None, year=None, month=None, day=None, quarter=None, @@ -145,17 +146,17 @@ _freqGroup = get_freq_group(self.freq) - if value is not None: - if isinstance(value, ndarray): - value = int(value) + if isinstance(value, str): + if self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): + self.datetime = DateTimeFromString(value) + else: + self.datetime = DateFromString(value) + elif value is not None: - if isinstance(value, str): - if self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): - self.datetime = DateTimeFromString(value) - else: - self.datetime = DateFromString(value) + #value could be a numpy scalar, which is not acceptable + value = int(value) - elif self.freq == _c.FR_SEC: + if self.freq == _c.FR_SEC: self.datetime = secondlyOriginDate + dt.timedelta(seconds=value) elif self.freq == _c.FR_MIN: self.datetime = minutelyOriginDate + dt.timedelta(minutes=value) @@ -181,8 +182,11 @@ year = (value - 1)//4 + 1 month = (value - (year - 1)*4)*3 self.datetime = dt.datetime(year, month, 1) - elif self.freq == _c.FR_ANN: - self.datetime = dt.datetime(value, 1, 1) + elif _freqGroup == _c.FR_ANN: + if self.freq == _c.FR_ANNDEC: + self.datetime = dt.datetime(value, 12, 1) + else: + self.datetime = dt.datetime(value, self.freq - _c.FR_ANN, 1) else: raise ValueError("unrecognized frequency: "+str(self.freq)) @@ -213,8 +217,9 @@ raise InsufficientDateError month = quarter * 3 day = 1 - elif self.freq == _c.FR_ANN: - month = 1 + elif _freqGroup == _c.FR_ANN: + month = self.freq - _freqGroup + if month == 0: month = 12 day = 1 elif self.freq == _c.FR_SEC: if month is None or day is None or second is None: @@ -384,7 +389,7 @@ elif self.freq == _c.FR_QTR: val = (self.datetime.year-1)*4 + self.datetime.month//3 # Annual ....... - elif self.freq == _c.FR_ANN: + elif _freqGroup == _c.FR_ANN: val = self.datetime.year return int(val) @@ -468,8 +473,16 @@ return dt.datetime(datetime.year, datetime.month, 1) elif freq == _c.FR_QTR: return dt.datetime(datetime.year, monthToQuarter(datetime.month)*3, 1) - elif freq == _c.FR_ANN: - return dt.datetime(datetime.year, 1, 1) + elif _freqGroup == _c.FR_ANN: + + if freq == _c.FR_ANNDEC: fr_month = 12 + else: fr_month = freq - _c.FR_ANN + + if datetime.month <= fr_month: + return dt.datetime(datetime.year, fr_month, 1) + else: + return dt.datetime(datetime.year+1, fr_month, 1) + else: return datetime From scipy-svn at scipy.org Tue Mar 6 16:15:51 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 Mar 2007 15:15:51 -0600 (CST) Subject: [Scipy-svn] r2832 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070306211551.043C239C1EE@new.scipy.org> Author: mattknox_ca Date: 2007-03-06 15:15:46 -0600 (Tue, 06 Mar 2007) New Revision: 2832 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: added support for new annual frequencies Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-06 21:15:18 UTC (rev 2831) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-06 21:15:46 UTC (rev 2832) @@ -9,6 +9,19 @@ static char cseries_doc[] = "Speed sensitive time series operations"; #define FR_ANN 1000 /* Annual */ +#define FR_ANNDEC FR_ANN /* Annual - December year end*/ +#define FR_ANNJAN 1001 /* Annual - January year end*/ +#define FR_ANNFEB 1002 /* Annual - February year end*/ +#define FR_ANNMAR 1003 /* Annual - March year end*/ +#define FR_ANNAPR 1004 /* Annual - April year end*/ +#define FR_ANNMAY 1005 /* Annual - May year end*/ +#define FR_ANNJUN 1006 /* Annual - June year end*/ +#define FR_ANNJUL 1007 /* Annual - July year end*/ +#define FR_ANNAUG 1008 /* Annual - August year end*/ +#define FR_ANNSEP 1009 /* Annual - September year end*/ +#define FR_ANNOCT 1010 /* Annual - October year end*/ +#define FR_ANNNOV 1011 /* Annual - November year end*/ + #define FR_QTR 2000 /* Quarterly */ #define FR_MTH 3000 /* Monthly */ @@ -38,8 +51,12 @@ #define CHECK_ASFREQ(result) if ((result) == DINFO_ERR) return NULL struct asfreq_info{ + int from_week_end; //day the week ends on in the "from" frequency int to_week_end; //day the week ends on in the "to" frequency - int from_week_end; //day the week ends on in the "from" frequency + + int from_a_year_end; //month the year ends on in the "from" frequency + int to_a_year_end; //month the year ends on in the "to" frequency + }; static struct asfreq_info NULL_AF_INFO; @@ -108,25 +125,25 @@ } static -int dInfoCalc_ISOWeek(struct date_info dinfo) +int dInfoCalc_ISOWeek(struct date_info *dinfo) { int week; /* Estimate */ - week = (dinfo.day_of_year-1) - dinfo.day_of_week + 3; + week = (dinfo->day_of_year-1) - dinfo->day_of_week + 3; if (week >= 0) week = week / 7 + 1; /* Verify */ if (week < 0) { /* The day lies in last week of the previous year */ if ((week > -2) || - (week == -2 && dInfoCalc_Leapyear(dinfo.year-1, dinfo.calendar))) + (week == -2 && dInfoCalc_Leapyear(dinfo->year-1, dinfo->calendar))) week = 53; else week = 52; } else if (week == 53) { /* Check if the week belongs to year or year+1 */ - if (31-dinfo.day + dinfo.day_of_week < 3) { + if (31-dinfo->day + dinfo->day_of_week < 3) { week = 1; } } @@ -462,23 +479,25 @@ //************ FROM DAILY *************** -static long asfreq_DtoA(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_DtoA(long fromDate, char relation, struct asfreq_info *af_info) { struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, GREGORIAN_CALENDAR)) return DINFO_ERR; - return (long)(dinfo.year); + if (dinfo.month > af_info->to_a_year_end) { return (long)(dinfo.year + 1); } + else { return (long)(dinfo.year); } } -static long asfreq_DtoQ(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_DtoQ(long fromDate, char relation, struct asfreq_info *af_info) { + struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, GREGORIAN_CALENDAR)) return DINFO_ERR; return (long)((dinfo.year - 1) * 4 + dinfo.quarter); } -static long asfreq_DtoM(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_DtoM(long fromDate, char relation, struct asfreq_info *af_info) { struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, @@ -486,11 +505,11 @@ return (long)((dinfo.year - 1) * 12 + dinfo.month); } -static long asfreq_DtoW(long fromDate, char relation, struct asfreq_info af_info) { - return (fromDate - (1 + af_info.to_week_end))/7 + 1; +static long asfreq_DtoW(long fromDate, char relation, struct asfreq_info *af_info) { + return (fromDate - (1 + af_info->to_week_end))/7 + 1; } -static long asfreq_DtoB(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_DtoB(long fromDate, char relation, struct asfreq_info *af_info) { struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, @@ -503,7 +522,7 @@ } } -static long asfreq_DtoB_forConvert(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_DtoB_forConvert(long fromDate, char relation, struct asfreq_info *af_info) { struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, @@ -517,7 +536,7 @@ } // needed for getDateInfo function -static long asfreq_DtoD(long fromDate, char relation, struct asfreq_info af_info) { return fromDate; } +static long asfreq_DtoD(long fromDate, char relation, struct asfreq_info *af_info) { return fromDate; } static long asfreq_DtoHIGHFREQ(long fromDate, char relation, long periodsPerDay) { if (fromDate >= minval_D_toHighFreq) { @@ -526,128 +545,129 @@ } else { return -1; } } -static long asfreq_DtoH(long fromDate, char relation, struct asfreq_info af_info) +static long asfreq_DtoH(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoHIGHFREQ(fromDate, relation, 24); } -static long asfreq_DtoT(long fromDate, char relation, struct asfreq_info af_info) +static long asfreq_DtoT(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoHIGHFREQ(fromDate, relation, 24*60); } -static long asfreq_DtoS(long fromDate, char relation, struct asfreq_info af_info) +static long asfreq_DtoS(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoHIGHFREQ(fromDate, relation, 24*60*60); } //************ FROM SECONDLY *************** -static long asfreq_StoD(long fromDate, char relation, struct asfreq_info af_info) +static long asfreq_StoD(long fromDate, char relation, struct asfreq_info *af_info) { return (fromDate - 1)/(60*60*24) + minval_D_toHighFreq; } -static long asfreq_StoA(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoA(asfreq_StoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_StoQ(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoQ(asfreq_StoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_StoM(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoM(asfreq_StoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_StoW(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoW(asfreq_StoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } -static long asfreq_StoB(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoB(asfreq_StoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_StoB_forConvert(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoB_forConvert(asfreq_StoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_StoT(long fromDate, char relation, struct asfreq_info af_info) +static long asfreq_StoA(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoA(asfreq_StoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } +static long asfreq_StoQ(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoQ(asfreq_StoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } +static long asfreq_StoM(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoM(asfreq_StoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } +static long asfreq_StoW(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoW(asfreq_StoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } +static long asfreq_StoB(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoB(asfreq_StoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } +static long asfreq_StoB_forConvert(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoB_forConvert(asfreq_StoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } +static long asfreq_StoT(long fromDate, char relation, struct asfreq_info *af_info) { return (fromDate - 1)/60 + 1; } -static long asfreq_StoH(long fromDate, char relation, struct asfreq_info af_info) +static long asfreq_StoH(long fromDate, char relation, struct asfreq_info *af_info) { return (fromDate - 1)/(60*60) + 1; } //************ FROM MINUTELY *************** -static long asfreq_TtoD(long fromDate, char relation, struct asfreq_info af_info) +static long asfreq_TtoD(long fromDate, char relation, struct asfreq_info *af_info) { return (fromDate - 1)/(60*24) + minval_D_toHighFreq; } -static long asfreq_TtoA(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoA(asfreq_TtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_TtoQ(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoQ(asfreq_TtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_TtoM(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoM(asfreq_TtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_TtoW(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoW(asfreq_TtoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } -static long asfreq_TtoB(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoB(asfreq_TtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_TtoA(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoA(asfreq_TtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } +static long asfreq_TtoQ(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoQ(asfreq_TtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } +static long asfreq_TtoM(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoM(asfreq_TtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } +static long asfreq_TtoW(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoW(asfreq_TtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } +static long asfreq_TtoB(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoB(asfreq_TtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } -static long asfreq_TtoB_forConvert(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoB_forConvert(asfreq_TtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_TtoB_forConvert(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoB_forConvert(asfreq_TtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } -static long asfreq_TtoH(long fromDate, char relation, struct asfreq_info af_info) +static long asfreq_TtoH(long fromDate, char relation, struct asfreq_info *af_info) { return (fromDate - 1)/60 + 1; } -static long asfreq_TtoS(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_TtoS(long fromDate, char relation, struct asfreq_info *af_info) { if (relation == 'B') { return fromDate*60 - 59; } else { return fromDate*60; }} //************ FROM HOURLY *************** -static long asfreq_HtoD(long fromDate, char relation, struct asfreq_info af_info) +static long asfreq_HtoD(long fromDate, char relation, struct asfreq_info *af_info) { return (fromDate - 1)/24 + minval_D_toHighFreq; } -static long asfreq_HtoA(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoA(asfreq_HtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_HtoQ(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoQ(asfreq_HtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_HtoM(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoM(asfreq_HtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_HtoW(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoW(asfreq_HtoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } -static long asfreq_HtoB(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoB(asfreq_HtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_HtoA(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoA(asfreq_HtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } +static long asfreq_HtoQ(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoQ(asfreq_HtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } +static long asfreq_HtoM(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoM(asfreq_HtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } +static long asfreq_HtoW(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoW(asfreq_HtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } +static long asfreq_HtoB(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoB(asfreq_HtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } -static long asfreq_HtoB_forConvert(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoB_forConvert(asfreq_HtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_HtoB_forConvert(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoB_forConvert(asfreq_HtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } // calculation works out the same as TtoS, so we just call that function for HtoT -static long asfreq_HtoT(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_TtoS(fromDate, relation, NULL_AF_INFO); } -static long asfreq_HtoS(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_HtoT(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_TtoS(fromDate, relation, &NULL_AF_INFO); } +static long asfreq_HtoS(long fromDate, char relation, struct asfreq_info *af_info) { if (relation == 'B') { return fromDate*60*60 - 60*60 + 1; } else { return fromDate*60*60; }} //************ FROM BUSINESS *************** -static long asfreq_BtoD(long fromDate, char relation, struct asfreq_info af_info) +static long asfreq_BtoD(long fromDate, char relation, struct asfreq_info *af_info) { return ((fromDate-1)/5)*7 + (fromDate-1)%5 + 1; } -static long asfreq_BtoA(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoA(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_BtoA(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoA(asfreq_BtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } -static long asfreq_BtoQ(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoQ(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_BtoQ(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoQ(asfreq_BtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } -static long asfreq_BtoM(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoM(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_BtoM(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoM(asfreq_BtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } -static long asfreq_BtoW(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoW(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } +static long asfreq_BtoW(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoW(asfreq_BtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } -static long asfreq_BtoH(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoH(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_BtoH(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoH(asfreq_BtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } -static long asfreq_BtoT(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoT(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_BtoT(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoT(asfreq_BtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } -static long asfreq_BtoS(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoS(asfreq_BtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_BtoS(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoS(asfreq_BtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } //************ FROM WEEKLY *************** -static long asfreq_WtoD(long fromDate, char relation, struct asfreq_info af_info) { - if (relation == 'B') { return fromDate * 7 - 6 + af_info.from_week_end;} - else { return fromDate * 7 + af_info.from_week_end; }} +static long asfreq_WtoD(long fromDate, char relation, struct asfreq_info *af_info) { + if (relation == 'B') { return fromDate * 7 - 6 + af_info->from_week_end;} + else { return fromDate * 7 + af_info->from_week_end; } +} -static long asfreq_WtoA(long fromDate, char relation, struct asfreq_info af_info) { - return asfreq_DtoA(asfreq_WtoD(fromDate, 'A', af_info), relation, NULL_AF_INFO); } -static long asfreq_WtoQ(long fromDate, char relation, struct asfreq_info af_info) { - return asfreq_DtoQ(asfreq_WtoD(fromDate, 'A', af_info), relation, NULL_AF_INFO); } -static long asfreq_WtoM(long fromDate, char relation, struct asfreq_info af_info) { - return asfreq_DtoM(asfreq_WtoD(fromDate, 'A', af_info), relation, NULL_AF_INFO); } +static long asfreq_WtoA(long fromDate, char relation, struct asfreq_info *af_info) { + return asfreq_DtoA(asfreq_WtoD(fromDate, 'A', af_info), relation, af_info); } +static long asfreq_WtoQ(long fromDate, char relation, struct asfreq_info *af_info) { + return asfreq_DtoQ(asfreq_WtoD(fromDate, 'A', af_info), relation, &NULL_AF_INFO); } +static long asfreq_WtoM(long fromDate, char relation, struct asfreq_info *af_info) { + return asfreq_DtoM(asfreq_WtoD(fromDate, 'A', af_info), relation, &NULL_AF_INFO); } -static long asfreq_WtoW(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoW(asfreq_WtoD(fromDate, relation, af_info), relation, NULL_AF_INFO); } +static long asfreq_WtoW(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoW(asfreq_WtoD(fromDate, relation, af_info), relation, &NULL_AF_INFO); } -static long asfreq_WtoB(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_WtoB(long fromDate, char relation, struct asfreq_info *af_info) { struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_WtoD(fromDate, relation, af_info), @@ -657,12 +677,12 @@ else { return DtoB_WeekendToFriday(dinfo); } } -static long asfreq_WtoH(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoH(asfreq_WtoD(fromDate, relation, af_info), relation, NULL_AF_INFO); } -static long asfreq_WtoT(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoT(asfreq_WtoD(fromDate, relation, af_info), relation, NULL_AF_INFO); } -static long asfreq_WtoS(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoS(asfreq_WtoD(fromDate, relation, af_info), relation, NULL_AF_INFO); } +static long asfreq_WtoH(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoH(asfreq_WtoD(fromDate, relation, af_info), relation, &NULL_AF_INFO); } +static long asfreq_WtoT(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoT(asfreq_WtoD(fromDate, relation, af_info), relation, &NULL_AF_INFO); } +static long asfreq_WtoS(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoS(asfreq_WtoD(fromDate, relation, af_info), relation, &NULL_AF_INFO); } //************ FROM MONTHLY *************** @@ -671,7 +691,7 @@ *m = fromDate - 12 * (*y) - 1; } -static long asfreq_MtoD(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_MtoD(long fromDate, char relation, struct asfreq_info *af_info) { long y, m, absdate; @@ -686,30 +706,35 @@ } } -static long asfreq_MtoA(long fromDate, char relation, struct asfreq_info af_info) - { return (fromDate - 1) / 12 + 1; } -static long asfreq_MtoQ(long fromDate, char relation, struct asfreq_info af_info) +static long asfreq_MtoA(long fromDate, char relation, struct asfreq_info *af_info) { + long year = (fromDate - 1) / 12 + 1; + long month = fromDate - (year - 1)*12; + if (month > af_info->to_a_year_end) { return year + 1; } + else { return year; } +} + +static long asfreq_MtoQ(long fromDate, char relation, struct asfreq_info *af_info) { return (fromDate - 1) / 3 + 1; } -static long asfreq_MtoW(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoW(asfreq_MtoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } +static long asfreq_MtoW(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoW(asfreq_MtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } -static long asfreq_MtoB(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_MtoB(long fromDate, char relation, struct asfreq_info *af_info) { struct date_info dinfo; - if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_MtoD(fromDate, relation, NULL_AF_INFO), + if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_MtoD(fromDate, relation, &NULL_AF_INFO), GREGORIAN_CALENDAR)) return DINFO_ERR; if (relation == 'B') { return DtoB_WeekendToMonday(dinfo); } else { return DtoB_WeekendToFriday(dinfo); } } -static long asfreq_MtoH(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoH(asfreq_MtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_MtoT(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoT(asfreq_MtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_MtoS(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoS(asfreq_MtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_MtoH(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoH(asfreq_MtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } +static long asfreq_MtoT(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoT(asfreq_MtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } +static long asfreq_MtoS(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoS(asfreq_MtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } //************ FROM QUARTERLY *************** @@ -718,7 +743,7 @@ *m = (fromDate + 4) * 3 - 12 * (*y) - 2; } -static long asfreq_QtoD(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_QtoD(long fromDate, char relation, struct asfreq_info *af_info) { long y, m, absdate; @@ -733,21 +758,25 @@ } } -static long asfreq_QtoA(long fromDate, char relation, struct asfreq_info af_info) - { return (fromDate - 1)/ 4 + 1; } +static long asfreq_QtoA(long fromDate, char relation, struct asfreq_info *af_info) { + long year = (fromDate - 1) / 4 + 1; + long quarter = fromDate - (year - 1)*4; + if (quarter > af_info->to_a_year_end) { return year + 1; } + else { return year; } +} -static long asfreq_QtoM(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_QtoM(long fromDate, char relation, struct asfreq_info *af_info) { if (relation == 'B') { return fromDate * 3 - 2; } else { return fromDate * 3; } } -static long asfreq_QtoW(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoW(asfreq_QtoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } +static long asfreq_QtoW(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoW(asfreq_QtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } -static long asfreq_QtoB(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_QtoB(long fromDate, char relation, struct asfreq_info *af_info) { struct date_info dinfo; - if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_QtoD(fromDate, relation, NULL_AF_INFO), + if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_QtoD(fromDate, relation, &NULL_AF_INFO), GREGORIAN_CALENDAR)) return DINFO_ERR; if (relation == 'B') { return DtoB_WeekendToMonday(dinfo); } @@ -755,54 +784,80 @@ } -static long asfreq_QtoH(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoH(asfreq_QtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_QtoT(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoT(asfreq_QtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_QtoS(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoS(asfreq_QtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_QtoH(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoH(asfreq_QtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } +static long asfreq_QtoT(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoT(asfreq_QtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } +static long asfreq_QtoS(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoS(asfreq_QtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } //************ FROM ANNUAL *************** -static long asfreq_AtoD(long fromDate, char relation, struct asfreq_info af_info) { - long absdate; +static long asfreq_AtoD(long fromDate, char relation, struct asfreq_info *af_info) { + long absdate, year, final_adj; + int month = (af_info->from_a_year_end + 1) % 12; + if (relation == 'B') { - if ((absdate = absdate_from_ymd(fromDate,1,1)) == DINFO_ERR) return DINFO_ERR; - return absdate; + if (af_info->from_a_year_end == 12) {year = fromDate;} + else {year = fromDate - 1;} + final_adj = 0; } else { - if ((absdate = absdate_from_ymd(fromDate+1,1,1)) == DINFO_ERR) return DINFO_ERR; - return absdate - 1; + if (af_info->from_a_year_end == 12) {year = fromDate+1;} + else {year = fromDate;} + final_adj = -1; } + absdate = absdate_from_ymd(year, month, 1); + if (absdate == DINFO_ERR) return DINFO_ERR; + return absdate + final_adj; } -static long asfreq_AtoQ(long fromDate, char relation, struct asfreq_info af_info) { - if (relation == 'B') { return fromDate * 4 - 3; } - else { return fromDate * 4; } +static long asfreq_AtoQ(long fromDate, char relation, struct asfreq_info *af_info) { + + long quarter = asfreq_MtoQ(af_info->from_a_year_end, 'B', &NULL_AF_INFO); + + if (relation == 'B') { + return fromDate * 4 - 3 - (4 - quarter); + } else { + return fromDate * 4 - (4 - quarter); + } } -static long asfreq_AtoM(long fromDate, char relation, struct asfreq_info af_info) { - if (relation == 'B') { return fromDate * 12 - 11; } - else { return fromDate * 12; } +static long asfreq_AtoM(long fromDate, char relation, struct asfreq_info *af_info) { + if (relation == 'B') { + return fromDate * 12 - 11 - (12 - af_info->from_a_year_end); + } else { + return fromDate * 12 - (12 - af_info->from_a_year_end); + } } -static long asfreq_AtoW(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoW(asfreq_AtoD(fromDate, relation, NULL_AF_INFO), relation, af_info); } +static long asfreq_AtoW(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoW(asfreq_AtoD(fromDate, relation, af_info), relation, af_info); } -static long asfreq_AtoB(long fromDate, char relation, struct asfreq_info af_info) { +static long asfreq_AtoB(long fromDate, char relation, struct asfreq_info *af_info) { + long absdate, year; + int month = (af_info->from_a_year_end + 1) % 12; + struct date_info dailyDate; if (relation == 'B') { + + if (af_info->from_a_year_end == 12) {year = fromDate;} + else {year = fromDate - 1;} + if (dInfoCalc_SetFromDateAndTime(&dailyDate, - fromDate,1,1, 0, 0, 0, + year,month,1, 0, 0, 0, GREGORIAN_CALENDAR)) return DINFO_ERR; return DtoB_WeekendToMonday(dailyDate); } else { long absdate; + if (af_info->from_a_year_end == 12) {year = fromDate+1;} + else {year = fromDate;} + if (dInfoCalc_SetFromDateAndTime(&dailyDate, - fromDate+1,1,1, 0, 0, 0, + year,month,1, 0, 0, 0, GREGORIAN_CALENDAR)) return DINFO_ERR; absdate = dailyDate.absdate - 1; @@ -815,20 +870,19 @@ } } -static long asfreq_AtoH(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoH(asfreq_AtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_AtoT(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoT(asfreq_AtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } -static long asfreq_AtoS(long fromDate, char relation, struct asfreq_info af_info) - { return asfreq_DtoS(asfreq_AtoD(fromDate, relation, NULL_AF_INFO), relation, NULL_AF_INFO); } +static long asfreq_AtoH(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoH(asfreq_AtoD(fromDate, relation, af_info), relation, &NULL_AF_INFO); } +static long asfreq_AtoT(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoT(asfreq_AtoD(fromDate, relation, af_info), relation, &NULL_AF_INFO); } +static long asfreq_AtoS(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoS(asfreq_AtoD(fromDate, relation, af_info), relation, &NULL_AF_INFO); } +static long nofunc(long fromDate, char relation, struct asfreq_info *af_info) { return -1; } -static long nofunc(long fromDate, char relation, struct asfreq_info af_info) { return -1; } - // end of frequency specific conversion routines // return a pointer to appropriate conversion function -static long (*get_asfreq_func(int fromFreq, int toFreq, int forConvert))(long, char, struct asfreq_info) { +static long (*get_asfreq_func(int fromFreq, int toFreq, int forConvert))(long, char, struct asfreq_info*) { int fromGroup = (fromFreq/1000)*1000; int toGroup = (toFreq/1000)*1000; @@ -1079,26 +1133,39 @@ } } -static void *get_asfreq_info(int fromFreq, int toFreq, struct asfreq_info *af_info) { +static int calc_a_year_end(int freq, int group) { + int result = freq - group; + if (result == 0) {return 12;} + else {return result;} +} - int maxBusDaysPerYear, maxBusDaysPerQuarter, maxBusDaysPerMonth; - int maxDaysPerYear, maxDaysPerQuarter, maxDaysPerMonth; +static int calc_week_end(int freq, int group) { + return freq - group; +} +static void get_asfreq_info(int fromFreq, int toFreq, struct asfreq_info *af_info) { + int fromGroup = (fromFreq/1000)*1000; int toGroup = (toFreq/1000)*1000; switch(fromGroup) { case FR_WK: { - af_info->from_week_end = fromFreq - fromGroup; + af_info->from_week_end = calc_week_end(fromFreq, fromGroup); } break; + case FR_ANN: { + af_info->from_a_year_end = calc_a_year_end(fromFreq, fromGroup); + } break; } switch(toGroup) { case FR_WK: { - af_info->to_week_end = toFreq - toGroup; + af_info->to_week_end = calc_week_end(toFreq, toGroup); } break; + case FR_ANN: { + af_info->to_a_year_end = calc_a_year_end(toFreq, toGroup); + } break; } } @@ -1129,9 +1196,9 @@ PyObject *val, *valMask; - long (*asfreq_main)(long, char, struct asfreq_info) = NULL; - long (*asfreq_endpoints)(long, char, struct asfreq_info) = NULL; - long (*asfreq_reverse)(long, char, struct asfreq_info) = NULL; + long (*asfreq_main)(long, char, struct asfreq_info*) = NULL; + long (*asfreq_endpoints)(long, char, struct asfreq_info*) = NULL; + long (*asfreq_reverse)(long, char, struct asfreq_info*) = NULL; returnVal = PyDict_New(); @@ -1169,16 +1236,16 @@ asfreq_endpoints = get_asfreq_func(fromFreq, toFreq, 0); //convert start index to new frequency - CHECK_ASFREQ(newStartTemp = asfreq_main(startIndex, 'B', af_info)); + CHECK_ASFREQ(newStartTemp = asfreq_main(startIndex, 'B', &af_info)); if (newStartTemp < 1) { - CHECK_ASFREQ(newStart = asfreq_endpoints(startIndex, 'A', af_info)); + CHECK_ASFREQ(newStart = asfreq_endpoints(startIndex, 'A', &af_info)); } else { newStart = newStartTemp; } //convert end index to new frequency - CHECK_ASFREQ(newEndTemp = asfreq_main(startIndex+array->dimensions[0]-1, 'A', af_info)); + CHECK_ASFREQ(newEndTemp = asfreq_main(startIndex+array->dimensions[0]-1, 'A', &af_info)); if (newEndTemp < 1) { - CHECK_ASFREQ(newEnd = asfreq_endpoints(startIndex+array->dimensions[0]-1, 'B', af_info)); + CHECK_ASFREQ(newEnd = asfreq_endpoints(startIndex+array->dimensions[0]-1, 'B', &af_info)); } else { newEnd = newEndTemp; } @@ -1192,8 +1259,12 @@ if (newHeight > 1) { long tempval; + struct asfreq_info af_info_rev; + + get_asfreq_info(toFreq, fromFreq, &af_info_rev); asfreq_reverse = get_asfreq_func(toFreq, fromFreq, 0); - CHECK_ASFREQ(tempval = asfreq_reverse(newStart, 'B', af_info)); + + CHECK_ASFREQ(tempval = asfreq_reverse(newStart, 'B', &af_info_rev)); currPerLen = startIndex - tempval; nd = 2; @@ -1225,7 +1296,8 @@ val = PyArray_GETITEM(array, PyArray_GetPtr(array, &i)); valMask = PyArray_GETITEM(mask, PyArray_GetPtr(mask, &i)); - CHECK_ASFREQ(currIndex = asfreq_main(startIndex + i, relation, af_info)); + CHECK_ASFREQ(currIndex = asfreq_main(startIndex + i, relation, &af_info)); + newIdx[0] = currIndex-newStart; if (newHeight > 1) { @@ -1248,6 +1320,7 @@ Py_DECREF(val); Py_DECREF(valMask); + } PyDimMem_FREE(newIdx); @@ -1265,6 +1338,51 @@ return returnVal; } +/* +static long my_func(long arg1, char arg2, struct asfreq_info *foobar) { + printf("address inside: %i\n", foobar); + printf("to_a_year_end: %i\n", foobar->to_a_year_end); + return 55; +} + +static void set_struct(struct asfreq_info *foobar) { + foobar->to_a_year_end = 20; +} + +static long (*get_my_func(int fromFreq, int toFreq, int forConvert))(long, char, struct asfreq_info*) { + return &asfreq_DtoA; +} + +static char cseries_fpointer_doc[] = ""; +static PyObject * +cseries_fpointer(PyObject *self, PyObject *args) +{ + + int myint; + struct asfreq_info af_info; + long fromFreq, toFreq; + char *relation; + long (*fpointer)(long, char, struct asfreq_info*) = NULL; + long result; + + if (!PyArg_ParseTuple(args, "iis:fpointer(fromfreq, tofreq, relation)", &fromFreq, &toFreq, &relation)) return NULL; + //if (!PyArg_ParseTuple(args, "i:fpointer(myint)", &myint)) return NULL; + + get_asfreq_info(fromFreq, toFreq, &af_info); + + //fpointer = get_my_func(15, 15, 15); + fpointer = get_asfreq_func(fromFreq, toFreq, 0); + + printf("address outside: %i\n", &af_info); + result = fpointer(732741, 'B', &af_info); + printf("result: %i\n", result); + + printf("function address: fpointer, my_func (%i, %i)\n", fpointer, &asfreq_DtoA); + + Py_RETURN_NONE; +} +*/ + static char cseries_asfreq_doc[] = ""; static PyObject * cseries_asfreq(PyObject *self, PyObject *args) @@ -1275,7 +1393,7 @@ char *relation; int fromFreq, toFreq; long fromDate, toDate; - long (*asfreq_main)(long, char, struct asfreq_info) = NULL; + long (*asfreq_main)(long, char, struct asfreq_info*) = NULL; struct asfreq_info af_info; if (!PyArg_ParseTuple(args, "Oiis:asfreq(fromDates, fromfreq, tofreq, relation)", &fromDates, &fromFreq, &toFreq, &relation)) return NULL; @@ -1296,7 +1414,7 @@ fromDateObj = PyArray_GETITEM(fromDates, iterFrom->dataptr); fromDate = PyInt_AsLong(fromDateObj); - CHECK_ASFREQ(toDate = asfreq_main(fromDate, relation[0], af_info)); + CHECK_ASFREQ(toDate = asfreq_main(fromDate, relation[0], &af_info)); toDateObj = PyInt_FromLong(toDate); PyArray_SETITEM(toDates, iterTo->dataptr, toDateObj); @@ -1315,16 +1433,16 @@ } -static int dInfo_year(struct date_info dateObj) { return dateObj.year; } -static int dInfo_quarter(struct date_info dateObj) { return dateObj.quarter; } -static int dInfo_month(struct date_info dateObj) { return dateObj.month; } -static int dInfo_day(struct date_info dateObj) { return dateObj.day; } -static int dInfo_day_of_year(struct date_info dateObj) { return dateObj.day_of_year; } -static int dInfo_day_of_week(struct date_info dateObj) { return dateObj.day_of_week; } -static int dInfo_week(struct date_info dateObj) { return dInfoCalc_ISOWeek(dateObj); } -static int dInfo_hour(struct date_info dateObj) { return dateObj.hour; } -static int dInfo_minute(struct date_info dateObj) { return dateObj.minute; } -static int dInfo_second(struct date_info dateObj) { return (int)dateObj.second; } +static int dInfo_year(struct date_info *dateObj) { return dateObj->year; } +static int dInfo_quarter(struct date_info *dateObj) { return dateObj->quarter; } +static int dInfo_month(struct date_info *dateObj) { return dateObj->month; } +static int dInfo_day(struct date_info *dateObj) { return dateObj->day; } +static int dInfo_day_of_year(struct date_info *dateObj) { return dateObj->day_of_year; } +static int dInfo_day_of_week(struct date_info *dateObj) { return dateObj->day_of_week; } +static int dInfo_week(struct date_info *dateObj) { return dInfoCalc_ISOWeek(dateObj); } +static int dInfo_hour(struct date_info *dateObj) { return dateObj->hour; } +static int dInfo_minute(struct date_info *dateObj) { return dateObj->minute; } +static int dInfo_second(struct date_info *dateObj) { return (int)dateObj->second; } static double getAbsTime(int freq, long dailyDate, long originalDate) { @@ -1368,8 +1486,8 @@ long absdate; double abstime; - long (*toDaily)(long, char, struct asfreq_info) = NULL; - int (*getDateInfo)(struct date_info) = NULL; + long (*toDaily)(long, char, struct asfreq_info*) = NULL; + int (*getDateInfo)(struct date_info*) = NULL; struct asfreq_info af_info; if (!PyArg_ParseTuple(args, "Ois:getDateInfo(array, freq, info)", &array, &freq, &info)) return NULL; @@ -1422,11 +1540,11 @@ val = PyArray_GETITEM(array, iterSource->dataptr); dateNum = PyInt_AsLong(val); Py_DECREF(val); - CHECK_ASFREQ(absdate = toDaily(dateNum, 'B', af_info)); + CHECK_ASFREQ(absdate = toDaily(dateNum, 'B', &af_info)); abstime = getAbsTime(freq, absdate, dateNum); if(dInfoCalc_SetFromAbsDateTime(&convDate, absdate, abstime, GREGORIAN_CALENDAR)) return NULL; - dInfo = getDateInfo(convDate); + dInfo = getDateInfo(&convDate); PyArray_SETITEM(newArray, iterResult->dataptr, PyInt_FromLong(dInfo)); @@ -1543,6 +1661,8 @@ /////////////////////////////////////////////////////////////////////// +//{"fpointer", cseries_fpointer, METH_VARARGS, cseries_fpointer_doc}, + static PyMethodDef cseries_methods[] = { {"strfmt", cseries_strfmt, METH_VARARGS, cseries_strfmt_doc}, {"convert", cseries_convert, METH_VARARGS, cseries_convert_doc}, @@ -1563,6 +1683,19 @@ // Add all the frequency constants to a python dictionary ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANN", FR_ANN); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNJAN", FR_ANNJAN); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNFEB", FR_ANNFEB); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNMAR", FR_ANNMAR); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNAPR", FR_ANNAPR); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNMAY", FR_ANNMAY); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNJUN", FR_ANNJUN); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNJUL", FR_ANNJUL); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNAUG", FR_ANNAUG); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNSEP", FR_ANNSEP); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNOCT", FR_ANNOCT); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNNOV", FR_ANNNOV); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNDEC", FR_ANNDEC); + ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_QTR", FR_QTR); ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_MTH", FR_MTH); From scipy-svn at scipy.org Tue Mar 6 16:43:11 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 Mar 2007 15:43:11 -0600 (CST) Subject: [Scipy-svn] r2833 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070306214311.C9A7E39C131@new.scipy.org> Author: mattknox_ca Date: 2007-03-06 15:43:07 -0600 (Tue, 06 Mar 2007) New Revision: 2833 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: removed commented out code that isn't needed Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-06 21:15:46 UTC (rev 2832) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-06 21:43:07 UTC (rev 2833) @@ -1338,51 +1338,6 @@ return returnVal; } -/* -static long my_func(long arg1, char arg2, struct asfreq_info *foobar) { - printf("address inside: %i\n", foobar); - printf("to_a_year_end: %i\n", foobar->to_a_year_end); - return 55; -} - -static void set_struct(struct asfreq_info *foobar) { - foobar->to_a_year_end = 20; -} - -static long (*get_my_func(int fromFreq, int toFreq, int forConvert))(long, char, struct asfreq_info*) { - return &asfreq_DtoA; -} - -static char cseries_fpointer_doc[] = ""; -static PyObject * -cseries_fpointer(PyObject *self, PyObject *args) -{ - - int myint; - struct asfreq_info af_info; - long fromFreq, toFreq; - char *relation; - long (*fpointer)(long, char, struct asfreq_info*) = NULL; - long result; - - if (!PyArg_ParseTuple(args, "iis:fpointer(fromfreq, tofreq, relation)", &fromFreq, &toFreq, &relation)) return NULL; - //if (!PyArg_ParseTuple(args, "i:fpointer(myint)", &myint)) return NULL; - - get_asfreq_info(fromFreq, toFreq, &af_info); - - //fpointer = get_my_func(15, 15, 15); - fpointer = get_asfreq_func(fromFreq, toFreq, 0); - - printf("address outside: %i\n", &af_info); - result = fpointer(732741, 'B', &af_info); - printf("result: %i\n", result); - - printf("function address: fpointer, my_func (%i, %i)\n", fpointer, &asfreq_DtoA); - - Py_RETURN_NONE; -} -*/ - static char cseries_asfreq_doc[] = ""; static PyObject * cseries_asfreq(PyObject *self, PyObject *args) From scipy-svn at scipy.org Tue Mar 6 16:44:02 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 6 Mar 2007 15:44:02 -0600 (CST) Subject: [Scipy-svn] r2834 - trunk/Lib/sandbox/timeseries Message-ID: <20070306214402.C8F6939C131@new.scipy.org> Author: mattknox_ca Date: 2007-03-06 15:43:59 -0600 (Tue, 06 Mar 2007) New Revision: 2834 Modified: trunk/Lib/sandbox/timeseries/__init__.py Log: removed plotlib import Modified: trunk/Lib/sandbox/timeseries/__init__.py =================================================================== --- trunk/Lib/sandbox/timeseries/__init__.py 2007-03-06 21:43:07 UTC (rev 2833) +++ trunk/Lib/sandbox/timeseries/__init__.py 2007-03-06 21:43:59 UTC (rev 2834) @@ -23,7 +23,6 @@ from tmulti import * import reportlib from reportlib import * -import plotlib from addons import filters, interpolate From scipy-svn at scipy.org Wed Mar 7 11:58:01 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Mar 2007 10:58:01 -0600 (CST) Subject: [Scipy-svn] r2835 - trunk/Lib/sandbox/timeseries Message-ID: <20070307165801.2A1C539C047@new.scipy.org> Author: mattknox_ca Date: 2007-03-07 10:57:56 -0600 (Wed, 07 Mar 2007) New Revision: 2835 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: tdates.py: removed get_freq_group function (put it in tcore) Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-06 21:43:59 UTC (rev 2834) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-07 16:57:56 UTC (rev 2835) @@ -144,7 +144,7 @@ self.freq = corelib.check_freq(freq) self.freqstr = corelib.freq_tostr(self.freq) - _freqGroup = get_freq_group(self.freq) + _freqGroup = corelib.get_freq_group(self.freq) if isinstance(value, str): if self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): @@ -352,7 +352,7 @@ def __value(self): "Converts the date to an integer, depending on the current frequency." - _freqGroup = get_freq_group(self.freq) + _freqGroup = corelib.get_freq_group(self.freq) # Secondly...... if self.freq == _c.FR_SEC: delta = (self.datetime - secondlyOriginDate) @@ -439,10 +439,6 @@ #---- --- Functions --- #####--------------------------------------------------------------------------- -def get_freq_group(freq): - # truncate frequency to nearest thousand - return (freq//1000)*1000 - def mx_to_datetime(mxDate): microsecond = 1000000*(mxDate.second % 1) return dt.datetime(mxDate.year, mxDate.month, @@ -454,7 +450,7 @@ def truncateDate(freq, datetime): "Chops off the irrelevant information from the datetime object passed in." freq = corelib.check_freq(freq) - _freqGroup = get_freq_group(freq) + _freqGroup = corelib.get_freq_group(freq) if freq == _c.FR_MIN: return dt.datetime(datetime.year, datetime.month, datetime.day, \ datetime.hour, datetime.minute) @@ -494,7 +490,7 @@ def thisday(freq): "Returns today's date, at the given frequency `freq`." freq = corelib.check_freq(freq) - _freqGroup = get_freq_group(freq) + _freqGroup = corelib.get_freq_group(freq) tempDate = dt.datetime.now() # if it is Saturday or Sunday currently, freq==B, then we want to use Friday if freq == _c.FR_BUS and tempDate.isoweekday() >= 6: From scipy-svn at scipy.org Wed Mar 7 11:58:17 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Mar 2007 10:58:17 -0600 (CST) Subject: [Scipy-svn] r2836 - trunk/Lib/sandbox/timeseries Message-ID: <20070307165817.5C69A39C0E5@new.scipy.org> Author: mattknox_ca Date: 2007-03-07 10:58:14 -0600 (Wed, 07 Mar 2007) New Revision: 2836 Modified: trunk/Lib/sandbox/timeseries/tcore.py Log: added get_freq_group Modified: trunk/Lib/sandbox/timeseries/tcore.py =================================================================== --- trunk/Lib/sandbox/timeseries/tcore.py 2007-03-07 16:57:56 UTC (rev 2835) +++ trunk/Lib/sandbox/timeseries/tcore.py 2007-03-07 16:58:14 UTC (rev 2836) @@ -126,16 +126,14 @@ result += [pr+'-'+mth_str for mth_str in (month[:3], month)] return result - - -freq_dict = { FR_QTR: ['Q','QUARTER','QUARTERLY',], - FR_MTH: ['M','MONTH','MONTHLY',], +freq_dict = { FR_QTR: ['Q','QUARTER','QUARTERLY'], + FR_MTH: ['M','MONTH','MONTHLY'], FR_BUS: ['B','BUSINESS','BUSINESSLY'], - FR_DAY: ['D','DAY','DAILY',], - FR_HR: ['H','HOUR','HOURLY',], - FR_MIN: ['T','MINUTE','MINUTELY',], - FR_SEC: ['S','SECOND','SECONDLY',], - FR_UND: ['U','UNDEF','UNDEFINED'], + FR_DAY: ['D','DAY','DAILY'], + FR_HR: ['H','HOUR','HOURLY'], + FR_MIN: ['T','MINUTE','MINUTELY'], + FR_SEC: ['S','SECOND','SECONDLY'], + FR_UND: ['U','UNDEF','UNDEFINED'] } for _freq, day_str in _week_end_map.iteritems(): @@ -186,6 +184,10 @@ else: raise ValueError("Invalid frequency: %s " % str(freq)) fmtFreq = check_freqstr + +def get_freq_group(freq): + # truncate frequency to nearest thousand + return (freq//1000)*1000 #####--------------------------------------------------------------------------- From scipy-svn at scipy.org Wed Mar 7 11:58:48 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 7 Mar 2007 10:58:48 -0600 (CST) Subject: [Scipy-svn] r2837 - trunk/Lib/sandbox/timeseries/plotlib Message-ID: <20070307165848.6996339C0E2@new.scipy.org> Author: mattknox_ca Date: 2007-03-07 10:58:45 -0600 (Wed, 07 Mar 2007) New Revision: 2837 Modified: trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py Log: modified code to work with new annual frequencies Modified: trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py 2007-03-07 16:58:14 UTC (rev 2836) +++ trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py 2007-03-07 16:58:45 UTC (rev 2837) @@ -426,7 +426,7 @@ return dict([(d,f) for (d,f) in zip(dates[formatted],format[formatted])]) #............................................................................... def _annual_finder(vmin, vmax, freq, aslocator): - if freq != TS.FR_ANN: + if TS.get_freq_group(freq) != TS.FR_ANN: raise ValueError("unexpected frequency") (vmin, vmax) = (int(vmin), int(vmax+1)) span = vmax - vmin + 1 @@ -457,12 +457,13 @@ base=1, quarter=1, month=1, day=1): self.freq = freq self.base = base + fgroup = TS.get_freq_group(freq) (self.quarter, self.month, self.day) = (quarter, month, day) self.isminor = minor_locator self.isdynamic = dynamic_mode self.offset = 0 #..... - if freq == TS.FR_ANN: + if fgroup == TS.FR_ANN: self.finder = _annual_finder elif freq == TS.FR_QTR: self.finder = _quarterly_finder @@ -530,8 +531,9 @@ self.isminor = minor_locator self.isdynamic = dynamic_mode self.offset = 0 + fgroup = TS.get_freq_group(freq) #..... - if freq == TS.FR_ANN: + if fgroup == TS.FR_ANN: self.finder = _annual_finder elif freq == TS.FR_QTR: self.finder = _quarterly_finder From scipy-svn at scipy.org Thu Mar 8 04:44:15 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 8 Mar 2007 03:44:15 -0600 (CST) Subject: [Scipy-svn] r2838 - in trunk/Lib/special: . cephes Message-ID: <20070308094415.029A339C079@new.scipy.org> Author: cookedm Date: 2007-03-08 03:44:13 -0600 (Thu, 08 Mar 2007) New Revision: 2838 Modified: trunk/Lib/special/cephes/mconf.h trunk/Lib/special/setup.py Log: Replace cephes' endianness check with Python's from pyconfig.h Modified: trunk/Lib/special/cephes/mconf.h =================================================================== --- trunk/Lib/special/cephes/mconf.h 2007-03-07 16:58:45 UTC (rev 2837) +++ trunk/Lib/special/cephes/mconf.h 2007-03-08 09:44:13 UTC (rev 2838) @@ -97,50 +97,19 @@ /* Type of computer arithmetic */ -/* PDP-11, Pro350, VAX: +/* This is kind of improper, as the byte-order of floats may not + * be the same as the byte-order of ints. However, it works. */ -/* #define DEC 1 */ -/* Not sure about these pdp defines */ -#if defined(vax) || defined(__vax__) || defined(decvax) || \ - defined(__decvax__) || defined(pro350) || defined(pdp11) -#define DEC 1 - -#elif defined(ns32000) || defined(__ns32000__) || \ - defined(sun386) || defined(__sun386__) || \ - defined(__i386__) || defined(i386) || \ - defined(_M_IX86) || defined(_X86_) || defined(__THW_INTEL__) || \ - defined(__I86__) || defined(__INTEL__) || \ - defined(__amd64__) || defined(__ia64__) || defined(_M_IA64) || \ - defined(MIPSEL) || defined(_MIPSEL) || \ - defined(BIT_ZERO_ON_RIGHT) || \ - defined(__alpha__) || defined(__alpha) || \ - defined(sequent) -#define IBMPC 1 /* Intel IEEE, low order words come first */ -#define BIGENDIAN 0 - -#elif defined(sel) || defined(pyr) || defined(mc68000) || defined (m68k) || \ - defined(is68k) || defined(tahoe) || defined(ibm032) || \ - defined(ibm370) || defined(MIPSEB) || defined(_MIPSEB) || \ - defined(__convex__) || defined(DGUX) || defined(hppa) || \ - defined(apollo) || defined(_CRAY) || defined(__hppa) || \ - defined(__hp9000) || defined(__hp9000s300) || \ - defined(__hp9000s700) || defined(__AIX) || defined(_AIX) ||\ - defined(__pyr__) || defined(__mc68000__) || defined(__sparc) ||\ - defined(_IBMR2) || defined (BIT_ZERO_ON_LEFT) -#define MIEEE 1 /* Motorola IEEE, high order words come first */ -#define BIGENDIAN 1 - -#else -#define UNK 1 /* Machine not IEEE or DEC, - constants given in decimal format */ -#if WORDS_BIGENDIAN /* Defined in pyconfig.h */ -#define BIGENDIAN 1 +#include +#ifdef WORDS_BIGENDIAN +# define MIEEE 1 +# define BIGENDIAN 1 #else -#define BIGENDIAN 0 +# define IBMPC 1 +# define BIGENDIAN 0 #endif -#endif /* UNKnown arithmetic, invokes coefficients given in * normal decimal format. Beware of range boundary * problems (MACHEP, MAXLOG, etc. in const.c) and Modified: trunk/Lib/special/setup.py =================================================================== --- trunk/Lib/special/setup.py 2007-03-07 16:58:45 UTC (rev 2837) +++ trunk/Lib/special/setup.py 2007-03-08 09:44:13 UTC (rev 2838) @@ -2,6 +2,7 @@ import os from os.path import join +from distutils.sysconfig import get_python_inc def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration @@ -15,6 +16,7 @@ # C libraries config.add_library('c_misc',sources=[join('c_misc','*.c')]) config.add_library('cephes',sources=[join('cephes','*.c')], + include_dirs=[get_python_inc()], macros=define_macros) # Fortran libraries From scipy-svn at scipy.org Thu Mar 8 12:06:55 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 8 Mar 2007 11:06:55 -0600 (CST) Subject: [Scipy-svn] r2839 - in trunk/Lib/linsolve: . umfpack/tests Message-ID: <20070308170655.3B13E39C0DE@new.scipy.org> Author: rc Date: 2007-03-08 11:06:49 -0600 (Thu, 08 Mar 2007) New Revision: 2839 Modified: trunk/Lib/linsolve/linsolve.py trunk/Lib/linsolve/umfpack/tests/test_umfpack.py Log: added linsolve.factorized() Modified: trunk/Lib/linsolve/linsolve.py =================================================================== --- trunk/Lib/linsolve/linsolve.py 2007-03-08 09:44:13 UTC (rev 2838) +++ trunk/Lib/linsolve/linsolve.py 2007-03-08 17:06:49 UTC (rev 2839) @@ -118,6 +118,35 @@ return gstrf(N, csc.nnz, csc.data, csc.indices, csc.indptr, permc_spec, diag_pivot_thresh, drop_tol, relax, panel_size) +def factorized( A ): + """ + Return a fuction for solving a linear system, with A pre-factorized. + + Example: + solve = factorized( A ) # Makes LU decomposition. + x1 = solve( rhs1 ) # Uses the LU factors. + x2 = solve( rhs2 ) # Uses again the LU factors. + """ + if isUmfpack and useUmfpack: + mat = _toCS_umfpack( A ) + + if mat.dtype.char not in 'dD': + raise ValueError, "convert matrix data to double, please, using"\ + " .astype(), or set linsolve.useUmfpack = False" + + family = {'d' : 'di', 'D' : 'zi'} + umf = umfpack.UmfpackContext( family[mat.dtype.char] ) + + # Make LU decomposition. + umf.numeric( mat ) + + def solve( b ): + return umf.solve( umfpack.UMFPACK_A, mat, b, autoTranspose = True ) + + return solve + else: + return splu( A ).solve + def _testme(): from scipy.sparse import csc_matrix from numpy import array Modified: trunk/Lib/linsolve/umfpack/tests/test_umfpack.py =================================================================== --- trunk/Lib/linsolve/umfpack/tests/test_umfpack.py 2007-03-08 09:44:13 UTC (rev 2838) +++ trunk/Lib/linsolve/umfpack/tests/test_umfpack.py 2007-03-08 17:06:49 UTC (rev 2839) @@ -73,11 +73,34 @@ #print "Error: ", a*x-b assert_array_almost_equal(a*x, self.b) + def check_factorized_umfpack(self): + """Prefactorize (with UMFPACK) matrix for solving with multiple rhs""" + linsolve.use_solver( useUmfpack = True ) + a = self.a.astype('d') + solve = linsolve.factorized( a ) + + x1 = solve( self.b ) + assert_array_almost_equal(a*x1, self.b) + x2 = solve( self.b2 ) + assert_array_almost_equal(a*x2, self.b2) + + def check_factorized_without_umfpack(self): + """Prefactorize matrix for solving with multiple rhs""" + linsolve.use_solver( useUmfpack = False ) + a = self.a.astype('d') + solve = linsolve.factorized( a ) + + x1 = solve( self.b ) + assert_array_almost_equal(a*x1, self.b) + x2 = solve( self.b2 ) + assert_array_almost_equal(a*x2, self.b2) + def setUp(self): self.a = spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]], [0, 1], 5, 5) #print "The sparse matrix (constructed from diagonals):" #print self.a self.b = array([1, 2, 3, 4, 5]) + self.b2 = array([5, 4, 3, 2, 1]) From scipy-svn at scipy.org Fri Mar 9 17:18:40 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 9 Mar 2007 16:18:40 -0600 (CST) Subject: [Scipy-svn] r2840 - trunk/Lib/sandbox/numexpr Message-ID: <20070309221840.69A2C39C0C0@new.scipy.org> Author: cookedm Date: 2007-03-09 16:18:37 -0600 (Fri, 09 Mar 2007) New Revision: 2840 Modified: trunk/Lib/sandbox/numexpr/interpreter.c Log: [numexpr] Fix so that MSVC Toolkit 2003 doesn't complain; from faltet Modified: trunk/Lib/sandbox/numexpr/interpreter.c =================================================================== --- trunk/Lib/sandbox/numexpr/interpreter.c 2007-03-08 17:06:49 UTC (rev 2839) +++ trunk/Lib/sandbox/numexpr/interpreter.c 2007-03-09 22:18:37 UTC (rev 2840) @@ -1055,12 +1055,13 @@ for (i = 0; i < n_inputs; i++) { PyObject *a = PyTuple_GET_ITEM(a_inputs, i+n_inputs); + PyObject *b; char c = PyString_AS_STRING(self->signature)[i]; int typecode = typecode_from_char(c); if (PyArray_NDIM(a) == 0) { /* Broadcast scalars */ intp dims[1] = {BLOCK_SIZE1}; - PyObject *b = PyArray_SimpleNew(1, dims, typecode); + b = PyArray_SimpleNew(1, dims, typecode); if (!b) goto cleanup_and_exit; self->memsteps[i+1] = 0; PyTuple_SET_ITEM(a_inputs, i+2*n_inputs, b); /* steals reference */ From scipy-svn at scipy.org Mon Mar 12 09:24:45 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Mar 2007 08:24:45 -0500 (CDT) Subject: [Scipy-svn] r2841 - trunk/Lib/stsci/image/lib Message-ID: <20070312132445.DC33639C075@new.scipy.org> Author: chanley Date: 2007-03-12 08:24:42 -0500 (Mon, 12 Mar 2007) New Revision: 2841 Modified: trunk/Lib/stsci/image/lib/combine.py Log: removed un-necessary axis=0 argument Modified: trunk/Lib/stsci/image/lib/combine.py =================================================================== --- trunk/Lib/stsci/image/lib/combine.py 2007-03-09 22:18:37 UTC (rev 2840) +++ trunk/Lib/stsci/image/lib/combine.py 2007-03-12 13:24:42 UTC (rev 2841) @@ -71,7 +71,7 @@ return _combine_f("median", arrays, output, outtype, nlow, nhigh, badmasks) def average( arrays, output=None, outtype=None, nlow=0, nhigh=0, badmasks=None): - """average(,axis=0) nominally computes the average pixel value for a stack of + """average() nominally computes the average pixel value for a stack of identically shaped images. arrays specifies a sequence of inputs arrays, which are nominally a @@ -97,7 +97,7 @@ >>> a = num.arange(4) >>> a = a.reshape((2,2)) >>> arrays = [a*16, a*4, a*2, a*8] - >>> average(arrays,axis=0) + >>> average(arrays) array([[ 0, 7], [15, 22]]) >>> average(arrays, nhigh=1) From scipy-svn at scipy.org Mon Mar 12 11:29:24 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Mar 2007 10:29:24 -0500 (CDT) Subject: [Scipy-svn] r2842 - in trunk/Lib/sandbox/timeseries: . archived_version Message-ID: <20070312152924.3A81739C032@new.scipy.org> Author: mattknox_ca Date: 2007-03-12 10:29:19 -0500 (Mon, 12 Mar 2007) New Revision: 2842 Added: trunk/Lib/sandbox/timeseries/archived_version/examples/ Removed: trunk/Lib/sandbox/timeseries/examples/ Log: Moved remotely Copied: trunk/Lib/sandbox/timeseries/archived_version/examples (from rev 2841, trunk/Lib/sandbox/timeseries/examples) From scipy-svn at scipy.org Mon Mar 12 15:46:11 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Mar 2007 14:46:11 -0500 (CDT) Subject: [Scipy-svn] r2843 - trunk/Lib/sandbox Message-ID: <20070312194611.0339839C032@new.scipy.org> Author: pierregm Date: 2007-03-12 14:46:06 -0500 (Mon, 12 Mar 2007) New Revision: 2843 Added: trunk/Lib/sandbox/pyloess/ Log: Initial import. Currently, only lowess (the univariable, simplified version of loess) and stl (season/trend loess decomposition) are functional. Please check the sandbox subfolder for a broken attempt to port loess From scipy-svn at scipy.org Mon Mar 12 15:47:35 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 12 Mar 2007 14:47:35 -0500 (CDT) Subject: [Scipy-svn] r2844 - in trunk/Lib/sandbox/pyloess: . sandbox sandbox/examples sandbox/src src tests Message-ID: <20070312194735.999AA39C032@new.scipy.org> Author: pierregm Date: 2007-03-12 14:47:15 -0500 (Mon, 12 Mar 2007) New Revision: 2844 Added: trunk/Lib/sandbox/pyloess/.project trunk/Lib/sandbox/pyloess/README trunk/Lib/sandbox/pyloess/__init__.py trunk/Lib/sandbox/pyloess/doc/ trunk/Lib/sandbox/pyloess/pyloess.py trunk/Lib/sandbox/pyloess/sandbox/ trunk/Lib/sandbox/pyloess/sandbox/builder trunk/Lib/sandbox/pyloess/sandbox/examples/ trunk/Lib/sandbox/pyloess/sandbox/examples/sin_data trunk/Lib/sandbox/pyloess/sandbox/examples/sin_result trunk/Lib/sandbox/pyloess/sandbox/pyloess.py trunk/Lib/sandbox/pyloess/sandbox/setup.py trunk/Lib/sandbox/pyloess/sandbox/src/ trunk/Lib/sandbox/pyloess/sandbox/src/S.h trunk/Lib/sandbox/pyloess/sandbox/src/c_loess.pxd trunk/Lib/sandbox/pyloess/sandbox/src/c_numpy.pxd trunk/Lib/sandbox/pyloess/sandbox/src/c_python.pxd trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c trunk/Lib/sandbox/pyloess/sandbox/src/cloess.h trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx trunk/Lib/sandbox/pyloess/sandbox/src/linpack_lite.f trunk/Lib/sandbox/pyloess/sandbox/src/loess.c trunk/Lib/sandbox/pyloess/sandbox/src/loess.h trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c trunk/Lib/sandbox/pyloess/sandbox/src/loessf.f trunk/Lib/sandbox/pyloess/sandbox/src/misc.c trunk/Lib/sandbox/pyloess/sandbox/src/predict.c trunk/Lib/sandbox/pyloess/setup.py trunk/Lib/sandbox/pyloess/src/ trunk/Lib/sandbox/pyloess/src/f_lowess.pyf trunk/Lib/sandbox/pyloess/src/f_stl.pyf trunk/Lib/sandbox/pyloess/src/lowess.f trunk/Lib/sandbox/pyloess/src/stl.f trunk/Lib/sandbox/pyloess/tests/ trunk/Lib/sandbox/pyloess/tests/__init__.py trunk/Lib/sandbox/pyloess/tests/co2_data trunk/Lib/sandbox/pyloess/tests/co2_results_double trunk/Lib/sandbox/pyloess/tests/co2_results_real trunk/Lib/sandbox/pyloess/tests/test_pyloess.py Log: Initial import. Currently, only lowess (the univariable, simplified version of loess) and stl (season/trend loess decomposition) are functional. Please check the sandbox subfolder for a broken attempt to port loess Added: trunk/Lib/sandbox/pyloess/.project =================================================================== --- trunk/Lib/sandbox/pyloess/.project 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/.project 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,17 @@ + + + pyloess + + + + + + org.python.pydev.PyDevBuilder + + + + + + org.python.pydev.pythonNature + + Added: trunk/Lib/sandbox/pyloess/README =================================================================== --- trunk/Lib/sandbox/pyloess/README 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/README 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,16 @@ +pyloess: a numpy wrapper to lowess and stl. + +LOWESS +------ + +The initial file is available at: +http://netlib.bell-labs.com/netlib/go/lowess.f.gz +Simple to double precision conversion by Pierre GERARD-MARCHANT, 2007/03. + + +STL +----- + +The initial file is available at: +http://netlib.bell-labs.com/netlib/a/stl.gz +Simple to double precision conversion by Pierre GERARD-MARCHANT, 2007/03. Added: trunk/Lib/sandbox/pyloess/__init__.py =================================================================== --- trunk/Lib/sandbox/pyloess/__init__.py 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/__init__.py 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,10 @@ +""" +Numpy wrappers for lowess and stl. +""" +__author__ = "Pierre GF Gerard-Marchant" +__version__ = '1.0' +__revision__ = "$Revision: 150 $" +__date__ = '$Date: 2007-02-28 23:42:16 -0500 (Wed, 28 Feb 2007) $' + +import pyloess +from pyloess import lowess, stl \ No newline at end of file Added: trunk/Lib/sandbox/pyloess/pyloess.py =================================================================== --- trunk/Lib/sandbox/pyloess/pyloess.py 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/pyloess.py 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,268 @@ +# pylint: disable-msg=E1101 +""" +Wrapper to lowess and stl routines. + +LOWESS: +Initial Fortran code available at: +http://netlib.bell-labs.com/netlib/go/lowess.f.gz + +initial author: W. S. Cleveland, 1979. +Simple to double precision conversion of the Fortran code by Pierre +GERARD-MARCHANT, 2007/03. + +STL: +Initial Fortran code available at: +http://netlib.bell-labs.com/netlib/a/stl.gz +Initial Authors: R. B. Cleveland, W. S. Cleveland, J. E. McRae, and +I. Terpenning, 1990. +Simple-to-double precision conversion of the Fortran code by Pierre +GERARD-MARCHANT, 2007/03. + + +:author: Pierre GF Gerard-Marchant +:contact: pierregm_at_uga_edu +:date: $Date: 2007-02-28 02:23:25 -0500 (Wed, 28 Feb 2007) $ +:version: $Id: generic.py 145 2007-02-28 07:23:25Z backtopop $ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__version__ = '1.0' +__revision__ = "$Revision: 145 $" +__date__ = '$Date: 2007-02-28 02:23:25 -0500 (Wed, 28 Feb 2007) $' + +import numpy +from numpy import bool_, complex_, float_, int_, str_, object_ +import numpy.core.numeric as numeric +from numpy.core.records import recarray + +import _lowess, _stl + + +def lowess(x,y,f=0.5,nsteps=2,delta=0): + """Performs a robust locally weighted regression (lowess). + + Outputs a *3xN* array of fitted values, residuals and fit weights. + + +:Parameters: + x : ndarray + Abscissas of the points on the scatterplot; the values in X must be + ordered from smallest to largest. + y : ndarray + Ordinates of the points on the scatterplot. + f : Float *[0.5]* + Fraction of the total number of points used to compute each fitted value. + As f increases the smoothed values become smoother. Choosing f in the range + .2 to .8 usually results in a good fit. + nsteps : Integer *[2]* + Number of iterations in the robust fit. If nsteps=0, the nonrobust fit + is returned; setting nsteps=2 should serve most purposes. + delta : Integer *[0]* + Nonnegative parameter which may be used to save computations. + If N (the number of elements in x) is less than 100, set delta=0.0; + if N is greater than 100 you should find out how delta works by reading + the additional instructions section. + +:Returns: + A recarray of smoothed values ('smooth'), residuals ('residuals') and local + robust weights ('weights'). + + +Additional instructions +----------------------- + +Fro the original author: + + DELTA can be used to save computations. Very roughly the + algorithm is this: on the initial fit and on each of the + NSTEPS iterations locally weighted regression fitted values + are computed at points in X which are spaced, roughly, DELTA + apart; then the fitted values at the remaining points are + computed using linear interpolation. The first locally + weighted regression (l.w.r.) computation is carried out at + X(1) and the last is carried out at X(N). Suppose the + l.w.r. computation is carried out at X(I). If X(I+1) is + greater than or equal to X(I)+DELTA, the next l.w.r. + computation is carried out at X(I+1). If X(I+1) is less + than X(I)+DELTA, the next l.w.r. computation is carried out + at the largest X(J) which is greater than or equal to X(I) + but is not greater than X(I)+DELTA. Then the fitted values + for X(K) between X(I) and X(J), if there are any, are + computed by linear interpolation of the fitted values at + X(I) and X(J). If N is less than 100 then DELTA can be set + to 0.0 since the computation time will not be too great. + For larger N it is typically not necessary to carry out the + l.w.r. computation for all points, so that much computation + time can be saved by taking DELTA to be greater than 0.0. + If DELTA = Range (X)/k then, if the values in X were + uniformly scattered over the range, the full l.w.r. + computation would be carried out at approximately k points. + Taking k to be 50 often works well. + +Method +------ + + The fitted values are computed by using the nearest neighbor + routine and robust locally weighted regression of degree 1 + with the tricube weight function. A few additional features + have been added. Suppose r is FN truncated to an integer. + Let h be the distance to the r-th nearest neighbor + from X[i]. All points within h of X[i] are used. Thus if + the r-th nearest neighbor is exactly the same distance as + other points, more than r points can possibly be used for + the smooth at X[i]. There are two cases where robust + locally weighted regression of degree 0 is actually used at + X[i]. One case occurs when h is 0.0. The second case + occurs when the weighted standard error of the X[i] with + respect to the weights w[j] is less than .001 times the + range of the X[i], where w[j] is the weight assigned to the + j-th point of X (the tricube weight times the robustness + weight) divided by the sum of all of the weights. Finally, + if the w[j] are all zero for the smooth at X[i], the fitted + value is taken to be Y[i]. + +References +---------- + W. S. Cleveland. 1978. Visual and Computational Considerations in + Smoothing Scatterplots by Locally Weighted Regression. In + Computer Science and Statistics: Eleventh Annual Symposium on the + Interface, pages 96-100. Institute of Statistics, North Carolina + State University, Raleigh, North Carolina, 1978. + + W. S. Cleveland, 1979. Robust Locally Weighted Regression and + Smoothing Scatterplots. Journal of the American Statistical + Association, 74:829-836, 1979. + + W. S. Cleveland, 1981. LOWESS: A Program for Smoothing Scatterplots + by Robust Locally Weighted Regression. The American Statistician, + 35:54. + + """ + dtyp = [('smooth',float_), ('weigths', float_), ('residuals', float_)] + return numeric.fromiter(zip(*_lowess.lowess(x,y,f,nsteps,delta,)), + dtype=dtyp).view(recarray) + +#-------------------------------------------------------------------------- +#--- --- STL --- +#####---------------------------------------------------------------------- +def stl(y, np=12, ns=7, nt=None, nl=13, isdeg=1, itdeg=1, ildeg=1, + nsjump=None,ntjump=None,nljump=None, robust=True, ni=None,no=None): + """Decomposes a time series into seasonal and trend components. + +:Parameters: + y : Numerical array + Time Series to be decomposed. + np : Integer *[12]* + Period of the seasonal component. + For example, if the time series is monthly with a yearly cycle, then + np=12. + ns : Integer *[7]* + Length of the seasonal smoother. + The value of ns should be an odd integer greater than or equal to 3. + A value ns>6 is recommended. As ns increases the values of the + seasonal component at a given point in the seasonal cycle (e.g., January + values of a monthly series with a yearly cycle) become smoother. + nt : Integer *[None]* + Length of the trend smoother. + The value of nt should be an odd integer greater than or equal to 3. + A value of nt between 1.5*np and 2*np is recommended. As nt increases, + the values of the trend component become smoother. + If nt is None, it is estimated as the smallest odd integer greater + or equal to (1.5*np)/[1-(1.5/ns)] + nl : Integer *[None]* + Length of the low-pass filter. + The value of nl should be an odd integer greater than or equal to 3. + The smallest odd integer greater than or equal to np is used by default. + isdeg : Integer *[1]* + Degree of locally-fitted polynomial in seasonal smoothing. + The value is 0 or 1. + itdeg : Integer *[1]* + Degree of locally-fitted polynomial in trend smoothing. + The value is 0 or 1. + ildeg : Integer *[1]* + Degree of locally-fitted polynomial in low-pass smoothing. + The value is 0 or 1. + nsjump : Integer *[None]* + Skipping value for seasonal smoothing. + The seasonal smoother skips ahead nsjump points and then linearly + interpolates in between. The value of nsjump should be a positive + integer; if nsjump=1, a seasonal smooth is calculated at all n points. + To make the procedure run faster, a reasonable choice for nsjump is + 10%-20% of ns. By default, nsjump= 0.1*ns. + ntjump : Integer *[1]* + Skipping value for trend smoothing. If None, ntjump= 0.1*nt + nljump : Integer *[1]* + Skipping value for low-pass smoothing. If None, nljump= 0.1*nl + robust : Boolean *[True]* + Flag indicating whether robust fitting should be performed. + ni : Integer *[None]* + Number of loops for updating the seasonal and trend components. + The value of ni should be a positive integer. + See the next argument for advice on the choice of ni. + If ni is None, ni is set to 1 for robust fitting, to 5 otherwise. + no : Integer *[0]* + Number of iterations of robust fitting. The value of no should + be a nonnegative integer. If the data are well behaved without + outliers, then robustness iterations are not needed. In this case + set no=0, and set ni=2 to 5 depending on how much security + you want that the seasonal-trend looping converges. + If outliers are present then no=3 is a very secure value unless + the outliers are radical, in which case no=5 or even 10 might + be better. If no>0 then set ni to 1 or 2. + If None, then no is set to 15 for robust fitting, to 0 otherwise. + +Returns: + A recarray of estimated trend values ('trend'), estimated seasonal + components ('seasonal'), local robust weights ('weights') and fit + residuals ('residuals'). + The final local robust weights are all 1 if no=0. + +Reference +--------- + + R. B. Cleveland, W. S. Cleveland, J. E. McRae and I. Terpenning. + 1990. STL: A Seasonal-Trend Decomposition Procedure Based on LOESS + (with Discussion). Journal of Official Statistics, 6:3-73. + + + """ + ns = max(ns, 3) + if ns%2 == 0: + ns += 1 + np = max(2, np) + if nt is None: + nt = max(int((1.5*np/(1.-1.5/ns))+0.5), 3) + if not nt%2: + nt += 1 + if nl is None: + nl = max(3,np) + if not nl%2: + nl += 1 + if nsjump is None: + nsjump = int(0.1*ns + 0.9) + if ntjump is None: + ntjump = int(0.1*nt + 0.9) + if nljump is None: + nljump = int(0.1*nl + 0.9) + if robust: + if ni is None: + ni = 1 + if no is None: + no = 15 + else: + if ni is None: + ni = 5 + if no is None: + no = 0 + + if hasattr(y,'_mask') and numpy.any(y._mask): + raise ValueError,"Missing values should first be filled !" + y = numeric.array(y, subok=True, copy=False).ravel() + (rw,szn,trn,work) = _stl.stl(y,np,ns,nt,nl,isdeg,itdeg,ildeg, + nsjump,ntjump,nljump,ni,no,) + dtyp = [('trend', float_), ('seasonal', float_), + ('residuals', float_), ('weights', float_)] + result = numeric.fromiter(zip(trn,szn,y-trn-szn,rw), dtype=dtyp) + return result.view(recarray) + +################################################################################ + Added: trunk/Lib/sandbox/pyloess/sandbox/builder =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/builder 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/builder 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,15 @@ +rm -rf build +pushd src +rm -f cloess.c *.so *.o +pyrexc cloess.pyx || exit +gcc -c -fPIC loess.c loessc.c misc.c predict.c loessf.f linpack_lite.f +gcc -c -fPIC cloess.c -I/usr/include/python2.4 \ + -I/usr/lib64/python2.4/site-packages/numpy/core/include || exit +gcc -shared loessf.o linpack_lite.o loess.o loessc.o misc.o predict.o cloess.o \ + -llapack -lblas -o cloess.so || exit +rm -f *.o +popd +mv src/cloess.so cloess.so +python -c "import cloess; print dir(cloess)" +python pyloess.py +echo "OK" \ No newline at end of file Property changes on: trunk/Lib/sandbox/pyloess/sandbox/builder ___________________________________________________________________ Name: svn:executable + * Added: trunk/Lib/sandbox/pyloess/sandbox/examples/sin_data =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/examples/sin_data 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/examples/sin_data 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,24 @@ +-0.529631673 -0.476162031 0.122393909 -0.764738290 0.694588529 + 0.157878753 0.825755505 0.383776725 -0.297611713 0.179712838 + 0.883403846 1.175870259 -0.222158656 0.887655136 0.506018472 + 1.201763090 1.358657158 1.766876246 0.945261834 0.242015272 + 1.108175506 1.588326244 0.086595996 0.135447708 1.674333147 + 0.087861038 0.150255064 1.662807709 1.918985242 0.334817302 + 1.995973197 0.269379941 0.469938419 0.719274928 1.441382256 + 1.856114890 -0.004302644 1.329872080 -0.058310637 0.472398463 + 0.435258117 1.636500756 1.699950103 1.478820190 -0.190025448 + 1.300341865 -0.058635213 0.819062806 0.047988842 -0.168558533 + 0.037056266 0.536154778 0.278227911 -0.313547042 0.722026888 +-0.114359903 -0.376634077 0.652043347 -0.515809282 -0.602277827 +-0.938181382 -1.037834739 0.278491625 -1.092834467 -0.778780405 +-1.070774416 0.539015258 -0.234691028 -0.152634072 -0.066153375 +-0.233711530 -0.959496456 -0.946902608 -0.871057712 -0.583103683 +-1.534738618 -0.662166840 -1.155263966 -0.533407016 -1.319182554 +-0.186566885 -0.897649461 -1.501951078 -0.004479304 -1.678331392 +-1.490781842 -0.589586598 -0.285787771 -0.510207129 -0.627988881 +-1.109061921 -1.310354670 0.002602266 -0.271113225 -0.885954568 +-1.150763444 -0.779791042 -1.053566764 -0.718805204 -0.257604369 +-1.278783228 -0.816685979 -1.417844559 -0.081346747 -1.413808292 +-1.487076480 -0.166387633 -0.922128152 0.267933770 -1.000264981 +-0.638768521 -0.298071585 0.115376460 0.104988650 -0.993492047 +-0.175837760 0.193326045 -0.068244286 0.325014896 -0.506554400 \ No newline at end of file Added: trunk/Lib/sandbox/pyloess/sandbox/examples/sin_result =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/examples/sin_result 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/examples/sin_result 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,24 @@ +-0.119671288 -0.048917262 0.019498810 0.085541472 0.149175270 + 0.210364749 0.269074456 0.325268935 0.378912732 0.429970393 + 0.478406464 0.524185488 0.567272013 0.607630584 0.645225746 + 0.679964281 0.711826741 0.740888328 0.767224242 0.790909683 + 0.812019853 0.830629952 0.846815180 0.860650739 0.872211830 + 0.881573652 0.888811407 0.894000296 0.897215519 0.898532276 + 0.896495398 0.889853461 0.878987289 0.864277706 0.846105535 + 0.824851599 0.800896721 0.774621727 0.746407438 0.716634678 + 0.685684270 0.653937039 0.621773808 0.589575399 0.557722637 + 0.522992287 0.482466105 0.436982397 0.387379471 0.334495633 + 0.279169191 0.222238452 0.164541722 0.106917309 0.050203520 +-0.004761338 -0.057138959 -0.106091034 -0.150779258 -0.190365323 +-0.228071840 -0.267406108 -0.307956846 -0.349312773 -0.391062611 +-0.432795078 -0.474098896 -0.514562784 -0.553775463 -0.591325651 +-0.626802071 -0.659793440 -0.689888480 -0.716675911 -0.739744452 +-0.760199435 -0.779384403 -0.797245400 -0.813728466 -0.828779643 +-0.842344973 -0.854370498 -0.864802259 -0.873586297 -0.880668656 +-0.885995376 -0.889512498 -0.891166066 -0.890902119 -0.888666701 +-0.884599958 -0.878878792 -0.871504374 -0.862477875 -0.851800466 +-0.839473318 -0.825497602 -0.809874489 -0.792605150 -0.773690757 +-0.753132480 -0.730931491 -0.707088961 -0.681606061 -0.654483961 +-0.625716944 -0.595298336 -0.563227879 -0.529505317 -0.494130390 +-0.457102841 -0.418422412 -0.378088845 -0.336101881 -0.292461263 +-0.247166733 -0.200218032 -0.151614903 -0.101357088 -0.049444328 Added: trunk/Lib/sandbox/pyloess/sandbox/pyloess.py =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/pyloess.py 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/pyloess.py 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,517 @@ +import os +from math import ceil + +import numpy +from numpy import bool_, int_, float_ + +narray = numpy.array +nempty = numpy.empty +nzeros = numpy.zeros + +import logging +logging.basicConfig(level=logging.DEBUG) +loesslogging = logging.getLogger('loesss') + +import cloess +reload(cloess) + +class paramdict(dict): + def __init__(self, **kwargs): + dict.__init__(self, **kwargs) + + def __getattr__(self, attr): + _got = getattr(super(paramdict,self), attr, None) + if _got is None: + _got = self.get(attr, None) + return _got + + def __setattr__(self, attr, value): + if attr in self.keys(): + self[attr] = value + else: + dict.__setattr__(self, attr, value) + +#------------------------------------------------------------------------------- +class _loess_control(dict): + + _optiondict = dict(surface=('interpolate', 'direct'), + statistics=('approximate', 'exact'), + trace_hat=('wait.to.decide', 'exact', 'approximate'),) + + def __init__(self, surface="interpolate", statistics="approximate", + trace_hat="wait.to.decide", iterations=4, cell=0.2): + dict.__init__(self, surface=None, statistics=None, + trace_hat=None, iterations=iterations, + cell=cell) + self.surface = surface.lower() + self.statistics = statistics.lower() + self.trace_hat = trace_hat.lower() + # + def __getattr__(self, attr): + _got = getattr(super(dict,self), attr, None) + if _got is None: + _got = self.get(attr, None) + return _got + # + def __setattr__(self, attr, value): + if attr in self.keys(): + self.__setitem__(attr, value) + else: + dict.__setattr__(self, attr, value) + # + def __setitem__(self, attr, value): + if attr in _loess_control._optiondict.keys(): + self.__setoption__(attr, value) + else: + dict.__setitem__(self, attr, value) + # + def __setoption__(self, attr, value): + msg = "Invalid argument: %s must be in %s (got %s)" + attrlist = _loess_control._optiondict[attr] + if (not isinstance(value, str)) or \ + (value.lower() not in attrlist): + raise ValueError, msg % (attr, attrlist, value) + dict.__setitem__(self, attr, value.lower()) + # +# def set_surface_status(self, new_stat): +# if new_stat.lower() not in ('none','exact','approximate'): +# raise ValueError,"Invalid value for the new_stat parameter: "\ +# "should be in ('none','exact','approximate'), got %s" % new_stat +# if self.surface == "interpolate" and new_stat == "approximate": +# if self.trace_hat == "approximate": +# new_stat = "2.approx" +# else: +# trace_hat='exact' in that case +# new_stat = "1.approx" +# return "/".join([self.surface, new_stat]) + def set_surface_status(self, new_stat): + if new_stat.lower() not in ('none','exact','approximate'): + raise ValueError,"Invalid value for the new_stat parameter: "\ + "should be in ('none','exact','approximate'), got %s" % new_stat + statusdict = {"interpolate":{"none": 10, + "exact":11, + "1.approx":12, + "2.approx":13 }, + "direct":{"none" : 20, + "exact": 21, + "approximate": 22}} + if self.surface == "interpolate" and new_stat == "approximate": + if self.trace_hat == "approximate": + status = 13 + else: + # trace_hat='exact' in that case + status = 12 + else: + status = statusdict[self.surface][new_stat] + return status + +# +# +# +#class loess(object): +# """ +# +#:Ivariables: +# x : ndarray +# Independent variables +# y : ndarray +# Dependent variables +# weights : ndarray +# """ +# def __init__(self, x, y, weights=None, +# span=0.75, degree=2, normalize=True, family="gaussian", +# surface="interpolate", statistics="approximate", +# cell=0.2, trace_hat="wait.to.decide",iterations=4): +# x = narray(x, copy=False, subok=True, order='F') +# if x.ndim == 2: +# (n,d) = x.shape +# elif x.ndim == 1: +# (n,d) = (len(x),1) +# else: +# raise ValueError,"Argument 'x' should be 2D at most!" +# max_kd = max(n, 200) +# # +# y = narray(y, copy=False, subok=True, order='F') +# if weights is None: +# weights = numpy.ones_like(y) +# self.inputs = paramdict(x=x, y=y, weights=weights, nobs=n, nvars=d) +# self.model = paramdict(span=span, degree=degree, +# normalize=normalize, family=family.lower(), +# parametric=nzeros((d,), bool_, 'F'), +# drop_square=nzeros((d,), bool_, 'F') +# ) +# self.control = _loess_control(surface=surface.lower(), +# statistics=statistics.lower(), +# trace_hat=trace_hat.lower(), +# iterations=iterations, cell=cell, +# ) +# self.outputs = paramdict(fitted_values=nempty((n,), float_, 'F'), +# fitted_residuals=nempty((n,), float_, 'F'), +# pseudovalues=nempty((n,), float_, 'F'), +# diagonal=nempty((n,), float_, 'F'), +# robust=numpy.ones((n,), float_, 'F'), +# divisor=nempty((d,), float_, 'F'), +# enp=0, s=0, one_delta=0, two_delta=0, +# trace_hat=0 +# ) +# self.kd_tree = paramdict(parameter=nempty((7,), int_, 'F'), +# a=nempty((max_kd,), int_, 'F'), +# xi=nempty((max_kd,), float_, 'F'), +# vert=nempty((d*2,), float_, 'F'), +# vval=nempty(((d+1)*max_kd,), float_, 'F') +# ) +# # +# if self.model.family == "gaussian": +# self.control['iterations'] = 0 +# if self.control.trace_hat == "wait.to.decide": +# if (self.control.surface == "interpolate") and n >= 500: +# self.control.trace_hat = "approximate" +# else: +# self.control.trace_hat = "exact" +# #...................................................... +# def fit(self, span = 0.75, degree = 2, parametric = False, +# drop_square = False, normalize = True, +# statistics = "approximate", surface = "interpolate", +# cell = 0.2, iterations = 1, trace_hat = "exact"): +# +# # Get input.................... +# inputs = self.inputs +# (x, y, n, d, weights) = [inputs[k] +# for k in ('x','y','nobs','nvars', 'weights')] +# +# max_kd = max(n, 200) +## a = max_kd +# one_delta = two_delta = trace_hat_out = 0 +# +# # Set temporary ............... +# kd_tree = self.kd_tree +# (a, xi, vert, vval, parameter) = [kd_tree[k] +# for k in ('a', 'xi', 'vert', 'vval', +# 'parameter')] +# a_tmp = nempty((max_kd,), int_) +# xi_tmp = nempty((max_kd,), float_) +# vert_tmp = nempty((2*d,), float_) +# vval_tmp = nempty(((d+1)*max_kd,), float_) +# +# # Check control ................ +# control = self.control +# surface = control.surface +# statistics = control.statistics +# iterations = control.iterations +# trace_hat = control.trace_hat +# # Get model .................... +# model = self.model +# family = model.family +# parametric = model.parametric +# drop_square = model.drop_square +# (span, degree, normalize) = [model[k] +# for k in ('span', 'degree', 'normalize')] +# # +# outputs = self.outputs +# fitted_values = outputs.fitted_values +# fitted_residuals = outputs.fitted_residuals +# pseudovalues = outputs.pseudovalues +# diagonal = outputs.diagonal +# robust = outputs.robust +# (enp, s, one_delta, two_delta) = [outputs[k] +# for k in ('enp','s','one_delta','two_delta')] +# trace_hat = outputs.trace_hat +## parameter = 7 +# (d1_tmp, d2_tmp, trL_tmp, zero,) = (0., 0., 0., 0.) +# (delta1, delta2, trL, trace_hat_in) = (0, 0, 0, 0) +# temp = nempty((n,), float_) +# diag_tmp = nempty((n,), float_) +# param_tmp = nempty((n,), int_) +# if iterations > 0: +# pseudo_resid = nempty((n,), float_) +# # +# new_cell = span * cell +# # +# loesslogging.debug("initial divisor: %s" % self.outputs.divisor) +# if normalize and d > 1: +# cut = int(ceil(0.1*n)) +# x_trimmed = numpy.sort(x, axis=0)[cut:-cut] +# outputs.divisor = x_trimmed.std(axis=0) +# outputs.divisor *= numpy.sqrt(n/float(n-1)) +# x = x / outputs.divisor +# else: +# outputs.divisor = numpy.ones(d, float_) +# loesslogging.debug("final divisor: %s" % self.outputs.divisor) +# # +# sum_drop_sqr = sum(drop_square) +# # +# parametric = narray(parametric, copy=True) +# parametric.resize((d,)) +# sum_parametric = parametric.sum() +# nonparametric = numpy.logical_not(parametric).sum() +# order_parametric = numpy.argsort(parametric) +# # +# order_drop_sqr = 2 - drop_square[order_parametric] +# x = x[:,order_parametric].ravel() +# # +# if degree == 1 and sum_drop_sqr: +# msg = "Specified the square of a factor predictor to be dropped"\ +# " when degree = 1" +# raise ValueError, msg +# if d == 1 and sum_drop_sqr: +# msg = "Specified the square of a predictor to be dropped "\ +# "with only one numeric predictor" +# raise ValueError, msg +# if sum_parametric == d: +# raise ValueError, "Specified parametric for all predictors" +# # +# new_stat = statistics.lower() +# loesslogging.debug("start iteration: %s" % new_stat) +# for j in range(iterations+1): +# if j > 0: +# new_stat = "none" +# robust = weights * robust +# surf_stat = control.set_surface_status(new_stat) +# #setLf = (surf_stat.lower() == "interpolate/exact") +# setLf = int(surf_stat == 11) +# loesslogging.debug("iteration: %i: %s - %s" % (j, surf_stat, setLf)) +# # +# (surf_stat, fitted_values, parameter, a, +# xi, vert, vval, diagonal, trL, delta1, delta2, +# ) = loess_raw(y, x, weights, robust, d, n, span, degree, +# nonparametric, order_drop_sqr, sum_drop_sqr, +# new_cell, surf_stat, fitted_values, parameter, a, +# xi, vert, vval, diagonal, trL, delta1, delta2, +# setLf) +# # +# if j == 0: +# trace_hat_out = trL +# one_delta = delta1 +# two_delta = delta2 +# fitted_residuals = y - fitted_values +# if j < iterations: +# (fitted_residuals, n, robust, temp) = lowesw(fitted_residuals, n, robust, temp) +# # +# if (iterations > 0): +# lowesp(n, y, fitted_values, weights, robust, temp, pseudovalues) +# (temp, param_tmp, a_tmp, xi_tmp, +# vert_tmp, vval_tmp, diag_tmp, trL_tmp, d1_tmp, d2_tmp, +# ) = loess_raw(pseudovalues, x, weights, weights, d, n, span, +# degree, nonparametric, order_drop_sqr, sum_drop_sqr, +# new_cell, surf_stat, temp, param_tmp, a_tmp, xi_tmp, +# vert_tmp, vval_tmp, diag_tmp, trL_tmp, d1_tmp, d2_tmp, +# zero) +# pseudo_resid = pseudovalues - temp +# # +# if (iterations == 0): +# sum_squares = numpy.sum(weights * fitted_residuals**2) +# else: +# sum_squares = numpy.sum(weights * pseudo_resid**2) +# # +# loesslogging.debug("setLf:%s" % setLf) +# loesslogging.debug("SSR:%s" % sum_squares) +# outputs.enp = (one_delta) + 2 * (trace_hat_out) - n; +# loesslogging.debug("one_delta:%s-trace_out:%s" % (one_delta, trace_hat_out)) +# outputs.s = numpy.sqrt(sum_squares / (one_delta)) +# for attr in ('one_delta','two_delta','diagonal','trace_hat', +# 'fitted_values','fitted_residuals','pseudovalues'): +# setattr(outputs,attr,eval(attr)) +## (outputs.one_delta, outputs.two_delta) = (one_delta, two_delta) +## outputs.diagonal = diagonal +## outputs. +# # +# #...................................................... +# def summary(self): +# print "Number of Observations : %d" % self.inputs.nobs +# print "Equivalent Number of Parameters: %.1f" % self.outputs.enp +# if self.model.family == "gaussian": +# print "Residual Standard Error : %.4f" % self.outputs.s +# else: +# print "Residual Scale Estimate : %.4f" % self.outputs.s +# #....................................................... +# def predict(self): +# outputs = self.outputs +# self.prediction = paramdict(fit=None, +# se_fit=None, +# residual_scale=outputs.s, +# df=outputs.one_delta**2 / outputs.two_delta, +# ) +# raise NotImplementedError +# +# +# +# +# +# +## size_info[0] = lo->in.p; +## size_info[1] = lo->in.n; +## size_info[2] = m; +## +## pred_(lo->in.y, lo->in.x, eval, size_info, &lo->out.s, +## lo->in.weights, +## lo->out.robust, +## &lo->model.span, +## &lo->model.degree, +## &lo->model.normalize, +## lo->model.parametric, +## lo->model.drop_square, +## &lo->control.surface, +## &lo->control.cell, +## &lo->model.family, +## lo->kd_tree.parameter, +## lo->kd_tree.a, +## lo->kd_tree.xi, +## lo->kd_tree.vert, +## lo->kd_tree.vval, +## lo->out.divisor, +## &se, +## pre->fit, +## pre->se_fit); +##} +# +##void +##pred_(y, x_, new_x, size_info, s, weights, robust, span, degree, +## normalize, parametric, drop_square, surface, cell, family, +## parameter, a, xi, vert, vval, divisor, se, fit, se_fit) +##double *y, *x_, *new_x, *weights, *robust, *span, *cell, *fit, *s, +## *xi, *vert, *vval, *divisor, *se_fit; +##long *size_info, *degree, *normalize, *parametric, *drop_square, +## *parameter, *a, *se; +##char **surface, **family; +##{ +## double *x, *x_tmp, *x_evaluate, *L, new_cell, z, tmp, *fit_tmp, +## *temp, sum, mean; +## long N, D, M, sum_drop_sqr = 0, sum_parametric = 0, +## nonparametric = 0, *order_parametric, *order_drop_sqr; +## int i, j, k, p, cut, comp(); +## +## D = size_info[0]; +## N = size_info[1]; +## M = size_info[2]; +## +## x = (double *) malloc(N * D * sizeof(double)); +## x_tmp = (double *) malloc(N * D * sizeof(double)); +## x_evaluate = (double *) malloc(M * D * sizeof(double)); +## L = (double *) malloc(N * M * sizeof(double)); +## order_parametric = (long *) malloc(D * sizeof(long)); +## order_drop_sqr = (long *) malloc(D * sizeof(long)); +## temp = (double *) malloc(N * D * sizeof(double)); +## +## for(i = 0; i < (N * D); i++) +## x_tmp[i] = x_[i]; +## for(i = 0; i < D; i++) { +## k = i * M; +## for(j = 0; j < M; j++) { +## p = k + j; +## new_x[p] = new_x[p] / divisor[i]; +## } +## } +## if(!strcmp(*surface, "direct") || se) { +## for(i = 0; i < D; i++) { +## k = i * N; +## for(j = 0; j < N; j++) { +## p = k + j; +## x_tmp[p] = x_[p] / divisor[i]; +## } +## } +## } +## j = D - 1; +## for(i = 0; i < D; i++) { +## sum_drop_sqr = sum_drop_sqr + drop_square[i]; +## sum_parametric = sum_parametric + parametric[i]; +## if(parametric[i]) +## order_parametric[j--] = i; +## else +## order_parametric[nonparametric++] = i; +## } +## for(i = 0; i < D; i++) { +## order_drop_sqr[i] = 2 - drop_square[order_parametric[i]]; +## k = i * M; +## p = order_parametric[i] * M; +## for(j = 0; j < M; j++) +## x_evaluate[k + j] = new_x[p + j]; +## k = i * N; +## p = order_parametric[i] * N; +## for(j = 0; j < N; j++) +## x[k + j] = x_tmp[p + j]; +## } +## for(i = 0; i < N; i++) +## robust[i] = weights[i] * robust[i]; +## +## if(!strcmp(*surface, "direct")) { +## if(*se) { +## loess_dfitse(y, x, x_evaluate, weights, robust, +## !strcmp(*family, "gaussian"), span, degree, +## &nonparametric, order_drop_sqr, &sum_drop_sqr, +## &D, &N, &M, fit, L); +## } +## else { +## loess_dfit(y, x, x_evaluate, robust, span, degree, +## &nonparametric, order_drop_sqr, &sum_drop_sqr, +## &D, &N, &M, fit); +## } +## } +## else { +## loess_ifit(parameter, a, xi, vert, vval, &M, x_evaluate, fit); +## if(*se) { +## new_cell = (*span) * (*cell); +## fit_tmp = (double *) malloc(M * sizeof(double)); +## loess_ise(y, x, x_evaluate, weights, span, degree, +## &nonparametric, order_drop_sqr, &sum_drop_sqr, +## &new_cell, &D, &N, &M, fit_tmp, L); +## free(fit_tmp); +## } +## } +## if(*se) { +## for(i = 0; i < N; i++) { +## k = i * M; +## for(j = 0; j < M; j++) { +## p = k + j; +## L[p] = L[p] / weights[i]; +## L[p] = L[p] * L[p]; +## } +## } +## for(i = 0; i < M; i++) { +## tmp = 0; +## for(j = 0; j < N; j++) +## tmp = tmp + L[i + j * M]; +## se_fit[i] = (*s) * sqrt(tmp); +## } +## } +## free(x); +## free(x_tmp); +## free(x_evaluate); +## free(L); +## free(order_parametric); +## free(order_drop_sqr); +## free(temp); +##} +## +##void +##pred_free_mem(pre) +##struct pred_struct *pre; +##{ +## free(pre->fit); +## free(pre->se_fit); +##} + + + +################################################################################ +if __name__ == '__main__': + import numpy as N + _data = open(os.path.join('examples','sin_data'), 'r') + _result = open(os.path.join('examples','sin_result'), 'r') + x = N.arange(1.,121.) + y = N.concatenate([N.fromiter((float(v) for v in L.rstrip().split()), float_) + for L in _data.readlines()]) + z = N.concatenate([N.fromiter((float(v) for v in L.rstrip().split()), float_) + for L in _result.readlines()]) +# x = N.concatenate([N.fromiter((float(v) for v in L.rstrip().split()), float_) +# for L in open('_data','r').readlines()]) +# x.shape = (-1,2) +# y = N.concatenate([N.fromiter((float(v) for v in L.rstrip().split()), float_) +# for L in open('_response','r').readlines()]) + tester = cloess.loess(x,y) + enp_theo = 4.34 + rse_theo = 0.579 + trc_smoother = 4.73 + print "OK" + tester.fit() + tester.summary() + print "Fit OK" Added: trunk/Lib/sandbox/pyloess/sandbox/setup.py =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/setup.py 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/setup.py 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,44 @@ +#!/usr/bin/env python +"""Install file for example on how to use Pyrex with Numpy. + +For more details, see: +http://www.scipy.org/Cookbook/Pyrex_and_NumPy +http://www.scipy.org/Cookbook/ArrayStruct_and_Pyrex +""" + +from distutils.core import setup +from distutils.extension import Extension + +# Make this usable by people who don't have pyrex installed (I've committed +# the generated C sources to SVN). +try: + from Pyrex.Distutils import build_ext + has_pyrex = True +except ImportError: + has_pyrex = False +import numpy + +# Define a pyrex-based extension module, using the generated sources if pyrex +# is not available. +if has_pyrex: + pyx_sources = ['cloess.pyx'] + cmdclass = {'build_ext': build_ext} +else: + pyx_sources = ['cloess.c'] + cmdclass = {} + +f_sources = ['loessf.f', 'linpack_lite.f'] +c_sources = ['loess.c', 'loessc.c'] + + +pyx_ext = Extension('cloess', + pyx_sources + c_sources + f_sources, + include_dirs = [numpy.get_include()]) + +# Call the routine which does the real work +setup(name = 'cloess', + description = 'Small example on using Pyrex to write a Numpy extension', + url = 'http://www.scipy.org/Cookbook/Pyrex_and_NumPy', + ext_modules = [pyx_ext], + cmdclass = cmdclass, + ) Added: trunk/Lib/sandbox/pyloess/sandbox/src/S.h =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/S.h 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/S.h 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,29 @@ +#include +#include + +#define Calloc(n,t) (t *)calloc((unsigned)(n),sizeof(t)) +#define Free(p) free((char *)(p)) + +/* the mapping from f77 to C intermediate code -- may be machine dependent + * the first definition satisfies lint's narrowminded preprocessing & should + * stay the same for all implementations. The __STDC__ definition is for + * ANSI standard conforming C compilers. The #else definition should + * generate the version of the fortran subroutine & common block names x + * handed to the local loader; e.g., "x_" in system V, Berkeley & 9th edition + */ + +#ifdef lint +#define F77_SUB(x) x +#define F77_COM(x) x +#else +#ifdef __STDC__ +#define F77_SUB(x) x##_ +#define F77_COM(x) x##_ +#else +#define F77_SUB(x) x/**/_ +#define F77_COM(x) x/**/_ +#endif +#endif + +#define NULL_ENTRY ((int *)NULL) + Added: trunk/Lib/sandbox/pyloess/sandbox/src/c_loess.pxd =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/c_loess.pxd 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/c_loess.pxd 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,87 @@ +# -*- Mode: Python -*- + +cdef extern from "loess.h": + ctypedef struct c_loess_inputs "loess_inputs": + long n + long p + double *y + double *x + double *weights + ctypedef struct c_loess_model "loess_model": + double span + long degree + long normalize + long parametric[8] + long drop_square[8] + char *family + ctypedef struct c_loess_control "loess_control": + char *surface + char *statistics + double cell + char *trace_hat + long iterations + ctypedef struct c_loess_kd_tree "loess_kd_tree": + long *parameter + long *a + double *xi + double *vert + double *vval + ctypedef struct c_loess_outputs "loess_outputs": + double *fitted_values + double *fitted_residuals + double enp + double s + double one_delta + double two_delta + double *pseudovalues + double trace_hat + double *diagonal + double *robust + double *divisor + ctypedef struct c_loess "loess": + c_loess_inputs inputs + c_loess_model model + c_loess_control control + c_loess_kd_tree kd_tree + c_loess_outputs outputs + #typedef struct { + # double *fit; + # double *se_fit; + # double residual_scale; + # double df; + #} predicted; + # + #struct anova_struct { + # double dfn; + # double dfd; + # double F_value; + # double Pr_F; + #}; + # + #struct ci_struct { + # double *fit; + # double *upper; + # double *lower; + #}; +cdef extern from "loess.h": + void loess_setup(double *x, double *y, long n, long p, c_loess *lo) + void loess_fit(c_loess *lo) + void loess_(double *y, double *x_, int *size_info, double *weights, + double *span, int *degree, int *parametric, int *drop_square, + int *normalize, char **statistics, char **surface, double *cell, + char **trace_hat_in, int *iterations, double *fitted_values, + double *fitted_residuals, double *enp, double *s, double *one_delta, + double *two_delta, double *pseudovalues, double *trace_hat_out, + double *diagonal, double *robust, double *divisor, long *parameter, + long *a, double *xi, double *vert, double *vval) + void loess_free_mem(c_loess *lo) + void loess_summary(c_loess *lo) + void condition(char **surface, char *new_stat, char **trace_hat_in) + int comp(double *d1, double *d2) + + void loess_raw(double *y, double *x, double *weights, double *robust, int *d, + int*n, double *span, int *degree, int *nonparametric, + int *drop_square, int *sum_drop_sqr, double *cell, char **surf_stat, + double *surface, long *parameter, long *a, double *xi, double *vert, + double *vval, double *diagonal, double *trL, double *one_delta, + double *two_delta, int *setLf) Added: trunk/Lib/sandbox/pyloess/sandbox/src/c_numpy.pxd =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/c_numpy.pxd 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/c_numpy.pxd 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,126 @@ +# :Author: Travis Oliphant + +cdef extern from "numpy/arrayobject.h": + + cdef enum NPY_TYPES: + NPY_BOOL + NPY_BYTE + NPY_UBYTE + NPY_SHORT + NPY_USHORT + NPY_INT + NPY_UINT + NPY_LONG + NPY_ULONG + NPY_LONGLONG + NPY_ULONGLONG + NPY_FLOAT + NPY_DOUBLE + NPY_LONGDOUBLE + NPY_CFLOAT + NPY_CDOUBLE + NPY_CLONGDOUBLE + NPY_OBJECT + NPY_STRING + NPY_UNICODE + NPY_VOID + NPY_NTYPES + NPY_NOTYPE + + cdef enum requirements: + NPY_CONTIGUOUS + NPY_FORTRAN + NPY_OWNDATA + NPY_FORCECAST + NPY_ENSURECOPY + NPY_ENSUREARRAY + NPY_ELEMENTSTRIDES + NPY_ALIGNED + NPY_NOTSWAPPED + NPY_WRITEABLE + NPY_UPDATEIFCOPY + NPY_ARR_HAS_DESCR + + NPY_BEHAVED + NPY_BEHAVED_NS + NPY_CARRAY + NPY_CARRAY_RO + NPY_FARRAY + NPY_FARRAY_RO + NPY_DEFAULT + + NPY_IN_ARRAY + NPY_OUT_ARRAY + NPY_INOUT_ARRAY + NPY_IN_FARRAY + NPY_OUT_FARRAY + NPY_INOUT_FARRAY + + NPY_UPDATE_ALL + + cdef enum defines: + # Note: as of Pyrex 0.9.5, enums are type-checked more strictly, so this + # can't be used as an integer. + NPY_MAXDIMS + + ctypedef struct npy_cdouble: + double real + double imag + + ctypedef struct npy_cfloat: + double real + double imag + + ctypedef int npy_intp + + ctypedef extern class numpy.dtype [object PyArray_Descr]: + cdef int type_num, elsize, alignment + cdef char type, kind, byteorder, hasobject + cdef object fields, typeobj + + ctypedef extern class numpy.ndarray [object PyArrayObject]: + cdef char *data + cdef int nd + cdef npy_intp *dimensions + cdef npy_intp *strides + cdef object base + cdef dtype descr + cdef int flags + + ctypedef extern class numpy.flatiter [object PyArrayIterObject]: + cdef int nd_m1 + cdef npy_intp index, size + cdef ndarray ao + cdef char *dataptr + + ctypedef extern class numpy.broadcast [object PyArrayMultiIterObject]: + cdef int numiter + cdef npy_intp size, index + cdef int nd + # These next two should be arrays of [NPY_MAXITER], but that is + # difficult to cleanly specify in Pyrex. Fortunately, it doesn't matter. + cdef npy_intp *dimensions + cdef void **iters + + object PyArray_ZEROS(int ndims, npy_intp* dims, NPY_TYPES type_num, int fortran) + object PyArray_EMPTY(int ndims, npy_intp* dims, NPY_TYPES type_num, int fortran) + dtype PyArray_DescrFromTypeNum(NPY_TYPES type_num) + object PyArray_SimpleNew(int ndims, npy_intp* dims, NPY_TYPES type_num) + int PyArray_Check(object obj) + object PyArray_ContiguousFromAny(object obj, NPY_TYPES type, + int mindim, int maxdim) + npy_intp PyArray_SIZE(ndarray arr) + npy_intp PyArray_NBYTES(ndarray arr) + void *PyArray_DATA(ndarray arr) + object PyArray_FromAny(object obj, dtype newtype, int mindim, int maxdim, + int requirements, object context) + object PyArray_FROMANY(object obj, NPY_TYPES type_num, int min, + int max, int requirements) + object PyArray_NewFromDescr(object subtype, dtype newtype, int nd, + npy_intp* dims, npy_intp* strides, void* data, + int flags, object parent) + + object PyArray_IterNew(object arr) + void PyArray_ITER_NEXT(flatiter it) + + void import_array() Added: trunk/Lib/sandbox/pyloess/sandbox/src/c_python.pxd =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/c_python.pxd 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/c_python.pxd 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,20 @@ +# -*- Mode: Python -*- Not really, but close enough + +# Expose as much of the Python C API as we need here + +cdef extern from "stdlib.h": + ctypedef int size_t + +cdef extern from "Python.h": + ctypedef int Py_intptr_t + void* PyMem_Malloc(size_t) + void* PyMem_Realloc(void *p, size_t n) + void PyMem_Free(void *p) + char* PyString_AsString(object string) + object PyString_FromString(char *v) + object PyString_InternFromString(char *v) + int PyErr_CheckSignals() + object PyFloat_FromDouble(double v) + void Py_XINCREF(object o) + void Py_XDECREF(object o) + void Py_CLEAR(object o) # use instead of decref Added: trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,2840 @@ +/* Generated by Pyrex 0.9.5.1a on Mon Mar 12 15:39:59 2007 */ + +#include "Python.h" +#include "structmember.h" +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifdef __cplusplus +#define __PYX_EXTERN_C extern "C" +#else +#define __PYX_EXTERN_C extern +#endif +__PYX_EXTERN_C double pow(double, double); +#include "stdlib.h" +#include "numpy/arrayobject.h" +#include "loess.h" + + +typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ +typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ + +static PyObject *__pyx_m; +static PyObject *__pyx_b; +static int __pyx_lineno; +static char *__pyx_filename; +static char **__pyx_f; + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ + +static int __Pyx_PrintItem(PyObject *); /*proto*/ +static int __Pyx_PrintNewline(void); /*proto*/ + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ + +static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ + +static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ + +static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/ + +static void __Pyx_AddTraceback(char *funcname); /*proto*/ + +/* Declarations from c_python */ + + +/* Declarations from c_numpy */ + +static PyTypeObject *__pyx_ptype_7c_numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_7c_numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_7c_numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_7c_numpy_broadcast = 0; + +/* Declarations from c_loess */ + + +/* Declarations from cloess */ + + +struct __pyx_obj_6cloess_loess_inputs { + PyObject_HEAD + loess_inputs _inputs; + long nobs; + long nvar; + PyArrayObject *x; + PyArrayObject *y; + PyArrayObject *weights; +}; + + +struct __pyx_obj_6cloess_loess_control { + PyObject_HEAD + loess_control _control; + char (*surface); + char (*statistics); + char (*trace_hat); + double cell; + int iterations; +}; + + +struct __pyx_obj_6cloess_loess_outputs { + PyObject_HEAD + loess_outputs _outputs; + PyArrayObject *fitted_values; + PyArrayObject *fitted_residuals; + PyArrayObject *pseudovalues; + PyArrayObject *diagonal; + PyArrayObject *robust; + PyArrayObject *divisor; + double enp; + double s; + double one_delta; + double two_delta; + double trace_hat; +}; + + +struct __pyx_obj_6cloess_loess_kd_tree { + PyObject_HEAD + loess_kd_tree _kdtree; + PyArrayObject *parameter; + PyArrayObject *a; + PyArrayObject *xi; + PyArrayObject *vert; + PyArrayObject *vval; +}; + + +struct __pyx_obj_6cloess_loess_model { + PyObject_HEAD + loess_model _model; + double span; + int degree; + int normalize; + char (*family); + PyObject *parametric_flags; + PyObject *drop_square_flags; +}; + + +struct __pyx_obj_6cloess_loess { + PyObject_HEAD + loess _base; + struct __pyx_obj_6cloess_loess_inputs *inputs; + struct __pyx_obj_6cloess_loess_model *model; + struct __pyx_obj_6cloess_loess_control *control; + struct __pyx_obj_6cloess_loess_kd_tree *kd_tree; + struct __pyx_obj_6cloess_loess_outputs *outputs; +}; + +static PyTypeObject *__pyx_ptype_6cloess_loess_inputs = 0; +static PyTypeObject *__pyx_ptype_6cloess_loess_control = 0; +static PyTypeObject *__pyx_ptype_6cloess_loess_outputs = 0; +static PyTypeObject *__pyx_ptype_6cloess_loess_kd_tree = 0; +static PyTypeObject *__pyx_ptype_6cloess_loess_model = 0; +static PyTypeObject *__pyx_ptype_6cloess_loess = 0; +static PyObject *__pyx_k2; +static double __pyx_k3; +static int __pyx_k4; +static int __pyx_k5; +static PyObject *__pyx_k6; +static PyObject *__pyx_k7; +static PyObject *__pyx_k9; +static PyObject *__pyx_k10; + + +/* Implementation of cloess */ + + +static PyObject *__pyx_n_c_python; +static PyObject *__pyx_n_c_numpy; +static PyObject *__pyx_n__N; +static PyObject *__pyx_n_c_loess; +static PyObject *__pyx_n_numpy; +static PyObject *__pyx_n_False; +static PyObject *__pyx_n_gaussian; + +static PyObject *__pyx_n_ndim; +static PyObject *__pyx_n_ValueError; +static PyObject *__pyx_n_len; +static PyObject *__pyx_n_size; + +static PyObject *__pyx_k11p; +static PyObject *__pyx_k12p; +static PyObject *__pyx_k13p; +static PyObject *__pyx_k14p; + +static char (__pyx_k11[]) = "DEBUG: Initializing loess_inputs..."; +static char (__pyx_k12[]) = "Argument 'x' should be 2D at most!"; +static char (__pyx_k13[]) = "Invalid size of the 'weights' vector!"; +static char (__pyx_k14[]) = " OK."; + +static int __pyx_f_6cloess_12loess_inputs___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_6cloess_12loess_inputs___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_x = 0; + PyObject *__pyx_v_y = 0; + PyObject *__pyx_v_weights = 0; + double (*__pyx_v_w_dat); + npy_intp __pyx_v_n; + npy_intp __pyx_v_p; + npy_intp (*__pyx_v_dims); + PyObject *__pyx_v_i; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + PyObject *__pyx_4 = 0; + npy_intp __pyx_5; + long __pyx_6; + static char *__pyx_argnames[] = {"x","y","weights",0}; + __pyx_v_weights = __pyx_k2; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_weights)) return -1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_x); + Py_INCREF(__pyx_v_y); + Py_INCREF(__pyx_v_weights); + __pyx_v_i = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":27 */ + if (__Pyx_PrintItem(__pyx_k11p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":28 */ + __pyx_1 = PyArray_FROMANY(__pyx_v_x,NPY_DOUBLE,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x)); + ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":29 */ + __pyx_1 = PyArray_FROMANY(__pyx_v_y,NPY_DOUBLE,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->y)); + ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->y = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":31 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x), __pyx_n_ndim); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} + __pyx_3 = __pyx_3 > 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":32 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + __Pyx_Raise(__pyx_1, __pyx_k12p, 0); + Py_DECREF(__pyx_1); __pyx_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":33 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x)); + PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x)); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_5 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_v_n = __pyx_5; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":34 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x), __pyx_n_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} + __pyx_1 = PyInt_FromLong(__pyx_v_n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} + __pyx_4 = PyNumber_Divide(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_5 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_v_p = __pyx_5; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":36 */ + ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->nobs = ((long )__pyx_v_n); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":37 */ + ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->nvar = ((long )__pyx_v_p); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":38 */ + (__pyx_v_dims[0]) = __pyx_v_n; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":40 */ + __pyx_3 = __pyx_v_weights == Py_None; + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":41 */ + __pyx_2 = PyArray_EMPTY(1,__pyx_v_dims,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights)); + ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights = ((PyArrayObject *)__pyx_2); + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":42 */ + __pyx_v_w_dat = ((double (*))((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":43 */ + __pyx_5 = (__pyx_v_dims[0]); + for (__pyx_6 = 0; __pyx_6 < __pyx_5; ++__pyx_6) { + __pyx_1 = PyInt_FromLong(__pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; goto __pyx_L1;} + Py_DECREF(__pyx_v_i); + __pyx_v_i = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":44 */ + __pyx_3 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} + (__pyx_v_w_dat[__pyx_3]) = 1; + } + goto __pyx_L3; + } + /*else*/ { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":46 */ + __pyx_4 = PyArray_FROMANY(__pyx_v_weights,NPY_DOUBLE,1,1,NPY_OWNDATA); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights)); + ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights = ((PyArrayObject *)__pyx_4); + Py_DECREF(__pyx_4); __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":47 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights), __pyx_n_ndim); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} + __pyx_3 = __pyx_3 > 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (!__pyx_3) { + __pyx_4 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights), __pyx_n_size); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(__pyx_v_n); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_4, __pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} + __pyx_3 = __pyx_3 != 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + } + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":48 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + __Pyx_Raise(__pyx_1, __pyx_k13p, 0); + Py_DECREF(__pyx_1); __pyx_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":49 */ + __pyx_v_w_dat = ((double (*))((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights->data); + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":51 */ + ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_inputs.n = ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->nobs; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":52 */ + ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_inputs.p = ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->nvar; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":53 */ + ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_inputs.x = ((double (*))((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":54 */ + ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_inputs.y = ((double (*))((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->y->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":55 */ + ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_inputs.weights = ((double (*))((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":62 */ + if (__Pyx_PrintItem(__pyx_k14p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":63 */ + __pyx_r = 0; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("cloess.loess_inputs.__init__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_i); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_x); + Py_DECREF(__pyx_v_y); + Py_DECREF(__pyx_v_weights); + return __pyx_r; +} + +static PyObject *__pyx_k15p; +static PyObject *__pyx_k19p; + +static char (__pyx_k15[]) = "DEBUG: Initializing loess_control..."; +static char (__pyx_k16[]) = "interpolate"; +static char (__pyx_k17[]) = "approximate"; +static char (__pyx_k18[]) = "wait.to.decide"; +static char (__pyx_k19[]) = "OK."; + +static int __pyx_f_6cloess_13loess_control___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_6cloess_13loess_control___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_r; + static char *__pyx_argnames[] = {0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":76 */ + if (__Pyx_PrintItem(__pyx_k15p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":77 */ + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->surface = __pyx_k16; + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_control.surface = __pyx_k16; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":78 */ + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->statistics = __pyx_k17; + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_control.statistics = __pyx_k17; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":79 */ + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->cell = 0.2; + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_control.cell = 0.2; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":80 */ + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->trace_hat = __pyx_k18; + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_control.trace_hat = __pyx_k18; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":81 */ + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->iterations = 4; + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_control.iterations = 4; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":82 */ + if (__Pyx_PrintItem(__pyx_k19p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":83 */ + __pyx_r = 0; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + __Pyx_AddTraceback("cloess.loess_control.__init__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_join; + +static PyObject *__pyx_k20p; +static PyObject *__pyx_k21p; +static PyObject *__pyx_k22p; +static PyObject *__pyx_k23p; +static PyObject *__pyx_k24p; +static PyObject *__pyx_k25p; +static PyObject *__pyx_k26p; + +static char (__pyx_k20[]) = "Control :"; +static char (__pyx_k21[]) = "Surface type : %s"; +static char (__pyx_k22[]) = "Statistics : %s"; +static char (__pyx_k23[]) = "Trace estimation : %s"; +static char (__pyx_k24[]) = "Cell size : %s"; +static char (__pyx_k25[]) = "Nb iterations : %s"; +static char (__pyx_k26[]) = "\n"; + +static PyObject *__pyx_f_6cloess_13loess_control___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_control___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_strg; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_strg = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":86 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k21p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k22p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k23p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k24p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + __pyx_6 = PyNumber_Remainder(__pyx_k25p, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyList_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; goto __pyx_L1;} + Py_INCREF(__pyx_k20p); + PyList_SET_ITEM(__pyx_1, 0, __pyx_k20p); + PyList_SET_ITEM(__pyx_1, 1, __pyx_2); + PyList_SET_ITEM(__pyx_1, 2, __pyx_3); + PyList_SET_ITEM(__pyx_1, 3, __pyx_4); + PyList_SET_ITEM(__pyx_1, 4, __pyx_5); + PyList_SET_ITEM(__pyx_1, 5, __pyx_6); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_6 = 0; + Py_DECREF(__pyx_v_strg); + __pyx_v_strg = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":92 */ + __pyx_2 = PyObject_GetAttr(__pyx_k26p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_INCREF(__pyx_v_strg); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + __Pyx_AddTraceback("cloess.loess_control.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_strg); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_pesudovalues; + +static PyObject *__pyx_k27p; +static PyObject *__pyx_k28p; + +static char (__pyx_k27[]) = "DEBUG: Initializing loess_outputs..."; +static char (__pyx_k28[]) = "OK."; + +static int __pyx_f_6cloess_13loess_outputs___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_6cloess_13loess_outputs___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_n = 0; + PyObject *__pyx_v_p = 0; + npy_intp (*__pyx_v_rows); + npy_intp (*__pyx_v_cols); + int __pyx_r; + PyObject *__pyx_1 = 0; + static char *__pyx_argnames[] = {"n","p",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_n, &__pyx_v_p)) return -1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_n); + Py_INCREF(__pyx_v_p); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":106 */ + (__pyx_v_rows[0]) = ((int )__pyx_v_n); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":107 */ + (__pyx_v_cols[0]) = ((int )__pyx_v_p); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":108 */ + if (__Pyx_PrintItem(__pyx_k27p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":110 */ + __pyx_1 = PyArray_EMPTY(1,__pyx_v_rows,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->fitted_values)); + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->fitted_values = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":111 */ + __pyx_1 = PyArray_EMPTY(1,__pyx_v_rows,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->fitted_residuals)); + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->fitted_residuals = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":112 */ + __pyx_1 = PyArray_EMPTY(1,__pyx_v_rows,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;} + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_pesudovalues, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":113 */ + __pyx_1 = PyArray_EMPTY(1,__pyx_v_rows,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->diagonal)); + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->diagonal = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":114 */ + __pyx_1 = PyArray_EMPTY(1,__pyx_v_rows,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->robust)); + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->robust = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":115 */ + __pyx_1 = PyArray_EMPTY(1,__pyx_v_cols,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->divisor)); + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->divisor = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":117 */ + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.fitted_values = ((double (*))((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->fitted_values->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":118 */ + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.fitted_residuals = ((double (*))((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->fitted_residuals->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":119 */ + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.pseudovalues = ((double (*))((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->pseudovalues->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":120 */ + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.diagonal = ((double (*))((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->diagonal->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":121 */ + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.robust = ((double (*))((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->robust->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":122 */ + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.divisor = ((double (*))((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->divisor->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":124 */ + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->enp = 0; + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.enp = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":125 */ + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->s = 0; + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.s = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":126 */ + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->one_delta = 0; + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.one_delta = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":127 */ + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->two_delta = 0; + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.two_delta = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":128 */ + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->trace_hat = 0; + ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.trace_hat = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":129 */ + if (__Pyx_PrintItem(__pyx_k28p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;} + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_outputs.__init__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_n); + Py_DECREF(__pyx_v_p); + return __pyx_r; +} + +static PyObject *__pyx_n_max; +static PyObject *__pyx_n_NPY_LONG; + +static PyObject *__pyx_k29p; +static PyObject *__pyx_k30p; +static PyObject *__pyx_k31p; +static PyObject *__pyx_k32p; + +static char (__pyx_k29[]) = "DEBUG: Initializing loess_kdtree..."; +static char (__pyx_k30[]) = "(python side)"; +static char (__pyx_k31[]) = "(C side)"; +static char (__pyx_k32[]) = "OK."; + +static int __pyx_f_6cloess_13loess_kd_tree___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_6cloess_13loess_kd_tree___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + long __pyx_v_n; + long __pyx_v_p; + long __pyx_v_maxkd; + long __pyx_v_nval; + long __pyx_v_nvert; + npy_intp (*__pyx_v_nmaxkd); + npy_intp (*__pyx_v_nnval); + npy_intp (*__pyx_v_nnvert); + npy_intp (*__pyx_v_npars); + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + long __pyx_5; + enum NPY_TYPES __pyx_6; + static char *__pyx_argnames[] = {"n","p",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ll", __pyx_argnames, &__pyx_v_n, &__pyx_v_p)) return -1; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":150 */ + if (__Pyx_PrintItem(__pyx_k29p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":151 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_max); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(__pyx_v_n); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(200); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2); + PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_5 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_v_maxkd = __pyx_5; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":152 */ + __pyx_v_nvert = (__pyx_v_p * 2); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":153 */ + __pyx_v_nval = ((__pyx_v_p + 1) * __pyx_v_maxkd); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":155 */ + if (__Pyx_PrintItem(__pyx_k30p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":156 */ + (__pyx_v_nmaxkd[0]) = ((int )__pyx_v_maxkd); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":157 */ + (__pyx_v_nnvert[0]) = ((int )__pyx_v_nvert); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":158 */ + (__pyx_v_nnval[0]) = ((int )__pyx_v_nval); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":159 */ + (__pyx_v_npars[0]) = ((int )8); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":160 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_NPY_LONG); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L1;} + __pyx_6 = ((enum NPY_TYPES )PyInt_AsLong(__pyx_3)); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_1 = PyArray_EMPTY(1,__pyx_v_npars,__pyx_6,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->parameter)); + ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->parameter = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":161 */ + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_NPY_LONG); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; goto __pyx_L1;} + __pyx_6 = ((enum NPY_TYPES )PyInt_AsLong(__pyx_4)); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_2 = PyArray_EMPTY(1,__pyx_v_nmaxkd,__pyx_6,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->a)); + ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->a = ((PyArrayObject *)__pyx_2); + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":162 */ + __pyx_3 = PyArray_EMPTY(1,__pyx_v_nmaxkd,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->xi)); + ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->xi = ((PyArrayObject *)__pyx_3); + Py_DECREF(__pyx_3); __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":163 */ + __pyx_1 = PyArray_EMPTY(1,__pyx_v_nnvert,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->vert)); + ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->vert = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":164 */ + __pyx_4 = PyArray_EMPTY(1,__pyx_v_nnval,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->vval)); + ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->vval = ((PyArrayObject *)__pyx_4); + Py_DECREF(__pyx_4); __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":171 */ + if (__Pyx_PrintItem(__pyx_k31p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":172 */ + ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->_kdtree.parameter = ((long (*))((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->parameter->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":173 */ + ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->_kdtree.a = ((long (*))((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->a->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":174 */ + ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->_kdtree.xi = ((double (*))((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->xi->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":175 */ + ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->_kdtree.vert = ((double (*))((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->vert->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":176 */ + ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->_kdtree.vval = ((double (*))((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->vval->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":187 */ + if (__Pyx_PrintItem(__pyx_k32p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":188 */ + __pyx_r = 0; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("cloess.loess_kd_tree.__init__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_hasattr; +static PyObject *__pyx_n___len__; + +static PyObject *__pyx_k33p; +static PyObject *__pyx_k36p; + +static char (__pyx_k33[]) = "DEBUG: Initializing loess_model..."; +static char (__pyx_k36[]) = "OK."; + +static int __pyx_f_6cloess_11loess_model___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_6cloess_11loess_model___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + double __pyx_v_span; + int __pyx_v_degree; + int __pyx_v_normalize; + PyObject *__pyx_v_parametric_in = 0; + PyObject *__pyx_v_drop_square_in = 0; + PyObject *__pyx_v_family = 0; + int __pyx_v_i; + int __pyx_r; + char (*__pyx_1); + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + int __pyx_5; + long __pyx_6; + long __pyx_7; + static char *__pyx_argnames[] = {"span","degree","normalize","parametric_in","drop_square_in","family",0}; + __pyx_v_span = __pyx_k3; + __pyx_v_degree = __pyx_k4; + __pyx_v_normalize = __pyx_k5; + __pyx_v_parametric_in = __pyx_k6; + __pyx_v_drop_square_in = __pyx_k7; + __pyx_v_family = __pyx_k9; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|diiOOO", __pyx_argnames, &__pyx_v_span, &__pyx_v_degree, &__pyx_v_normalize, &__pyx_v_parametric_in, &__pyx_v_drop_square_in, &__pyx_v_family)) return -1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_parametric_in); + Py_INCREF(__pyx_v_drop_square_in); + Py_INCREF(__pyx_v_family); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":208 */ + if (__Pyx_PrintItem(__pyx_k33p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":209 */ + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->span = __pyx_v_span; + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.span = __pyx_v_span; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":210 */ + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->degree = __pyx_v_degree; + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.degree = __pyx_v_degree; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":211 */ + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->normalize = __pyx_v_normalize; + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.normalize = __pyx_v_normalize; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":212 */ + __pyx_1 = PyString_AsString(__pyx_v_family); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->family = __pyx_1; + __pyx_1 = PyString_AsString(__pyx_v_family); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.family = __pyx_1; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":214 */ + __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;} + Py_INCREF(Py_None); + PyList_SET_ITEM(__pyx_2, 0, Py_None); + __pyx_3 = PyInt_FromLong(8); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;} + __pyx_4 = PyNumber_Multiply(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->parametric_flags); + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->parametric_flags = __pyx_4; + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":215 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_hasattr); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;} + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;} + Py_INCREF(__pyx_v_parametric_in); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_parametric_in); + Py_INCREF(__pyx_n___len__); + PyTuple_SET_ITEM(__pyx_3, 1, __pyx_n___len__); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (__pyx_5) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":216 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} + Py_INCREF(__pyx_v_parametric_in); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_parametric_in); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_6 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_6; ++__pyx_v_i) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":217 */ + __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;} + __pyx_3 = PyObject_GetItem(__pyx_v_parametric_in, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;} + if (PyObject_SetItem(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->parametric_flags, __pyx_4, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":218 */ + __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;} + __pyx_3 = PyObject_GetItem(__pyx_v_parametric_in, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_7 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.parametric[__pyx_v_i]) = __pyx_7; + } + goto __pyx_L2; + } + /*else*/ { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":220 */ + for (__pyx_v_i = 0; __pyx_v_i <= 7; ++__pyx_v_i) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":221 */ + __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; goto __pyx_L1;} + if (PyObject_SetItem(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->parametric_flags, __pyx_4, __pyx_v_parametric_in) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":222 */ + __pyx_7 = PyInt_AsLong(__pyx_v_parametric_in); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; goto __pyx_L1;} + (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.parametric[__pyx_v_i]) = __pyx_7; + } + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":224 */ + __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;} + Py_INCREF(Py_None); + PyList_SET_ITEM(__pyx_2, 0, Py_None); + __pyx_3 = PyInt_FromLong(8); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;} + __pyx_4 = PyNumber_Multiply(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->drop_square_flags); + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->drop_square_flags = __pyx_4; + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":225 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_hasattr); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} + Py_INCREF(__pyx_v_drop_square_in); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_drop_square_in); + Py_INCREF(__pyx_n___len__); + PyTuple_SET_ITEM(__pyx_3, 1, __pyx_n___len__); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (__pyx_5) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":226 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + Py_INCREF(__pyx_v_drop_square_in); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_drop_square_in); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_6 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_6; ++__pyx_v_i) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":227 */ + __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} + __pyx_3 = PyObject_GetItem(__pyx_v_drop_square_in, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} + if (PyObject_SetItem(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->drop_square_flags, __pyx_4, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":228 */ + __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;} + __pyx_3 = PyObject_GetItem(__pyx_v_drop_square_in, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_7 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.drop_square[__pyx_v_i]) = __pyx_7; + } + goto __pyx_L7; + } + /*else*/ { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":230 */ + for (__pyx_v_i = 0; __pyx_v_i < 8; ++__pyx_v_i) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":231 */ + __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} + if (PyObject_SetItem(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->drop_square_flags, __pyx_4, __pyx_v_drop_square_in) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":232 */ + __pyx_7 = PyInt_AsLong(__pyx_v_drop_square_in); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;} + (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.drop_square[__pyx_v_i]) = __pyx_7; + } + } + __pyx_L7:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":233 */ + if (__Pyx_PrintItem(__pyx_k36p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":246 */ + __pyx_r = 0; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("cloess.loess_model.__init__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_parametric_in); + Py_DECREF(__pyx_v_drop_square_in); + Py_DECREF(__pyx_v_family); + return __pyx_r; +} + +static PyObject *__pyx_n_id; + +static PyObject *__pyx_k37p; + +static char (__pyx_k37[]) = "loess model parameters @%s"; + +static PyObject *__pyx_f_6cloess_11loess_model___repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_model___repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":249 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} + Py_INCREF(__pyx_v_self); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = PyNumber_Remainder(__pyx_k37p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_model.__repr__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n___name__; +static PyObject *__pyx_n_parametric; +static PyObject *__pyx_n_drop_square; + +static PyObject *__pyx_k38p; +static PyObject *__pyx_k39p; +static PyObject *__pyx_k40p; +static PyObject *__pyx_k41p; +static PyObject *__pyx_k42p; +static PyObject *__pyx_k43p; +static PyObject *__pyx_k44p; +static PyObject *__pyx_k45p; + +static char (__pyx_k38[]) = "Object : %s"; +static char (__pyx_k39[]) = "family : %s"; +static char (__pyx_k40[]) = "span : %s"; +static char (__pyx_k41[]) = "degree : %s"; +static char (__pyx_k42[]) = "normalized : %s"; +static char (__pyx_k43[]) = "parametric : %s"; +static char (__pyx_k44[]) = "drop_square : %s"; +static char (__pyx_k45[]) = "\n"; + +static PyObject *__pyx_f_6cloess_11loess_model___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_model___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_strg; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + PyObject *__pyx_7 = 0; + PyObject *__pyx_8 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_strg = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":251 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___name__); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k38p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k39p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k40p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k41p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.normalize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;} + __pyx_6 = PyNumber_Remainder(__pyx_k42p, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_parametric); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;} + __pyx_7 = PyNumber_Remainder(__pyx_k43p, __pyx_1); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_drop_square); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;} + __pyx_8 = PyNumber_Remainder(__pyx_k44p, __pyx_1); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyList_New(7); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + PyList_SET_ITEM(__pyx_1, 0, __pyx_2); + PyList_SET_ITEM(__pyx_1, 1, __pyx_3); + PyList_SET_ITEM(__pyx_1, 2, __pyx_4); + PyList_SET_ITEM(__pyx_1, 3, __pyx_5); + PyList_SET_ITEM(__pyx_1, 4, __pyx_6); + PyList_SET_ITEM(__pyx_1, 5, __pyx_7); + PyList_SET_ITEM(__pyx_1, 6, __pyx_8); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_6 = 0; + __pyx_7 = 0; + __pyx_8 = 0; + Py_DECREF(__pyx_v_strg); + __pyx_v_strg = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":258 */ + __pyx_2 = PyObject_GetAttr(__pyx_k45p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} + Py_INCREF(__pyx_v_strg); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + Py_XDECREF(__pyx_7); + Py_XDECREF(__pyx_8); + __Pyx_AddTraceback("cloess.loess_model.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_strg); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k46p; + +static char (__pyx_k46[]) = "DEBUG:Initializing loess_cside"; + +static int __pyx_f_6cloess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_6cloess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_x = 0; + PyObject *__pyx_v_y = 0; + PyObject *__pyx_v_weights = 0; + long __pyx_v_n; + long __pyx_v_p; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + static char *__pyx_argnames[] = {"x","y","weights",0}; + __pyx_v_weights = __pyx_k10; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_weights)) return -1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_x); + Py_INCREF(__pyx_v_y); + Py_INCREF(__pyx_v_weights); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":285 */ + __pyx_1 = PyTuple_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; goto __pyx_L1;} + Py_INCREF(__pyx_v_x); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_x); + Py_INCREF(__pyx_v_y); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_y); + Py_INCREF(__pyx_v_weights); + PyTuple_SET_ITEM(__pyx_1, 2, __pyx_v_weights); + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_inputs), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_inputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs)); + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs = ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_2); + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":286 */ + __pyx_v_n = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs->nobs; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":287 */ + __pyx_v_p = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs->nvar; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":288 */ + __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_model), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_6cloess_loess_model)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model)); + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model = ((struct __pyx_obj_6cloess_loess_model *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":289 */ + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_control), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_control)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control)); + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control = ((struct __pyx_obj_6cloess_loess_control *)__pyx_2); + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":290 */ + __pyx_1 = PyInt_FromLong(__pyx_v_n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); + PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); + __pyx_1 = 0; + __pyx_2 = 0; + __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_outputs), __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_6cloess_loess_outputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs)); + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs = ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":291 */ + __pyx_2 = PyInt_FromLong(__pyx_v_n); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(__pyx_v_p); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;} + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_kd_tree), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_kd_tree)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree)); + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree = ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_2); + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":293 */ + if (__Pyx_PrintItem(__pyx_k46p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":294 */ + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.inputs = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs->_inputs; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":295 */ + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.model = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model->_model; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":296 */ + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.control = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control->_control; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":297 */ + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.kd_tree = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree->_kdtree; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":298 */ + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.outputs = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->_outputs; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess.__init__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_x); + Py_DECREF(__pyx_v_y); + Py_DECREF(__pyx_v_weights); + return __pyx_r; +} + +static PyObject *__pyx_n_n; + +static PyObject *__pyx_k47p; +static PyObject *__pyx_k48p; +static PyObject *__pyx_k50p; +static PyObject *__pyx_k51p; + +static char (__pyx_k47[]) = "Number of Observations : %d"; +static char (__pyx_k48[]) = "Equivalent Number of Parameters: %.1f"; +static char (__pyx_k49[]) = "gaussian"; +static char (__pyx_k50[]) = "Residual Standard Error : %.4f"; +static char (__pyx_k51[]) = "Residual Scale Estimate : %.4f"; + +static PyObject *__pyx_f_6cloess_5loess_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6cloess_5loess_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + static char *__pyx_argnames[] = {0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":310 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs), __pyx_n_n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k47p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":311 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k48p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":312 */ + __pyx_3 = (((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model->family == __pyx_k49); + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":313 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k50p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} + goto __pyx_L2; + } + /*else*/ { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":315 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k51p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;} + } + __pyx_L2:; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + __Pyx_AddTraceback("cloess.loess.summary"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static __Pyx_InternTabEntry __pyx_intern_tab[] = { + {&__pyx_n_False, "False"}, + {&__pyx_n_NPY_LONG, "NPY_LONG"}, + {&__pyx_n_ValueError, "ValueError"}, + {&__pyx_n__N, "_N"}, + {&__pyx_n___len__, "__len__"}, + {&__pyx_n___name__, "__name__"}, + {&__pyx_n_c_loess, "c_loess"}, + {&__pyx_n_c_numpy, "c_numpy"}, + {&__pyx_n_c_python, "c_python"}, + {&__pyx_n_drop_square, "drop_square"}, + {&__pyx_n_gaussian, "gaussian"}, + {&__pyx_n_hasattr, "hasattr"}, + {&__pyx_n_id, "id"}, + {&__pyx_n_join, "join"}, + {&__pyx_n_len, "len"}, + {&__pyx_n_max, "max"}, + {&__pyx_n_n, "n"}, + {&__pyx_n_ndim, "ndim"}, + {&__pyx_n_numpy, "numpy"}, + {&__pyx_n_parametric, "parametric"}, + {&__pyx_n_pesudovalues, "pesudovalues"}, + {&__pyx_n_size, "size"}, + {0, 0} +}; + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_k11p, __pyx_k11, sizeof(__pyx_k11)}, + {&__pyx_k12p, __pyx_k12, sizeof(__pyx_k12)}, + {&__pyx_k13p, __pyx_k13, sizeof(__pyx_k13)}, + {&__pyx_k14p, __pyx_k14, sizeof(__pyx_k14)}, + {&__pyx_k15p, __pyx_k15, sizeof(__pyx_k15)}, + {&__pyx_k19p, __pyx_k19, sizeof(__pyx_k19)}, + {&__pyx_k20p, __pyx_k20, sizeof(__pyx_k20)}, + {&__pyx_k21p, __pyx_k21, sizeof(__pyx_k21)}, + {&__pyx_k22p, __pyx_k22, sizeof(__pyx_k22)}, + {&__pyx_k23p, __pyx_k23, sizeof(__pyx_k23)}, + {&__pyx_k24p, __pyx_k24, sizeof(__pyx_k24)}, + {&__pyx_k25p, __pyx_k25, sizeof(__pyx_k25)}, + {&__pyx_k26p, __pyx_k26, sizeof(__pyx_k26)}, + {&__pyx_k27p, __pyx_k27, sizeof(__pyx_k27)}, + {&__pyx_k28p, __pyx_k28, sizeof(__pyx_k28)}, + {&__pyx_k29p, __pyx_k29, sizeof(__pyx_k29)}, + {&__pyx_k30p, __pyx_k30, sizeof(__pyx_k30)}, + {&__pyx_k31p, __pyx_k31, sizeof(__pyx_k31)}, + {&__pyx_k32p, __pyx_k32, sizeof(__pyx_k32)}, + {&__pyx_k33p, __pyx_k33, sizeof(__pyx_k33)}, + {&__pyx_k36p, __pyx_k36, sizeof(__pyx_k36)}, + {&__pyx_k37p, __pyx_k37, sizeof(__pyx_k37)}, + {&__pyx_k38p, __pyx_k38, sizeof(__pyx_k38)}, + {&__pyx_k39p, __pyx_k39, sizeof(__pyx_k39)}, + {&__pyx_k40p, __pyx_k40, sizeof(__pyx_k40)}, + {&__pyx_k41p, __pyx_k41, sizeof(__pyx_k41)}, + {&__pyx_k42p, __pyx_k42, sizeof(__pyx_k42)}, + {&__pyx_k43p, __pyx_k43, sizeof(__pyx_k43)}, + {&__pyx_k44p, __pyx_k44, sizeof(__pyx_k44)}, + {&__pyx_k45p, __pyx_k45, sizeof(__pyx_k45)}, + {&__pyx_k46p, __pyx_k46, sizeof(__pyx_k46)}, + {&__pyx_k47p, __pyx_k47, sizeof(__pyx_k47)}, + {&__pyx_k48p, __pyx_k48, sizeof(__pyx_k48)}, + {&__pyx_k50p, __pyx_k50, sizeof(__pyx_k50)}, + {&__pyx_k51p, __pyx_k51, sizeof(__pyx_k51)}, + {0, 0, 0} +}; + +static PyObject *__pyx_tp_new_6cloess_loess_inputs(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_6cloess_loess_inputs *p = (struct __pyx_obj_6cloess_loess_inputs *)o; + p->x = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->y = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6cloess_loess_inputs(PyObject *o) { + struct __pyx_obj_6cloess_loess_inputs *p = (struct __pyx_obj_6cloess_loess_inputs *)o; + Py_XDECREF(((PyObject *)p->x)); + Py_XDECREF(((PyObject *)p->y)); + Py_XDECREF(((PyObject *)p->weights)); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6cloess_loess_inputs(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6cloess_loess_inputs *p = (struct __pyx_obj_6cloess_loess_inputs *)o; + if (p->x) { + e = (*v)(((PyObject*)p->x), a); if (e) return e; + } + if (p->y) { + e = (*v)(((PyObject*)p->y), a); if (e) return e; + } + if (p->weights) { + e = (*v)(((PyObject*)p->weights), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6cloess_loess_inputs(PyObject *o) { + struct __pyx_obj_6cloess_loess_inputs *p = (struct __pyx_obj_6cloess_loess_inputs *)o; + Py_XDECREF(((PyObject *)p->x)); + p->x = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->y)); + p->y = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->weights)); + p->weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return 0; +} + +static struct PyMethodDef __pyx_methods_6cloess_loess_inputs[] = { + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_6cloess_loess_inputs[] = { + {"nobs", T_LONG, offsetof(struct __pyx_obj_6cloess_loess_inputs, nobs), 0, 0}, + {"nvar", T_LONG, offsetof(struct __pyx_obj_6cloess_loess_inputs, nvar), 0, 0}, + {"x", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess_inputs, x), READONLY, 0}, + {"y", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess_inputs, y), READONLY, 0}, + {"weights", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess_inputs, weights), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_inputs = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_inputs = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_inputs = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_inputs = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6cloess_loess_inputs = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "cloess.loess_inputs", /*tp_name*/ + sizeof(struct __pyx_obj_6cloess_loess_inputs), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6cloess_loess_inputs, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_inputs, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_inputs, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_inputs, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_inputs, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6cloess_loess_inputs, /*tp_traverse*/ + __pyx_tp_clear_6cloess_loess_inputs, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6cloess_loess_inputs, /*tp_methods*/ + __pyx_members_6cloess_loess_inputs, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_f_6cloess_12loess_inputs___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6cloess_loess_inputs, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_6cloess_loess_control(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + return o; +} + +static void __pyx_tp_dealloc_6cloess_loess_control(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6cloess_loess_control(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_6cloess_loess_control(PyObject *o) { + return 0; +} + +static struct PyMethodDef __pyx_methods_6cloess_loess_control[] = { + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_6cloess_loess_control[] = { + {"surface", T_STRING, offsetof(struct __pyx_obj_6cloess_loess_control, surface), 0, 0}, + {"statistics", T_STRING, offsetof(struct __pyx_obj_6cloess_loess_control, statistics), 0, 0}, + {"trace_hat", T_STRING, offsetof(struct __pyx_obj_6cloess_loess_control, trace_hat), 0, 0}, + {"cell", T_DOUBLE, offsetof(struct __pyx_obj_6cloess_loess_control, cell), 0, 0}, + {"iterations", T_INT, offsetof(struct __pyx_obj_6cloess_loess_control, iterations), 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_control = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_control = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_control = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_control = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6cloess_loess_control = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "cloess.loess_control", /*tp_name*/ + sizeof(struct __pyx_obj_6cloess_loess_control), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6cloess_loess_control, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_control, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_control, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_control, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_f_6cloess_13loess_control___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_control, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6cloess_loess_control, /*tp_traverse*/ + __pyx_tp_clear_6cloess_loess_control, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6cloess_loess_control, /*tp_methods*/ + __pyx_members_6cloess_loess_control, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_f_6cloess_13loess_control___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6cloess_loess_control, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_6cloess_loess_outputs(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_6cloess_loess_outputs *p = (struct __pyx_obj_6cloess_loess_outputs *)o; + p->fitted_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->fitted_residuals = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->pseudovalues = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->diagonal = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->robust = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->divisor = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6cloess_loess_outputs(PyObject *o) { + struct __pyx_obj_6cloess_loess_outputs *p = (struct __pyx_obj_6cloess_loess_outputs *)o; + Py_XDECREF(((PyObject *)p->fitted_values)); + Py_XDECREF(((PyObject *)p->fitted_residuals)); + Py_XDECREF(((PyObject *)p->pseudovalues)); + Py_XDECREF(((PyObject *)p->diagonal)); + Py_XDECREF(((PyObject *)p->robust)); + Py_XDECREF(((PyObject *)p->divisor)); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6cloess_loess_outputs(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6cloess_loess_outputs *p = (struct __pyx_obj_6cloess_loess_outputs *)o; + if (p->fitted_values) { + e = (*v)(((PyObject*)p->fitted_values), a); if (e) return e; + } + if (p->fitted_residuals) { + e = (*v)(((PyObject*)p->fitted_residuals), a); if (e) return e; + } + if (p->pseudovalues) { + e = (*v)(((PyObject*)p->pseudovalues), a); if (e) return e; + } + if (p->diagonal) { + e = (*v)(((PyObject*)p->diagonal), a); if (e) return e; + } + if (p->robust) { + e = (*v)(((PyObject*)p->robust), a); if (e) return e; + } + if (p->divisor) { + e = (*v)(((PyObject*)p->divisor), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6cloess_loess_outputs(PyObject *o) { + struct __pyx_obj_6cloess_loess_outputs *p = (struct __pyx_obj_6cloess_loess_outputs *)o; + Py_XDECREF(((PyObject *)p->fitted_values)); + p->fitted_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->fitted_residuals)); + p->fitted_residuals = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->pseudovalues)); + p->pseudovalues = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->diagonal)); + p->diagonal = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->robust)); + p->robust = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->divisor)); + p->divisor = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return 0; +} + +static struct PyMethodDef __pyx_methods_6cloess_loess_outputs[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_outputs = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_outputs = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_outputs = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_outputs = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6cloess_loess_outputs = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "cloess.loess_outputs", /*tp_name*/ + sizeof(struct __pyx_obj_6cloess_loess_outputs), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6cloess_loess_outputs, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_outputs, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_outputs, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_outputs, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_outputs, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6cloess_loess_outputs, /*tp_traverse*/ + __pyx_tp_clear_6cloess_loess_outputs, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6cloess_loess_outputs, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_f_6cloess_13loess_outputs___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6cloess_loess_outputs, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_6cloess_loess_kd_tree(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_6cloess_loess_kd_tree *p = (struct __pyx_obj_6cloess_loess_kd_tree *)o; + p->parameter = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->a = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->xi = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->vert = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->vval = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6cloess_loess_kd_tree(PyObject *o) { + struct __pyx_obj_6cloess_loess_kd_tree *p = (struct __pyx_obj_6cloess_loess_kd_tree *)o; + Py_XDECREF(((PyObject *)p->parameter)); + Py_XDECREF(((PyObject *)p->a)); + Py_XDECREF(((PyObject *)p->xi)); + Py_XDECREF(((PyObject *)p->vert)); + Py_XDECREF(((PyObject *)p->vval)); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6cloess_loess_kd_tree(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6cloess_loess_kd_tree *p = (struct __pyx_obj_6cloess_loess_kd_tree *)o; + if (p->parameter) { + e = (*v)(((PyObject*)p->parameter), a); if (e) return e; + } + if (p->a) { + e = (*v)(((PyObject*)p->a), a); if (e) return e; + } + if (p->xi) { + e = (*v)(((PyObject*)p->xi), a); if (e) return e; + } + if (p->vert) { + e = (*v)(((PyObject*)p->vert), a); if (e) return e; + } + if (p->vval) { + e = (*v)(((PyObject*)p->vval), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6cloess_loess_kd_tree(PyObject *o) { + struct __pyx_obj_6cloess_loess_kd_tree *p = (struct __pyx_obj_6cloess_loess_kd_tree *)o; + Py_XDECREF(((PyObject *)p->parameter)); + p->parameter = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->a)); + p->a = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->xi)); + p->xi = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->vert)); + p->vert = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->vval)); + p->vval = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return 0; +} + +static struct PyMethodDef __pyx_methods_6cloess_loess_kd_tree[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_kd_tree = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_kd_tree = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_kd_tree = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_kd_tree = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6cloess_loess_kd_tree = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "cloess.loess_kd_tree", /*tp_name*/ + sizeof(struct __pyx_obj_6cloess_loess_kd_tree), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6cloess_loess_kd_tree, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_kd_tree, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_kd_tree, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_kd_tree, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_kd_tree, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6cloess_loess_kd_tree, /*tp_traverse*/ + __pyx_tp_clear_6cloess_loess_kd_tree, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6cloess_loess_kd_tree, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_f_6cloess_13loess_kd_tree___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6cloess_loess_kd_tree, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_6cloess_loess_model(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_6cloess_loess_model *p = (struct __pyx_obj_6cloess_loess_model *)o; + p->parametric_flags = Py_None; Py_INCREF(Py_None); + p->drop_square_flags = Py_None; Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6cloess_loess_model(PyObject *o) { + struct __pyx_obj_6cloess_loess_model *p = (struct __pyx_obj_6cloess_loess_model *)o; + Py_XDECREF(p->parametric_flags); + Py_XDECREF(p->drop_square_flags); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6cloess_loess_model(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6cloess_loess_model *p = (struct __pyx_obj_6cloess_loess_model *)o; + if (p->parametric_flags) { + e = (*v)(p->parametric_flags, a); if (e) return e; + } + if (p->drop_square_flags) { + e = (*v)(p->drop_square_flags, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6cloess_loess_model(PyObject *o) { + struct __pyx_obj_6cloess_loess_model *p = (struct __pyx_obj_6cloess_loess_model *)o; + Py_XDECREF(p->parametric_flags); + p->parametric_flags = Py_None; Py_INCREF(Py_None); + Py_XDECREF(p->drop_square_flags); + p->drop_square_flags = Py_None; Py_INCREF(Py_None); + return 0; +} + +static struct PyMethodDef __pyx_methods_6cloess_loess_model[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_model = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_model = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_model = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_model = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6cloess_loess_model = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "cloess.loess_model", /*tp_name*/ + sizeof(struct __pyx_obj_6cloess_loess_model), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6cloess_loess_model, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + __pyx_f_6cloess_11loess_model___repr__, /*tp_repr*/ + &__pyx_tp_as_number_loess_model, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_model, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_model, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_f_6cloess_11loess_model___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_model, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6cloess_loess_model, /*tp_traverse*/ + __pyx_tp_clear_6cloess_loess_model, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6cloess_loess_model, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_f_6cloess_11loess_model___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6cloess_loess_model, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_6cloess_loess(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_6cloess_loess *p = (struct __pyx_obj_6cloess_loess *)o; + p->inputs = ((struct __pyx_obj_6cloess_loess_inputs *)Py_None); Py_INCREF(Py_None); + p->model = ((struct __pyx_obj_6cloess_loess_model *)Py_None); Py_INCREF(Py_None); + p->control = ((struct __pyx_obj_6cloess_loess_control *)Py_None); Py_INCREF(Py_None); + p->kd_tree = ((struct __pyx_obj_6cloess_loess_kd_tree *)Py_None); Py_INCREF(Py_None); + p->outputs = ((struct __pyx_obj_6cloess_loess_outputs *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6cloess_loess(PyObject *o) { + struct __pyx_obj_6cloess_loess *p = (struct __pyx_obj_6cloess_loess *)o; + Py_XDECREF(((PyObject *)p->inputs)); + Py_XDECREF(((PyObject *)p->model)); + Py_XDECREF(((PyObject *)p->control)); + Py_XDECREF(((PyObject *)p->kd_tree)); + Py_XDECREF(((PyObject *)p->outputs)); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6cloess_loess(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6cloess_loess *p = (struct __pyx_obj_6cloess_loess *)o; + if (p->inputs) { + e = (*v)(((PyObject*)p->inputs), a); if (e) return e; + } + if (p->model) { + e = (*v)(((PyObject*)p->model), a); if (e) return e; + } + if (p->control) { + e = (*v)(((PyObject*)p->control), a); if (e) return e; + } + if (p->kd_tree) { + e = (*v)(((PyObject*)p->kd_tree), a); if (e) return e; + } + if (p->outputs) { + e = (*v)(((PyObject*)p->outputs), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6cloess_loess(PyObject *o) { + struct __pyx_obj_6cloess_loess *p = (struct __pyx_obj_6cloess_loess *)o; + Py_XDECREF(((PyObject *)p->inputs)); + p->inputs = ((struct __pyx_obj_6cloess_loess_inputs *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->model)); + p->model = ((struct __pyx_obj_6cloess_loess_model *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->control)); + p->control = ((struct __pyx_obj_6cloess_loess_control *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->kd_tree)); + p->kd_tree = ((struct __pyx_obj_6cloess_loess_kd_tree *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->outputs)); + p->outputs = ((struct __pyx_obj_6cloess_loess_outputs *)Py_None); Py_INCREF(Py_None); + return 0; +} + +static struct PyMethodDef __pyx_methods_6cloess_loess[] = { + {"summary", (PyCFunction)__pyx_f_6cloess_5loess_summary, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6cloess_loess = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "cloess.loess", /*tp_name*/ + sizeof(struct __pyx_obj_6cloess_loess), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6cloess_loess, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6cloess_loess, /*tp_traverse*/ + __pyx_tp_clear_6cloess_loess, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6cloess_loess, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_f_6cloess_5loess___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6cloess_loess, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static struct PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +static void __pyx_init_filenames(void); /*proto*/ + +PyMODINIT_FUNC initcloess(void); /*proto*/ +PyMODINIT_FUNC initcloess(void) { + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + __pyx_init_filenames(); + __pyx_m = Py_InitModule4("cloess", __pyx_methods, 0, 0, PYTHON_API_VERSION); + if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + __pyx_b = PyImport_AddModule("__builtin__"); + if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + __pyx_type_6cloess_loess_inputs.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_inputs", (PyObject *)&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} + __pyx_ptype_6cloess_loess_inputs = &__pyx_type_6cloess_loess_inputs; + if (PyType_Ready(&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_control", (PyObject *)&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L1;} + __pyx_ptype_6cloess_loess_control = &__pyx_type_6cloess_loess_control; + __pyx_type_6cloess_loess_outputs.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_outputs", (PyObject *)&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;} + __pyx_ptype_6cloess_loess_outputs = &__pyx_type_6cloess_loess_outputs; + __pyx_type_6cloess_loess_kd_tree.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_kd_tree", (PyObject *)&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;} + __pyx_ptype_6cloess_loess_kd_tree = &__pyx_type_6cloess_loess_kd_tree; + __pyx_type_6cloess_loess_model.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_model", (PyObject *)&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + __pyx_ptype_6cloess_loess_model = &__pyx_type_6cloess_loess_model; + __pyx_type_6cloess_loess.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess", (PyObject *)&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} + __pyx_ptype_6cloess_loess = &__pyx_type_6cloess_loess; + __pyx_ptype_7c_numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (!__pyx_ptype_7c_numpy_dtype) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; goto __pyx_L1;} + __pyx_ptype_7c_numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (!__pyx_ptype_7c_numpy_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 81; goto __pyx_L1;} + __pyx_ptype_7c_numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject)); if (!__pyx_ptype_7c_numpy_flatiter) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 90; goto __pyx_L1;} + __pyx_ptype_7c_numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject)); if (!__pyx_ptype_7c_numpy_broadcast) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":7 */ + __pyx_1 = __Pyx_Import(__pyx_n_numpy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} + if (PyObject_SetAttr(__pyx_m, __pyx_n__N, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":9 */ + import_array(); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":22 */ + Py_INCREF(Py_None); + __pyx_k2 = Py_None; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":202 */ + __pyx_k3 = 0.75; + __pyx_k4 = 2; + __pyx_k5 = 1; + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;} + __pyx_k6 = __pyx_1; + __pyx_1 = 0; + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;} + __pyx_k7 = __pyx_2; + __pyx_2 = 0; + Py_INCREF(__pyx_n_gaussian); + __pyx_k9 = __pyx_n_gaussian; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":273 */ + Py_INCREF(Py_None); + __pyx_k10 = Py_None; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":309 */ + return; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + __Pyx_AddTraceback("cloess"); +} + +static char *__pyx_filenames[] = { + "cloess.pyx", + "c_numpy.pxd", +}; + +/* Runtime support code */ + +static void __pyx_init_filenames(void) { + __pyx_f = __pyx_filenames; +} + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) { + PyObject *__import__ = 0; + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + __import__ = PyObject_GetAttrString(__pyx_b, "__import__"); + if (!__import__) + goto bad; + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + module = PyObject_CallFunction(__import__, "OOOO", + name, global_dict, empty_dict, list); +bad: + Py_XDECREF(empty_list); + Py_XDECREF(__import__); + Py_XDECREF(empty_dict); + return module; +} + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { + PyObject *result; + result = PyObject_GetAttr(dict, name); + if (!result) + PyErr_SetObject(PyExc_NameError, name); + return result; +} + +static PyObject *__Pyx_GetStdout(void) { + PyObject *f = PySys_GetObject("stdout"); + if (!f) { + PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); + } + return f; +} + +static int __Pyx_PrintItem(PyObject *v) { + PyObject *f; + + if (!(f = __Pyx_GetStdout())) + return -1; + if (PyFile_SoftSpace(f, 1)) { + if (PyFile_WriteString(" ", f) < 0) + return -1; + } + if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) + return -1; + if (PyString_Check(v)) { + char *s = PyString_AsString(v); + int len = PyString_Size(v); + if (len > 0 && + isspace(Py_CHARMASK(s[len-1])) && + s[len-1] != ' ') + PyFile_SoftSpace(f, 0); + } + return 0; +} + +static int __Pyx_PrintNewline(void) { + PyObject *f; + + if (!(f = __Pyx_GetStdout())) + return -1; + if (PyFile_WriteString("\n", f) < 0) + return -1; + PyFile_SoftSpace(f, 0); + return 0; +} + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { + Py_XINCREF(type); + Py_XINCREF(value); + Py_XINCREF(tb); + /* First, check the traceback argument, replacing None with NULL. */ + if (tb == Py_None) { + Py_DECREF(tb); + tb = 0; + } + else if (tb != NULL && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + /* Next, replace a missing value with None */ + if (value == NULL) { + value = Py_None; + Py_INCREF(value); + } + /* Next, repeatedly, replace a tuple exception with its first item */ + while (PyTuple_Check(type) && PyTuple_Size(type) > 0) { + PyObject *tmp = type; + type = PyTuple_GET_ITEM(type, 0); + Py_INCREF(type); + Py_DECREF(tmp); + } + if (PyString_Check(type)) { + if (PyErr_Warn(PyExc_DeprecationWarning, + "raising a string exception is deprecated")) + goto raise_error; + } + else if (PyType_Check(type) || PyClass_Check(type)) + ; /*PyErr_NormalizeException(&type, &value, &tb);*/ + else { + /* Raising an instance. The value should be a dummy. */ + if (value != Py_None) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + /* Normalize to raise , */ + Py_DECREF(value); + value = type; + if (PyInstance_Check(type)) + type = (PyObject*) ((PyInstanceObject*)type)->in_class; + else + type = (PyObject*) type->ob_type; + Py_INCREF(type); + } + PyErr_Restore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} + +static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (obj == Py_None || PyObject_TypeCheck(obj, type)) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s", + obj->ob_type->tp_name, type->tp_name); + return 0; +} + +static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) { + while (t->p) { + *t->p = PyString_InternFromString(t->s); + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, + long size) +{ + PyObject *py_module_name = 0; + PyObject *py_class_name = 0; + PyObject *py_name_list = 0; + PyObject *py_module = 0; + PyObject *result = 0; + + py_module_name = PyString_FromString(module_name); + if (!py_module_name) + goto bad; + py_class_name = PyString_FromString(class_name); + if (!py_class_name) + goto bad; + py_name_list = PyList_New(1); + if (!py_name_list) + goto bad; + Py_INCREF(py_class_name); + if (PyList_SetItem(py_name_list, 0, py_class_name) < 0) + goto bad; + py_module = __Pyx_Import(py_module_name, py_name_list); + if (!py_module) + goto bad; + result = PyObject_GetAttr(py_module, py_class_name); + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%s.%s is not a type object", + module_name, class_name); + goto bad; + } + if (((PyTypeObject *)result)->tp_basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%s.%s does not appear to be the correct type object", + module_name, class_name); + goto bad; + } + goto done; +bad: + Py_XDECREF(result); + result = 0; +done: + Py_XDECREF(py_module_name); + Py_XDECREF(py_class_name); + Py_XDECREF(py_name_list); + return (PyTypeObject *)result; +} + +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" + +static void __Pyx_AddTraceback(char *funcname) { + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + PyObject *py_globals = 0; + PyObject *empty_tuple = 0; + PyObject *empty_string = 0; + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + + py_srcfile = PyString_FromString(__pyx_filename); + if (!py_srcfile) goto bad; + py_funcname = PyString_FromString(funcname); + if (!py_funcname) goto bad; + py_globals = PyModule_GetDict(__pyx_m); + if (!py_globals) goto bad; + empty_tuple = PyTuple_New(0); + if (!empty_tuple) goto bad; + empty_string = PyString_FromString(""); + if (!empty_string) goto bad; + py_code = PyCode_New( + 0, /*int argcount,*/ + 0, /*int nlocals,*/ + 0, /*int stacksize,*/ + 0, /*int flags,*/ + empty_string, /*PyObject *code,*/ + empty_tuple, /*PyObject *consts,*/ + empty_tuple, /*PyObject *names,*/ + empty_tuple, /*PyObject *varnames,*/ + empty_tuple, /*PyObject *freevars,*/ + empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + __pyx_lineno, /*int firstlineno,*/ + empty_string /*PyObject *lnotab*/ + ); + if (!py_code) goto bad; + py_frame = PyFrame_New( + PyThreadState_Get(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + py_globals, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = __pyx_lineno; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + Py_XDECREF(empty_tuple); + Py_XDECREF(empty_string); + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} Added: trunk/Lib/sandbox/pyloess/sandbox/src/cloess.h =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/cloess.h 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/cloess.h 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,87 @@ +#include +#include +#include "loess.h" +/* +loess.c +*/ +void loess_setup(double *x, double *y, int n, int p, loess *lo); +void loess_fit(loess *lo); +void +loess_(double *y, double *x_, int *size_info, double *weights, double *span, + int *degree, int *parametric, int *drop_square, int *normalize, + char **statistics, char **surface, double *cell, char **trace_hat_in, + int *iterations, double *fitted_values, double *fitted_residuals, + double *enp, double *s, double *one_delta, double *two_delta, + double *pseudovalues, double *trace_hat_out, double *diagonal, + double *robust, double *divisor, int *parameter, int *a, double *xi, + double *vert, double *vval); +void loess_free_mem(loess *lo); +void loess_summary(loess *lo); +void condition(char **surface, char *new_stat, char **trace_hat_in); +int comp(double *d1, double *d2); + +/* +loessc.c +*/ +void +loess_raw(double *y, double *x, double *weights, double *robust, int *d, + int*n, double *span, int *degree, int *nonparametric, + int *drop_square, int *sum_drop_sqr, double *cell, char **surf_stat, + double *surface, int *parameter, int *a, double *xi, double *vert, + double *vval, double *diagonal, double *trL, double *one_delta, + double *two_delta, int *setLf); +void +loess_dfit(double *y, double *x, double *x_evaluate, double *weights, + double *span, int *degree, int *nonparametric, + int *drop_square, int *sum_drop_sqr, int *d, int *n, int *m, + double *fit); +void +loess_dfitse(double *y, double *x, double *x_evaluate, double *weights, + double *robust, int *family, double *span, int *degree, + int *nonparametric, int *drop_square, int *sum_drop_sqr, + int *d, int *n, int *m, double *fit, double *L); +void +loess_ifit(int *parameter, int *a, double *xi, double *vert, double *vval, + int *m, double *x_evaluate, double *fit); +void +loess_ise(double *y, double *x, double *x_evaluate, double *weights, + double *span, int *degree, int *nonparametric, int *drop_square, + int *sum_drop_sqr, double *cell, int *d, int *n, int *m, + double *fit, double *L); +void +loess_workspace(int *d, int *n, double *span, int *degree, + int *nonparametric, int *drop_square, int *sum_drop_sqr, + int *setLf); +void +loess_prune(int *parameter, int *a, double *xi, double *vert, double *vval); +void +loess_grow(int *parameter, int *a, double *xi, double *vert, double *vval); +void +F77_SUB(lowesw)(double *res, int *n, double *rw, int *pi); +void +F77_SUB(lowesp)(int *n, double *y, double *yhat, double *pwgts, + double *rwgts, int *pi, double *ytilde); + +// +///* +//misc.c +//*/ +//void +//anova(struct loess_struct *one, struct loess_struct *two, +// struct anova_struct *out); +// +///* +//predict.c +//*/ +//void +//predict(double *eval, int m, struct loess_struct *lo, struct pred_struct *pre, +// int se); +//void +//pred_(double *y, double *x_, double *new_x, int *size_info, double *s, +// double *weights, double *robust, double *span, int *degree, +// int *normalize, int *parametric, int *drop_square, char **surface, +// double *cell, char **family, int *parameter, int *a, double *xi, +// double *vert, double *vval, double *divisor, int *se, double *fit, +// double *se_fit); +//void +//pred_free_mem(struct pred_struct *pre); Added: trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,315 @@ +# -*- Mode: Python -*- +cimport c_python +cimport c_numpy +from c_numpy cimport ndarray, npy_intp, \ + PyArray_SIZE, PyArray_EMPTY, PyArray_FROMANY, \ + NPY_INT, NPY_DOUBLE, NPY_OWNDATA, NPY_ALIGNED +import numpy as _N +# NumPy must be initialized +c_numpy.import_array() + +cimport c_loess + +#####--------------------------------------------------------------------------- +#---- ---- loess model --- +#####--------------------------------------------------------------------------- + +cdef class loess_inputs: + cdef c_loess.c_loess_inputs _inputs + cdef public long nobs, nvar + cdef readonly ndarray x, y, weights + + def __init__(self, object x, object y, object weights=None): + cdef ndarray x_ndr, y_ndr + cdef double *x_dat, *y_in_dat, *w_dat + cdef npy_intp n, p + cdef npy_intp *dims + print "DEBUG: Initializing loess_inputs...", + self.x = PyArray_FROMANY(x, NPY_DOUBLE, 1, 1, NPY_OWNDATA) + self.y = PyArray_FROMANY(y, NPY_DOUBLE, 1, 1, NPY_OWNDATA) + # + if self.x.ndim > 2: + raise ValueError,"Argument 'x' should be 2D at most!" + n = len(self.x) + p = self.x.size / n + # Initialize the python side ............ + self.nobs = n + self.nvar = p + dims[0] = n + # ... input weights ... + if weights is None: + self.weights = PyArray_EMPTY(1, dims, NPY_DOUBLE, NPY_ALIGNED) + w_dat = self.weights.data + for i from 0 <= i < dims[0]: + w_dat[i] = 1 + else: + self.weights = PyArray_FROMANY(weights, NPY_DOUBLE, 1, 1, NPY_OWNDATA) + if self.weights.ndim > 1 or self.weights.size != n: + raise ValueError, "Invalid size of the 'weights' vector!" + w_dat = self.weights.data + # Initialize the underlying C object .... + self._inputs.n = self.nobs + self._inputs.p = self.nvar + self._inputs.x = self.x.data + self._inputs.y = self.y.data + self._inputs.weights = self.weights.data + +# for i from 0 <= i < (self.nobs*self.nvar): +# self._inputs.x[i] = self.x.data[i] +# for i from 0 <= i < self.nobs: +# self._inputs.y[i] = self.y.data[i] +# self._inputs.weights[i] = w_dat[i] + print " OK." + return + + +#####--------------------------------------------------------------------------- +#---- ---- loess control --- +#####--------------------------------------------------------------------------- +cdef class loess_control: + cdef c_loess.c_loess_control _control + cdef public char *surface, *statistics, *trace_hat + cdef public double cell + cdef public int iterations + + def __init__(self): + print "DEBUG: Initializing loess_control...", + self.surface = self._control.surface = "interpolate" + self.statistics = self._control.statistics = "approximate" + self.cell = self._control.cell = 0.2 + self.trace_hat = self._control.trace_hat = "wait.to.decide" + self.iterations = self._control.iterations = 4 + print "OK." + return + + def __str__(self): + strg = ["Control :", + "Surface type : %s" % self.surface, + "Statistics : %s" % self.statistics, + "Trace estimation : %s" % self.trace_hat, + "Cell size : %s" % self.cell, + "Nb iterations : %s" % self.iterations,] + return '\n'.join(strg) + + +#####--------------------------------------------------------------------------- +#---- ---- loess outputs --- +#####--------------------------------------------------------------------------- +cdef class loess_outputs: + cdef c_loess.c_loess_outputs _outputs + cdef ndarray fitted_values, fitted_residuals, pseudovalues, diagonal, robust, divisor + cdef double enp, s, one_delta, two_delta, trace_hat + + def __init__(self, n, p): + cdef npy_intp *rows, *cols + #cdef double *fv_dat, *fr_dat, *pv_dat, *diag_dat, *rw_dat, *div_dat + rows[0] = n + cols[0] = p + print "DEBUG: Initializing loess_outputs...", + # Initialize the python side ............ + self.fitted_values = PyArray_EMPTY(1, rows, NPY_DOUBLE, NPY_ALIGNED) + self.fitted_residuals = PyArray_EMPTY(1, rows, NPY_DOUBLE, NPY_ALIGNED) + self.pesudovalues = PyArray_EMPTY(1, rows, NPY_DOUBLE, NPY_ALIGNED) + self.diagonal = PyArray_EMPTY(1, rows, NPY_DOUBLE, NPY_ALIGNED) + self.robust = PyArray_EMPTY(1, rows, NPY_DOUBLE, NPY_ALIGNED) + self.divisor = PyArray_EMPTY(1, cols, NPY_DOUBLE, NPY_ALIGNED) + # Initialize the C side ................. + self._outputs.fitted_values = self.fitted_values.data + self._outputs.fitted_residuals = self.fitted_residuals.data + self._outputs.pseudovalues = self.pseudovalues.data + self._outputs.diagonal = self.diagonal.data + self._outputs.robust = self.robust.data + self._outputs.divisor = self.divisor.data + # Common initialization ................. + self.enp = self._outputs.enp = 0 + self.s = self._outputs.s = 0 + self.one_delta = self._outputs.one_delta = 0 + self.two_delta = self._outputs.two_delta = 0 + self.trace_hat = self._outputs.trace_hat = 0 + print "OK." + +# def __str__(self): +# strg = ["Outputs :", +# "enp : %s" % self.enp, +# "s : %s" % self.s, +# "Deltas : %s/%s" % (self.one_delta, self.two_delta), +# "Divisor : %s" % self.divisor,] +# return '\n'.join(strg) + +#####--------------------------------------------------------------------------- +#---- ---- loess kd_tree --- +#####--------------------------------------------------------------------------- +cdef class loess_kd_tree: + cdef c_loess.c_loess_kd_tree _kdtree + cdef ndarray parameter, a, xi, vert, vval + + def __init__(self, long n, long p): + cdef long maxkd, nval, nvert + cdef npy_intp *nmaxkd, *nnval, *nnvert, *npars + # + print "DEBUG: Initializing loess_kdtree...", + maxkd = max(n, 200) + nvert = p * 2 + nval = (p+1) * maxkd + # Initialize the python side ............ + print "(python side)", + nmaxkd[0] = maxkd + nnvert[0] = nvert + nnval[0] = nval + npars[0] = 8 + self.parameter = PyArray_EMPTY(1, npars, NPY_LONG, NPY_ALIGNED) + self.a = PyArray_EMPTY(1, nmaxkd, NPY_LONG, NPY_ALIGNED) + self.xi = PyArray_EMPTY(1, nmaxkd, NPY_DOUBLE, NPY_ALIGNED) + self.vert = PyArray_EMPTY(1, nnvert, NPY_DOUBLE, NPY_ALIGNED) + self.vval = PyArray_EMPTY(1, nnval, NPY_DOUBLE, NPY_ALIGNED) +# self.parameter = _N.empty((8,), _N.long, order='F') +# self.a = _N.empty((maxkd,), _N.long, order='F') +# self.xi = _N.empty((maxkd,), _N.float, order='F') +# self.vert = _N.empty((p*2,), _N.float, order='F') +# self.vval = _N.empty((nnval,), _N.float, order='F') + # Initialize the C side ................. + print "(C side)", + self._kdtree.parameter = self.parameter.data + self._kdtree.a = self.a.data + self._kdtree.xi = self.xi.data + self._kdtree.vert = self.vert.data + self._kdtree.vval = self.vval.data +# # FIXME : Do we need to fill the arrays ? +# for i from 0 <= i < 8: +# self._kdtree.parameter[i] = 0 +# for i from 0 <= i < len(self.a): +# self._kdtree.a[i] = 0 +# self._kdtree.xi[i] = 0 +# for i from 0 <= i < (p*2): +# self._kdtree.vert[i] = 0 +# for i from 0 <= i < nnval: +# self._kdtree.vval[i] = 0 + print "OK." + return + +#####--------------------------------------------------------------------------- +#---- ---- loess model --- +#####--------------------------------------------------------------------------- + +cdef class loess_model: + cdef c_loess.c_loess_model _model + cdef double span + cdef int degree, normalize + cdef char *family +# cdef ndarray parametric_flags, drop_square_flags + cdef object parametric_flags, drop_square_flags + # + def __init__(self, double span=0.75, int degree=2, int normalize=1, + object parametric_in=False, object drop_square_in=False, + object family="gaussian"): + cdef int i + cdef int *parmf_dat, *dropsq_dat + cdef npy_intp *npars + print "DEBUG: Initializing loess_model...", + self.span = self._model.span = span + self.degree = self._model.degree = degree + self.normalize = self._model.normalize = normalize + self.family = self._model.family = family + # FIXME : trying to use a ndarray crashes around here.... + self.parametric_flags = [None]*8 + if hasattr(parametric_in, '__len__'): + for i from 0 <= i < len(parametric_in): + self.parametric_flags[i] = parametric_in[i] + self._model.parametric[i] = parametric_in[i] + else: + for i from 0 <= i <=7: + self.parametric_flags[i] = parametric_in + self._model.parametric[i] = parametric_in + #.... + self.drop_square_flags = [None]*8 + if hasattr(drop_square_in, '__len__'): + for i from 0 <= i < len(drop_square_in): + self.drop_square_flags[i] = drop_square_in[i] + self._model.drop_square[i] = drop_square_in[i] + else: + for i from 0 <= i < 8: + self.drop_square_flags[i] = drop_square_in + self._model.drop_square[i] = drop_square_in + print "OK." +# npars[0] = 8 +# self.parametric = PyArray_EMPTY(1, npars, NPY_INT, NPY_ALIGNED) +# self.drop_square = PyArray_EMPTY(1, npars, NPY_INT, NPY_ALIGNED) +# parmf_dat = self.parametric_flags.data +# dropsq_dat = self.drop_square_flags.data +# for i from 0 <= i < 8: +# print "i:%i" % i +# parmf_dat[i] = 0 +# self._model.parametric[i] = parmf_dat[i] +# dropsq_dat[i] = 0 +# self._model.drop_square[i] = dropsq_dat[i] +# print "DEBUG: loess_model: initialized" + return + # + def __repr__(self): + return "loess model parameters @%s" % id(self) + def __str__(self): + strg = ["Object : %s" % self.__name__, + "family : %s" % self._model.family, + "span : %s" % self._model.span, + "degree : %s" % self._model.degree, + "normalized : %s" % self._model.normalize, + "parametric : %s" % self.parametric, + "drop_square : %s" % self.drop_square] + return '\n'.join(strg) + +#####--------------------------------------------------------------------------- +#---- ---- loess base class --- +#####--------------------------------------------------------------------------- + +cdef class loess: +# cdef c_loess.c_loess *_base # If we try the pure C way + cdef c_loess.c_loess _base + cdef loess_inputs inputs + cdef loess_model model + cdef loess_control control + cdef loess_kd_tree kd_tree + cdef loess_outputs outputs + + def __init__(self, object x, object y, object weights=None): + # + cdef ndarray x_ndr, y_ndr + cdef double *x_dat, *y_dat + cdef long n, p + cdef int i + # +# print "Try setup" +# # CHECK : The following function segfaults :( +# c_loess.loess_setup(x_dat, y_dat, n, d, self._base) +# # CHECK : So we gonna try the hard way + # Initialize the python side ............ + self.inputs = loess_inputs(x, y, weights) + n = self.inputs.nobs + p = self.inputs.nvar + self.model = loess_model() + self.control = loess_control() + self.outputs = loess_outputs(n,p) + self.kd_tree = loess_kd_tree(n,p) + # Initialize the C side ................. + print "DEBUG:Initializing loess_cside" + self._base.inputs = self.inputs._inputs + self._base.model = self.model._model + self._base.control = self.control._control + self._base.kd_tree = self.kd_tree._kdtree + self._base.outputs = self.outputs._outputs + + + +# self.inputs = base.in +# self.model = base.model +# self.kd_tree = base.kd_tree +# self.outputs = base.out + + + #...................................................... + def summary(self): + print "Number of Observations : %d" % self.inputs.n + print "Equivalent Number of Parameters: %.1f" % self.outputs.enp + if self.model.family == "gaussian": + print "Residual Standard Error : %.4f" % self.outputs.s + else: + print "Residual Scale Estimate : %.4f" % self.outputs.s \ No newline at end of file Added: trunk/Lib/sandbox/pyloess/sandbox/src/linpack_lite.f =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/linpack_lite.f 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/linpack_lite.f 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,757 @@ + subroutine dqrsl(x,ldx,n,k,qraux,y,qy,qty,b,rsd,xb,job,info) + integer ldx,n,k,job,info + double precision x(ldx,1),qraux(1),y(1),qy(1),qty(1),b(1),rsd(1), + * xb(1) +c +c dqrsl applies the output of dqrdc to compute coordinate +c transformations, projections, and least squares solutions. +c for k .le. min(n,p), let xk be the matrix +c +c xk = (x(jpvt(1)),x(jpvt(2)), ... ,x(jpvt(k))) +c +c formed from columnns jpvt(1), ... ,jpvt(k) of the original +c n x p matrix x that was input to dqrdc (if no pivoting was +c done, xk consists of the first k columns of x in their +c original order). dqrdc produces a factored orthogonal matrix q +c and an upper triangular matrix r such that +c +c xk = q * (r) +c (0) +c +c this information is contained in coded form in the arrays +c x and qraux. +c +c on entry +c +c x double precision(ldx,p). +c x contains the output of dqrdc. +c +c ldx integer. +c ldx is the leading dimension of the array x. +c +c n integer. +c n is the number of rows of the matrix xk. it must +c have the same value as n in dqrdc. +c +c k integer. +c k is the number of columns of the matrix xk. k +c must nnot be greater than min(n,p), where p is the +c same as in the calling sequence to dqrdc. +c +c qraux double precision(p). +c qraux contains the auxiliary output from dqrdc. +c +c y double precision(n) +c y contains an n-vector that is to be manipulated +c by dqrsl. +c +c job integer. +c job specifies what is to be computed. job has +c the decimal expansion abcde, with the following +c meaning. +c +c if a.ne.0, compute qy. +c if b,c,d, or e .ne. 0, compute qty. +c if c.ne.0, compute b. +c if d.ne.0, compute rsd. +c if e.ne.0, compute xb. +c +c note that a request to compute b, rsd, or xb +c automatically triggers the computation of qty, for +c which an array must be provided in the calling +c sequence. +c +c on return +c +c qy double precision(n). +c qy conntains q*y, if its computation has been +c requested. +c +c qty double precision(n). +c qty contains trans(q)*y, if its computation has +c been requested. here trans(q) is the +c transpose of the matrix q. +c +c b double precision(k) +c b contains the solution of the least squares problem +c +c minimize norm2(y - xk*b), +c +c if its computation has been requested. (note that +c if pivoting was requested in dqrdc, the j-th +c component of b will be associated with column jpvt(j) +c of the original matrix x that was input into dqrdc.) +c +c rsd double precision(n). +c rsd contains the least squares residual y - xk*b, +c if its computation has been requested. rsd is +c also the orthogonal projection of y onto the +c orthogonal complement of the column space of xk. +c +c xb double precision(n). +c xb contains the least squares approximation xk*b, +c if its computation has been requested. xb is also +c the orthogonal projection of y onto the column space +c of x. +c +c info integer. +c info is zero unless the computation of b has +c been requested and r is exactly singular. in +c this case, info is the index of the first zero +c diagonal element of r and b is left unaltered. +c +c the parameters qy, qty, b, rsd, and xb are not referenced +c if their computation is not requested and in this case +c can be replaced by dummy variables in the calling program. +c to save storage, the user may in some cases use the same +c array for different parameters in the calling sequence. a +c frequently occuring example is when one wishes to compute +c any of b, rsd, or xb and does not need y or qty. in this +c case one may identify y, qty, and one of b, rsd, or xb, while +c providing separate arrays for anything else that is to be +c computed. thus the calling sequence +c +c call dqrsl(x,ldx,n,k,qraux,y,dum,y,b,y,dum,110,info) +c +c will result in the computation of b and rsd, with rsd +c overwriting y. more generally, each item in the following +c list contains groups of permissible identifications for +c a single callinng sequence. +c +c 1. (y,qty,b) (rsd) (xb) (qy) +c +c 2. (y,qty,rsd) (b) (xb) (qy) +c +c 3. (y,qty,xb) (b) (rsd) (qy) +c +c 4. (y,qy) (qty,b) (rsd) (xb) +c +c 5. (y,qy) (qty,rsd) (b) (xb) +c +c 6. (y,qy) (qty,xb) (b) (rsd) +c +c in any group the value returned in the array allocated to +c the group corresponds to the last member of the group. +c +c linpack. this version dated 08/14/78 . +c g.w. stewart, university of maryland, argonne national lab. +c +c dqrsl uses the following functions and subprograms. +c +c blas daxpy,dcopy,ddot +c fortran dabs,min0,mod +c +c internal variables +c + integer i,j,jj,ju,kp1 + double precision ddot,t,temp + logical cb,cqy,cqty,cr,cxb +c +c +c set info flag. +c + info = 0 +c +c determine what is to be computed. +c + cqy = job/10000 .ne. 0 + cqty = mod(job,10000) .ne. 0 + cb = mod(job,1000)/100 .ne. 0 + cr = mod(job,100)/10 .ne. 0 + cxb = mod(job,10) .ne. 0 + ju = min0(k,n-1) +c +c special action when n=1. +c + if (ju .ne. 0) go to 40 + if (cqy) qy(1) = y(1) + if (cqty) qty(1) = y(1) + if (cxb) xb(1) = y(1) + if (.not.cb) go to 30 + if (x(1,1) .ne. 0.0d0) go to 10 + info = 1 + go to 20 + 10 continue + b(1) = y(1)/x(1,1) + 20 continue + 30 continue + if (cr) rsd(1) = 0.0d0 + go to 250 + 40 continue +c +c set up to compute qy or qty. +c + if (cqy) call dcopy(n,y,1,qy,1) + if (cqty) call dcopy(n,y,1,qty,1) + if (.not.cqy) go to 70 +c +c compute qy. +c + do 60 jj = 1, ju + j = ju - jj + 1 + if (qraux(j) .eq. 0.0d0) go to 50 + temp = x(j,j) + x(j,j) = qraux(j) + t = -ddot(n-j+1,x(j,j),1,qy(j),1)/x(j,j) + call daxpy(n-j+1,t,x(j,j),1,qy(j),1) + x(j,j) = temp + 50 continue + 60 continue + 70 continue + if (.not.cqty) go to 100 +c +c compute trans(q)*y. +c + do 90 j = 1, ju + if (qraux(j) .eq. 0.0d0) go to 80 + temp = x(j,j) + x(j,j) = qraux(j) + t = -ddot(n-j+1,x(j,j),1,qty(j),1)/x(j,j) + call daxpy(n-j+1,t,x(j,j),1,qty(j),1) + x(j,j) = temp + 80 continue + 90 continue + 100 continue +c +c set up to compute b, rsd, or xb. +c + if (cb) call dcopy(k,qty,1,b,1) + kp1 = k + 1 + if (cxb) call dcopy(k,qty,1,xb,1) + if (cr .and. k .lt. n) call dcopy(n-k,qty(kp1),1,rsd(kp1),1) + if (.not.cxb .or. kp1 .gt. n) go to 120 + do 110 i = kp1, n + xb(i) = 0.0d0 + 110 continue + 120 continue + if (.not.cr) go to 140 + do 130 i = 1, k + rsd(i) = 0.0d0 + 130 continue + 140 continue + if (.not.cb) go to 190 +c +c compute b. +c + do 170 jj = 1, k + j = k - jj + 1 + if (x(j,j) .ne. 0.0d0) go to 150 + info = j +c ......exit + go to 180 + 150 continue + b(j) = b(j)/x(j,j) + if (j .eq. 1) go to 160 + t = -b(j) + call daxpy(j-1,t,x(1,j),1,b,1) + 160 continue + 170 continue + 180 continue + 190 continue + if (.not.cr .and. .not.cxb) go to 240 +c +c compute rsd or xb as required. +c + do 230 jj = 1, ju + j = ju - jj + 1 + if (qraux(j) .eq. 0.0d0) go to 220 + temp = x(j,j) + x(j,j) = qraux(j) + if (.not.cr) go to 200 + t = -ddot(n-j+1,x(j,j),1,rsd(j),1)/x(j,j) + call daxpy(n-j+1,t,x(j,j),1,rsd(j),1) + 200 continue + if (.not.cxb) go to 210 + t = -ddot(n-j+1,x(j,j),1,xb(j),1)/x(j,j) + call daxpy(n-j+1,t,x(j,j),1,xb(j),1) + 210 continue + x(j,j) = temp + 220 continue + 230 continue + 240 continue + 250 continue + return + end +c...................................................................... + subroutine dsvdc(x,ldx,n,p,s,e,u,ldu,v,ldv,work,job,info) + integer ldx,n,p,ldu,ldv,job,info + double precision x(ldx,1),s(1),e(1),u(ldu,1),v(ldv,1),work(1) +c +c +c dsvdc is a subroutine to reduce a double precision nxp matrix x +c by orthogonal transformations u and v to diagonal form. the +c diagonal elements s(i) are the singular values of x. the +c columns of u are the corresponding left singular vectors, +c and the columns of v the right singular vectors. +c +c on entry +c +c x double precision(ldx,p), where ldx.ge.n. +c x contains the matrix whose singular value +c decomposition is to be computed. x is +c destroyed by dsvdc. +c +c ldx integer. +c ldx is the leading dimension of the array x. +c +c n integer. +c n is the number of rows of the matrix x. +c +c p integer. +c p is the number of columns of the matrix x. +c +c ldu integer. +c ldu is the leading dimension of the array u. +c (see below). +c +c ldv integer. +c ldv is the leading dimension of the array v. +c (see below). +c +c work double precision(n). +c work is a scratch array. +c +c job integer. +c job controls the computation of the singular +c vectors. it has the decimal expansion ab +c with the following meaning +c +c a.eq.0 do not compute the left singular +c vectors. +c a.eq.1 return the n left singular vectors +c in u. +c a.ge.2 return the first min(n,p) singular +c vectors in u. +c b.eq.0 do not compute the right singular +c vectors. +c b.eq.1 return the right singular vectors +c in v. +c +c on return +c +c s double precision(mm), where mm=min(n+1,p). +c the first min(n,p) entries of s contain the +c singular values of x arranged in descending +c order of magnitude. +c +c e double precision(p), +c e ordinarily contains zeros. however see the +c discussion of info for exceptions. +c +c u double precision(ldu,k), where ldu.ge.n. if +c joba.eq.1 then k.eq.n, if joba.ge.2 +c then k.eq.min(n,p). +c u contains the matrix of left singular vectors. +c u is not referenced if joba.eq.0. if n.le.p +c or if joba.eq.2, then u may be identified with x +c in the subroutine call. +c +c v double precision(ldv,p), where ldv.ge.p. +c v contains the matrix of right singular vectors. +c v is not referenced if job.eq.0. if p.le.n, +c then v may be identified with x in the +c subroutine call. +c +c info integer. +c the singular values (and their corresponding +c singular vectors) s(info+1),s(info+2),...,s(m) +c are correct (here m=min(n,p)). thus if +c info.eq.0, all the singular values and their +c vectors are correct. in any event, the matrix +c b = trans(u)*x*v is the bidiagonal matrix +c with the elements of s on its diagonal and the +c elements of e on its super-diagonal (trans(u) +c is the transpose of u). thus the singular +c values of x and b are the same. +c +c linpack. this version dated 08/14/78 . +c correction made to shift 2/84. +c g.w. stewart, university of maryland, argonne national lab. +c +c dsvdc uses the following functions and subprograms. +c +c external drot +c blas daxpy,ddot,dscal,dswap,dnrm2,drotg +c fortran dabs,dmax1,max0,min0,mod,dsqrt +c +c internal variables +c + integer i,iter,j,jobu,k,kase,kk,l,ll,lls,lm1,lp1,ls,lu,m,maxit, + * mm,mm1,mp1,nct,nctp1,ncu,nrt,nrtp1 + double precision ddot,t,r + double precision b,c,cs,el,emm1,f,g,dnrm2,scale,shift,sl,sm,sn, + * smm1,t1,test,ztest + logical wantu,wantv +c +c +c set the maximum number of iterations. +c + maxit = 30 +c +c determine what is to be computed. +c + wantu = .false. + wantv = .false. + jobu = mod(job,100)/10 + ncu = n + if (jobu .gt. 1) ncu = min0(n,p) + if (jobu .ne. 0) wantu = .true. + if (mod(job,10) .ne. 0) wantv = .true. +c +c reduce x to bidiagonal form, storing the diagonal elements +c in s and the super-diagonal elements in e. +c + info = 0 + nct = min0(n-1,p) + nrt = max0(0,min0(p-2,n)) + lu = max0(nct,nrt) + if (lu .lt. 1) go to 170 + do 160 l = 1, lu + lp1 = l + 1 + if (l .gt. nct) go to 20 +c +c compute the transformation for the l-th column and +c place the l-th diagonal in s(l). +c + s(l) = dnrm2(n-l+1,x(l,l),1) + if (s(l) .eq. 0.0d0) go to 10 + if (x(l,l) .ne. 0.0d0) s(l) = dsign(s(l),x(l,l)) + call dscal(n-l+1,1.0d0/s(l),x(l,l),1) + x(l,l) = 1.0d0 + x(l,l) + 10 continue + s(l) = -s(l) + 20 continue + if (p .lt. lp1) go to 50 + do 40 j = lp1, p + if (l .gt. nct) go to 30 + if (s(l) .eq. 0.0d0) go to 30 +c +c apply the transformation. +c + t = -ddot(n-l+1,x(l,l),1,x(l,j),1)/x(l,l) + call daxpy(n-l+1,t,x(l,l),1,x(l,j),1) + 30 continue +c +c place the l-th row of x into e for the +c subsequent calculation of the row transformation. +c + e(j) = x(l,j) + 40 continue + 50 continue + if (.not.wantu .or. l .gt. nct) go to 70 +c +c place the transformation in u for subsequent back +c multiplication. +c + do 60 i = l, n + u(i,l) = x(i,l) + 60 continue + 70 continue + if (l .gt. nrt) go to 150 +c +c compute the l-th row transformation and place the +c l-th super-diagonal in e(l). +c + e(l) = dnrm2(p-l,e(lp1),1) + if (e(l) .eq. 0.0d0) go to 80 + if (e(lp1) .ne. 0.0d0) e(l) = dsign(e(l),e(lp1)) + call dscal(p-l,1.0d0/e(l),e(lp1),1) + e(lp1) = 1.0d0 + e(lp1) + 80 continue + e(l) = -e(l) + if (lp1 .gt. n .or. e(l) .eq. 0.0d0) go to 120 +c +c apply the transformation. +c + do 90 i = lp1, n + work(i) = 0.0d0 + 90 continue + do 100 j = lp1, p + call daxpy(n-l,e(j),x(lp1,j),1,work(lp1),1) + 100 continue + do 110 j = lp1, p + call daxpy(n-l,-e(j)/e(lp1),work(lp1),1,x(lp1,j),1) + 110 continue + 120 continue + if (.not.wantv) go to 140 +c +c place the transformation in v for subsequent +c back multiplication. +c + do 130 i = lp1, p + v(i,l) = e(i) + 130 continue + 140 continue + 150 continue + 160 continue + 170 continue +c +c set up the final bidiagonal matrix or order m. +c + m = min0(p,n+1) + nctp1 = nct + 1 + nrtp1 = nrt + 1 + if (nct .lt. p) s(nctp1) = x(nctp1,nctp1) + if (n .lt. m) s(m) = 0.0d0 + if (nrtp1 .lt. m) e(nrtp1) = x(nrtp1,m) + e(m) = 0.0d0 +c +c if required, generate u. +c + if (.not.wantu) go to 300 + if (ncu .lt. nctp1) go to 200 + do 190 j = nctp1, ncu + do 180 i = 1, n + u(i,j) = 0.0d0 + 180 continue + u(j,j) = 1.0d0 + 190 continue + 200 continue + if (nct .lt. 1) go to 290 + do 280 ll = 1, nct + l = nct - ll + 1 + if (s(l) .eq. 0.0d0) go to 250 + lp1 = l + 1 + if (ncu .lt. lp1) go to 220 + do 210 j = lp1, ncu + t = -ddot(n-l+1,u(l,l),1,u(l,j),1)/u(l,l) + call daxpy(n-l+1,t,u(l,l),1,u(l,j),1) + 210 continue + 220 continue + call dscal(n-l+1,-1.0d0,u(l,l),1) + u(l,l) = 1.0d0 + u(l,l) + lm1 = l - 1 + if (lm1 .lt. 1) go to 240 + do 230 i = 1, lm1 + u(i,l) = 0.0d0 + 230 continue + 240 continue + go to 270 + 250 continue + do 260 i = 1, n + u(i,l) = 0.0d0 + 260 continue + u(l,l) = 1.0d0 + 270 continue + 280 continue + 290 continue + 300 continue +c +c if it is required, generate v. +c + if (.not.wantv) go to 350 + do 340 ll = 1, p + l = p - ll + 1 + lp1 = l + 1 + if (l .gt. nrt) go to 320 + if (e(l) .eq. 0.0d0) go to 320 + do 310 j = lp1, p + t = -ddot(p-l,v(lp1,l),1,v(lp1,j),1)/v(lp1,l) + call daxpy(p-l,t,v(lp1,l),1,v(lp1,j),1) + 310 continue + 320 continue + do 330 i = 1, p + v(i,l) = 0.0d0 + 330 continue + v(l,l) = 1.0d0 + 340 continue + 350 continue +c +c main iteration loop for the singular values. +c + mm = m + iter = 0 + 360 continue +c +c quit if all the singular values have been found. +c +c ...exit + if (m .eq. 0) go to 620 +c +c if too many iterations have been performed, set +c flag and return. +c + if (iter .lt. maxit) go to 370 + info = m +c ......exit + go to 620 + 370 continue +c +c this section of the program inspects for +c negligible elements in the s and e arrays. on +c completion the variables kase and l are set as follows. +c +c kase = 1 if s(m) and e(l-1) are negligible and l.lt.m +c kase = 2 if s(l) is negligible and l.lt.m +c kase = 3 if e(l-1) is negligible, l.lt.m, and +c s(l), ..., s(m) are not negligible (qr step). +c kase = 4 if e(m-1) is negligible (convergence). +c + do 390 ll = 1, m + l = m - ll +c ...exit + if (l .eq. 0) go to 400 + test = dabs(s(l)) + dabs(s(l+1)) + ztest = test + dabs(e(l)) + if (ztest .ne. test) go to 380 + e(l) = 0.0d0 +c ......exit + go to 400 + 380 continue + 390 continue + 400 continue + if (l .ne. m - 1) go to 410 + kase = 4 + go to 480 + 410 continue + lp1 = l + 1 + mp1 = m + 1 + do 430 lls = lp1, mp1 + ls = m - lls + lp1 +c ...exit + if (ls .eq. l) go to 440 + test = 0.0d0 + if (ls .ne. m) test = test + dabs(e(ls)) + if (ls .ne. l + 1) test = test + dabs(e(ls-1)) + ztest = test + dabs(s(ls)) + if (ztest .ne. test) go to 420 + s(ls) = 0.0d0 +c ......exit + go to 440 + 420 continue + 430 continue + 440 continue + if (ls .ne. l) go to 450 + kase = 3 + go to 470 + 450 continue + if (ls .ne. m) go to 460 + kase = 1 + go to 470 + 460 continue + kase = 2 + l = ls + 470 continue + 480 continue + l = l + 1 +c +c perform the task indicated by kase. +c + go to (490,520,540,570), kase +c +c deflate negligible s(m). +c + 490 continue + mm1 = m - 1 + f = e(m-1) + e(m-1) = 0.0d0 + do 510 kk = l, mm1 + k = mm1 - kk + l + t1 = s(k) + call drotg(t1,f,cs,sn) + s(k) = t1 + if (k .eq. l) go to 500 + f = -sn*e(k-1) + e(k-1) = cs*e(k-1) + 500 continue + if (wantv) call drot(p,v(1,k),1,v(1,m),1,cs,sn) + 510 continue + go to 610 +c +c split at negligible s(l). +c + 520 continue + f = e(l-1) + e(l-1) = 0.0d0 + do 530 k = l, m + t1 = s(k) + call drotg(t1,f,cs,sn) + s(k) = t1 + f = -sn*e(k) + e(k) = cs*e(k) + if (wantu) call drot(n,u(1,k),1,u(1,l-1),1,cs,sn) + 530 continue + go to 610 +c +c perform one qr step. +c + 540 continue +c +c calculate the shift. +c + scale = dmax1(dabs(s(m)),dabs(s(m-1)),dabs(e(m-1)), + * dabs(s(l)),dabs(e(l))) + sm = s(m)/scale + smm1 = s(m-1)/scale + emm1 = e(m-1)/scale + sl = s(l)/scale + el = e(l)/scale + b = ((smm1 + sm)*(smm1 - sm) + emm1**2)/2.0d0 + c = (sm*emm1)**2 + shift = 0.0d0 + if (b .eq. 0.0d0 .and. c .eq. 0.0d0) go to 550 + shift = dsqrt(b**2+c) + if (b .lt. 0.0d0) shift = -shift + shift = c/(b + shift) + 550 continue + f = (sl + sm)*(sl - sm) + shift + g = sl*el +c +c chase zeros. +c + mm1 = m - 1 + do 560 k = l, mm1 + call drotg(f,g,cs,sn) + if (k .ne. l) e(k-1) = f + f = cs*s(k) + sn*e(k) + e(k) = cs*e(k) - sn*s(k) + g = sn*s(k+1) + s(k+1) = cs*s(k+1) + if (wantv) call drot(p,v(1,k),1,v(1,k+1),1,cs,sn) + call drotg(f,g,cs,sn) + s(k) = f + f = cs*e(k) + sn*s(k+1) + s(k+1) = -sn*e(k) + cs*s(k+1) + g = sn*e(k+1) + e(k+1) = cs*e(k+1) + if (wantu .and. k .lt. n) + * call drot(n,u(1,k),1,u(1,k+1),1,cs,sn) + 560 continue + e(m-1) = f + iter = iter + 1 + go to 610 +c +c convergence. +c + 570 continue +c +c make the singular value positive. +c + if (s(l) .ge. 0.0d0) go to 580 + s(l) = -s(l) + if (wantv) call dscal(p,-1.0d0,v(1,l),1) + 580 continue +c +c order the singular value. +c + 590 if (l .eq. mm) go to 600 +c ...exit + if (s(l) .ge. s(l+1)) go to 600 + t = s(l) + s(l) = s(l+1) + s(l+1) = t + if (wantv .and. l .lt. p) + * call dswap(p,v(1,l),1,v(1,l+1),1) + if (wantu .and. l .lt. n) + * call dswap(n,u(1,l),1,u(1,l+1),1) + l = l + 1 + go to 590 + 600 continue + iter = 0 + m = m - 1 + 610 continue + go to 360 + 620 continue + return + end + Added: trunk/Lib/sandbox/pyloess/sandbox/src/loess.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/loess.c 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/loess.c 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,325 @@ +#include "S.h" +#include "loess.h" +#include +#include + +static char *surf_stat; + +void +loess_setup(double *x, double *y, int n, int p, loess *lo) +{ + int i, max_kd; + + max_kd = n > 200 ? n : 200; + + lo->inputs.y = (double *) malloc(n * sizeof(double)); + lo->inputs.x = (double *) malloc(n * p * sizeof(double)); + lo->inputs.weights = (double *) malloc(n * sizeof(double)); + for(i = 0; i < (n * p); i++) + lo->inputs.x[i] = x[i]; + for(i = 0; i < n; i++) { + lo->inputs.y[i] = y[i]; + lo->inputs.weights[i] = 1; + } + lo->inputs.n = n; + lo->inputs.p = p; + lo->model.span = 0.75; + lo->model.degree = 2; + lo->model.normalize = TRUE; + for(i = 0; i < 8; i++) + lo->model.parametric[i] = lo->model.drop_square[i] = FALSE; + lo->model.family = "gaussian"; + + lo->control.surface = "interpolate"; + lo->control.statistics = "approximate"; + lo->control.cell = 0.2; + lo->control.trace_hat = "wait.to.decide"; + lo->control.iterations = 4; + + lo->outputs.fitted_values = (double *) malloc(n * sizeof(double)); + lo->outputs.fitted_residuals = (double *) malloc(n * sizeof(double)); + lo->outputs.pseudovalues = (double *) malloc(n * sizeof(double)); + lo->outputs.diagonal = (double *) malloc(n * sizeof(double)); + lo->outputs.robust = (double *) malloc(n * sizeof(double)); + lo->outputs.divisor = (double *) malloc(p * sizeof(double)); + + lo->kd_tree.parameter = (int *) malloc(7 * sizeof(int)); + lo->kd_tree.a = (int *) malloc(max_kd * sizeof(int)); + lo->kd_tree.xi = (double *) malloc(max_kd * sizeof(double)); + lo->kd_tree.vert = (double *) malloc(p * 2 * sizeof(double)); + lo->kd_tree.vval = (double *) malloc((p + 1) * max_kd * sizeof(double)); +} + +void +loess_fit(loess *lo) +{ + int size_info[2], iterations; + void loess_(); + + size_info[0] = lo->inputs.p; + size_info[1] = lo->inputs.n; + + iterations = (!strcmp(lo->model.family, "gaussian")) ? 0 : + lo->control.iterations; + if(!strcmp(lo->control.trace_hat, "wait.to.decide")) { + if(!strcmp(lo->control.surface, "interpolate")) + lo->control.trace_hat = (lo->inputs.n < 500) ? "exact" : +"approximate"; + else + lo->control.trace_hat = "exact"; + } + loess_(lo->inputs.y, lo->inputs.x, size_info, lo->inputs.weights, + &lo->model.span, + &lo->model.degree, + lo->model.parametric, + lo->model.drop_square, + &lo->model.normalize, + &lo->control.statistics, + &lo->control.surface, + &lo->control.cell, + &lo->control.trace_hat, + &iterations, + lo->outputs.fitted_values, + lo->outputs.fitted_residuals, + &lo->outputs.enp, + &lo->outputs.s, + &lo->outputs.one_delta, + &lo->outputs.two_delta, + lo->outputs.pseudovalues, + &lo->outputs.trace_hat, + lo->outputs.diagonal, + lo->outputs.robust, + lo->outputs.divisor, + lo->kd_tree.parameter, + lo->kd_tree.a, + lo->kd_tree.xi, + lo->kd_tree.vert, + lo->kd_tree.vval); +} + +void +loess_(double *y, double *x_, int *size_info, double *weights, double *span, + int *degree, int *parametric, int *drop_square, int *normalize, + char **statistics, char **surface, double *cell, char **trace_hat_in, + int *iterations, double *fitted_values, double *fitted_residuals, + double *enp, double *s, double *one_delta, double *two_delta, + double *pseudovalues, double *trace_hat_out, double *diagonal, + double *robust, double *divisor, int *parameter, int *a, double *xi, + double *vert, double *vval) +{ + double *x, *x_tmp, new_cell, trL, delta1, delta2, sum_squares = 0, + *pseudo_resid, *temp, *xi_tmp, *vert_tmp, *vval_tmp, + *diag_tmp, trL_tmp = 0, d1_tmp = 0, d2_tmp = 0, sum, mean; + int i, j, k, p, N, D, sum_drop_sqr = 0, sum_parametric = 0, + setLf, nonparametric = 0, *order_parametric, + *order_drop_sqr, zero = 0, max_kd, *a_tmp, *param_tmp; + int cut, comp(); + char *new_stat; + void condition(); + + D = size_info[0]; + N = size_info[1]; + max_kd = (N > 200 ? N : 200); + *one_delta = *two_delta = *trace_hat_out = 0; + + x = (double *) malloc(D * N * sizeof(double)); + x_tmp = (double *) malloc(D * N * sizeof(double)); + temp = (double *) malloc(N * sizeof(double)); + a_tmp = (int *) malloc(max_kd * sizeof(int)); + xi_tmp = (double *) malloc(max_kd * sizeof(double)); + vert_tmp = (double *) malloc(D * 2 * sizeof(double)); + vval_tmp = (double *) malloc((D + 1) * max_kd * sizeof(double)); + diag_tmp = (double *) malloc(N * sizeof(double)); + param_tmp = (int *) malloc(N * sizeof(int)); + order_parametric = (int *) malloc(D * sizeof(int)); + order_drop_sqr = (int *) malloc(D * sizeof(int)); + if((*iterations) > 0) + pseudo_resid = (double *) malloc(N * sizeof(double)); + + new_cell = (*span) * (*cell); + for(i = 0; i < N; i++) + robust[i] = 1; + for(i = 0; i < (N * D); i++) + x_tmp[i] = x_[i]; + if((*normalize) && (D > 1)) { + cut = ceil(0.100000000000000000001 * N); + for(i = 0; i < D; i++) { + k = i * N; + for(j = 0; j < N; j++) + temp[j] = x_[k + j]; + qsort(temp, N, sizeof(double), comp); + sum = 0; + for(j = cut; j <= (N - cut - 1); j++) + sum = sum + temp[j]; + mean = sum / (N - 2 * cut); + sum = 0; + for(j = cut; j <= (N - cut - 1); j++) { + temp[j] = temp[j] - mean; + sum = sum + temp[j] * temp[j]; + } + divisor[i] = sqrt(sum / (N - 2 * cut - 1)); + for(j = 0; j < N; j++) { + p = k + j; + x_tmp[p] = x_[p] / divisor[i]; + } + } + } + else + for(i = 0; i < D; i++) divisor[i] = 1; + j = D - 1; + for(i = 0; i < D; i++) { + sum_drop_sqr = sum_drop_sqr + drop_square[i]; + sum_parametric = sum_parametric + parametric[i]; + if(parametric[i]) + order_parametric[j--] = i; + else + order_parametric[nonparametric++] = i; + } + for(i = 0; i < D; i++) { + order_drop_sqr[i] = 2 - drop_square[order_parametric[i]]; + k = i * N; + p = order_parametric[i] * N; + for(j = 0; j < N; j++) + x[k + j] = x_tmp[p + j]; + } + if((*degree) == 1 && sum_drop_sqr) { + fprintf(stderr, "Specified the square of a factor predictor to be"\ + "dropped when degree = 1"); + exit(1); + } + if(D == 1 && sum_drop_sqr) { + fprintf(stderr, "Specified the square of a predictor to be dropped"\ + "with only one numeric predictor"); + exit(1); + } + if(sum_parametric == D) { + fprintf(stderr, "Specified parametric for all predictors"); + exit(1); + } + for(j = 0; j <= (*iterations); j++) { + new_stat = j ? "none" : *statistics; + for(i = 0; i < N; i++) + robust[i] = weights[i] * robust[i]; + condition(surface, new_stat, trace_hat_in); + setLf = !strcmp(surf_stat, "interpolate/exact"); + loess_raw(y, x, weights, robust, &D, &N, span, degree, + &nonparametric, order_drop_sqr, &sum_drop_sqr, + &new_cell, &surf_stat, fitted_values, parameter, a, + xi, vert, vval, diagonal, &trL, &delta1, &delta2, + &setLf); + if(j == 0) { + *trace_hat_out = trL; + *one_delta = delta1; + *two_delta = delta2; + } + for(i = 0; i < N; i++) + printf("i:%i y:%.3f f:%.3f\n", i, y[i], fitted_values[i]); + fitted_residuals[i] = y[i] - fitted_values[i]; + if(j < (*iterations)) + F77_SUB(lowesw)(fitted_residuals, &N, robust, temp); + } + if((*iterations) > 0) { + F77_SUB(lowesp)(&N, y, fitted_values, weights, robust, temp, +pseudovalues); + + loess_raw(pseudovalues, x, weights, weights, &D, &N, span, + degree, &nonparametric, order_drop_sqr, &sum_drop_sqr, + &new_cell, &surf_stat, temp, param_tmp, a_tmp, xi_tmp, + vert_tmp, vval_tmp, diag_tmp, &trL_tmp, &d1_tmp, &d2_tmp, + &zero); + for(i = 0; i < N; i++) + pseudo_resid[i] = pseudovalues[i] - temp[i]; + } + if((*iterations) == 0) + for(i = 0; i < N; i++) + sum_squares = sum_squares + weights[i] * + fitted_residuals[i] * fitted_residuals[i]; + else + for(i = 0; i < N; i++) + sum_squares = sum_squares + weights[i] * + pseudo_resid[i] * pseudo_resid[i]; + *enp = (*one_delta) + 2 * (*trace_hat_out) - N; + *s = sqrt(sum_squares / (*one_delta)); + + free(x); + free(x_tmp); + free(temp); + free(xi_tmp); + free(vert_tmp); + free(vval_tmp); + free(diag_tmp); + free(a_tmp); + free(param_tmp); + free(order_parametric); + free(order_drop_sqr); + if((*iterations) > 0) + free(pseudo_resid); +} + +void +loess_free_mem(loess *lo) +{ + free(lo->inputs.x); + free(lo->inputs.y); + free(lo->inputs.weights); + free(lo->outputs.fitted_values); + free(lo->outputs.fitted_residuals); + free(lo->outputs.pseudovalues); + free(lo->outputs.diagonal); + free(lo->outputs.robust); + free(lo->outputs.divisor); + free(lo->kd_tree.parameter); + free(lo->kd_tree.a); + free(lo->kd_tree.xi); + free(lo->kd_tree.vert); + free(lo->kd_tree.vval); +} + +void +loess_summary(loess *lo) +{ + printf("Number of Observations : %d\n", lo->inputs.n); + printf("Equivalent Number of Parameters: %.1f\n", lo->outputs.enp); + if(!strcmp(lo->model.family, "gaussian")) + printf("Residual Standard Error : "); + else + printf("Residual Scale Estimate: "); + printf("%.4f\n", lo->outputs.s); +} + +void +condition(char **surface, char *new_stat, char **trace_hat_in) +{ + if(!strcmp(*surface, "interpolate")) { + if(!strcmp(new_stat, "none")) + surf_stat = "interpolate/none"; + else if(!strcmp(new_stat, "exact")) + surf_stat = "interpolate/exact"; + else if(!strcmp(new_stat, "approximate")) + { + if(!strcmp(*trace_hat_in, "approximate")) + surf_stat = "interpolate/2.approx"; + else if(!strcmp(*trace_hat_in, "exact")) + surf_stat = "interpolate/1.approx"; + } + } + else if(!strcmp(*surface, "direct")) { + if(!strcmp(new_stat, "none")) + surf_stat = "direct/none"; + else if(!strcmp(new_stat, "exact")) + surf_stat = "direct/exact"; + else if(!strcmp(new_stat, "approximate")) + surf_stat = "direct/approximate"; + } +} + +int +comp(double *d1, double *d2) +{ + if(*d1 < *d2) + return(-1); + else if(*d1 == *d2) + return(0); + else + return(1); +} Added: trunk/Lib/sandbox/pyloess/sandbox/src/loess.h =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/loess.h 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/loess.h 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,81 @@ +/* for the meaning of these fields, see struct.m */ +/* longs are used here so that the codes can be called from S */ + +#define TRUE 1 +#define FALSE 0 + +typedef struct { + long n; + long p; + double *y; + double *x; + double *weights; + } loess_inputs; + +typedef struct { + double span; + int degree; + int normalize; + int parametric[8]; + int drop_square[8]; + char *family; + } loess_model; + +typedef struct { + char *surface; + char *statistics; + double cell; + char *trace_hat; + int iterations; + } loess_control; + +typedef struct { + int *parameter; + int *a; + double *xi; + double *vert; + double *vval; + } loess_kd_tree; + +typedef struct { + double *fitted_values; + double *fitted_residuals; + double enp; + double s; + double one_delta; + double two_delta; + double *pseudovalues; + double trace_hat; + double *diagonal; + double *robust; + double *divisor; + } loess_outputs; + +typedef struct { + loess_inputs inputs; + loess_model model; + loess_control control; + loess_kd_tree kd_tree; + loess_outputs outputs; +} loess; + +typedef struct { + double *fit; + double *se_fit; + double residual_scale; + double df; +} predicted; + +struct anova_struct { + double dfn; + double dfd; + double F_value; + double Pr_F; +}; + +struct ci_struct { + double *fit; + double *upper; + double *lower; +}; + Added: trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,330 @@ +#include "S.h" +#include +#include + +#define min(x,y) ((x) < (y) ? (x) : (y)) +#define max(x,y) ((x) > (y) ? (x) : (y)) +#define GAUSSIAN 1 +#define SYMMETRIC 0 + +static int *iv, liv, lv, tau; +static double *v; + +loess_raw(double *y, double *x, double *weights, double *robust, int *d, + int*n, double *span, int *degree, int *nonparametric, + int *drop_square, int *sum_drop_sqr, double *cell, char **surf_stat, + double *surface, int *parameter, int *a, double *xi, double *vert, + double *vval, double *diagonal, double *trL, double *one_delta, + double *two_delta, int *setLf) +{ + int zero = 0, one = 1, two = 2, nsing, i, k; + double *hat_matrix, *LL; + + *trL = 0; + loess_workspace(d, n, span, degree, nonparametric, drop_square, + sum_drop_sqr, setLf); + v[1] = *cell; + if(!strcmp(*surf_stat, "interpolate/none")) { + F77_SUB(lowesb)(x, y, robust, &zero, &zero, iv, &liv, &lv, v); + F77_SUB(lowese)(iv, &liv, &lv, v, n, x, surface); + loess_prune(parameter, a, xi, vert, vval); + } + else if (!strcmp(*surf_stat, "direct/none")) { + F77_SUB(lowesf)(x, y, robust, iv, &liv, &lv, v, n, x, + &zero, &zero, surface); + } + else if (!strcmp(*surf_stat, "interpolate/1.approx")) { + F77_SUB(lowesb)(x, y, weights, diagonal, &one, iv, &liv, &lv, v); + F77_SUB(lowese)(iv, &liv, &lv, v, n, x, surface); + nsing = iv[29]; + for(i = 0; i < (*n); i++) *trL = *trL + diagonal[i]; + F77_SUB(lowesa)(trL, n, d, &tau, &nsing, one_delta, two_delta); + loess_prune(parameter, a, xi, vert, vval); + } + else if (!strcmp(*surf_stat, "interpolate/2.approx")) { + F77_SUB(lowesb)(x, y, robust, &zero, &zero, iv, &liv, &lv, v); + F77_SUB(lowese)(iv, &liv, &lv, v, n, x, surface); + nsing = iv[29]; + F77_SUB(ehg196)(&tau, d, span, trL); + F77_SUB(lowesa)(trL, n, d, &tau, &nsing, one_delta, two_delta); + loess_prune(parameter, a, xi, vert, vval); + } + else if (!strcmp(*surf_stat, "direct/approximate")) { + F77_SUB(lowesf)(x, y, weights, iv, &liv, &lv, v, n, x, + diagonal, &one, surface); + nsing = iv[29]; + for(i = 0; i < (*n); i++) *trL = *trL + diagonal[i]; + F77_SUB(lowesa)(trL, n, d, &tau, &nsing, one_delta, two_delta); + } + else if (!strcmp(*surf_stat, "interpolate/exact")) { + hat_matrix = Calloc((*n)*(*n), double); + LL = Calloc((*n)*(*n), double); + F77_SUB(lowesb)(x, y, weights, diagonal, &one, iv, &liv, &lv, v); + F77_SUB(lowesl)(iv, &liv, &lv, v, n, x, hat_matrix); + F77_SUB(lowesc)(n, hat_matrix, LL, trL, one_delta, two_delta); + F77_SUB(lowese)(iv, &liv, &lv, v, n, x, surface); + loess_prune(parameter, a, xi, vert, vval); + Free(hat_matrix); + Free(LL); + } + else if (!strcmp(*surf_stat, "direct/exact")) { + hat_matrix = Calloc((*n)*(*n), double); + LL = Calloc((*n)*(*n), double); + F77_SUB(lowesf)(x, y, weights, iv, liv, lv, v, n, x, + hat_matrix, &two, surface); + F77_SUB(lowesc)(n, hat_matrix, LL, trL, one_delta, two_delta); + k = (*n) + 1; + for(i = 0; i < (*n); i++) + diagonal[i] = hat_matrix[i * k]; + Free(hat_matrix); + Free(LL); + } + loess_free(); +} + +loess_dfit(double *y, double *x, double *x_evaluate, double *weights, + double *span, int *degree, int *nonparametric, + int *drop_square, int *sum_drop_sqr, int *d, int *n, int *m, + double *fit) +{ + int zero = 0, one = 1; + loess_workspace(d, n, span, degree, nonparametric, drop_square, + sum_drop_sqr, &zero); + F77_SUB(lowesf)(x, y, weights, iv, &liv, &lv, v, m, x_evaluate, + &zero, &zero, fit); + loess_free(); +} + +loess_dfitse(double *y, double *x, double *x_evaluate, double *weights, + double *robust, int *family, double *span, int *degree, + int *nonparametric, int *drop_square, int *sum_drop_sqr, + int *d, int *n, int *m, double *fit, double *L) +{ + int zero = 0, one = 1, two = 2; + loess_workspace(d, n, span, degree, nonparametric, drop_square, + sum_drop_sqr, &zero); + if(*family == GAUSSIAN) + F77_SUB(lowesf)(x, y, weights, iv, &liv, &lv, v, m, + x_evaluate, L, &two, fit); + else if(*family == SYMMETRIC) + { + F77_SUB(lowesf)(x, y, weights, iv, &liv, &lv, v, m, + x_evaluate, L, &two, fit); + F77_SUB(lowesf)(x, y, robust, iv, &liv, &lv, v, m, + x_evaluate, &zero, &zero, fit); + } + loess_free(); +} + +loess_ifit(int *parameter, int *a, double *xi, double *vert, double *vval, + int *m, double *x_evaluate, double *fit) +{ + loess_grow(parameter, a, xi, vert, vval); + F77_SUB(lowese)(iv, &liv, &lv, v, m, x_evaluate, fit); + loess_free(); +} + +loess_ise(double *y, double *x, double *x_evaluate, double *weights, + double *span, int *degree, int *nonparametric, int *drop_square, + int *sum_drop_sqr, double *cell, int *d, int *n, int *m, + double *fit, double *L) +{ + int zero = 0, one = 1; + loess_workspace(d, n, span, degree, nonparametric, drop_square, + sum_drop_sqr, &one); + v[1] = *cell; + F77_SUB(lowesb)(x, y, weights, &zero, &zero, iv, &liv, &lv, v); + F77_SUB(lowesl)(iv, &liv, &lv, v, m, x_evaluate, L); + loess_free(); +} + +loess_workspace(int *d, int *n, double *span, int *degree, + int *nonparametric, int *drop_square, int *sum_drop_sqr, + int *setLf) +{ + int D, N, tau0, nvmax, nf, version = 106, i; + D = *d; + N = *n; + nvmax = max(200, N); + nf = min(N, floor(N * (*span))); + tau0 = ((*degree) > 1) ? ((D + 2) * (D + 1) * 0.5) : (D + 1); + tau = tau0 - (*sum_drop_sqr); + lv = 50 + (3 * D + 3) * nvmax + N + (tau0 + 2) * nf; + liv = 50 + ((int)pow((double)2, (double)D) + 4) * nvmax + 2 * N; + if(*setLf) { + lv = lv + (D + 1) * nf * nvmax; + liv = liv + nf * nvmax; + } + iv = Calloc(liv, int); + v = Calloc(lv, double); + + F77_SUB(lowesd)(&version, iv, &liv, &lv, v, d, n, span, degree, + &nvmax, setLf); + iv[32] = *nonparametric; + for(i = 0; i < D; i++) + iv[i + 40] = drop_square[i]; +} + +loess_prune(int *parameter, int *a, double *xi, double *vert, double *vval) +{ + int d, vc, a1, v1, xi1, vv1, nc, nv, nvmax, i, j, k; + + d = iv[1]; + vc = iv[3] - 1; + nc = iv[4]; + nv = iv[5]; + a1 = iv[6] - 1; + v1 = iv[10] - 1; + xi1 = iv[11] - 1; + vv1 = iv[12] - 1; + nvmax = iv[13]; + + for(i = 0; i < 5; i++) + parameter[i] = iv[i + 1]; + parameter[5] = iv[21] - 1; + parameter[6] = iv[14] - 1; + + for(i = 0; i < d; i++){ + k = nvmax * i; + vert[i] = v[v1 + k]; + vert[i + d] = v[v1 + vc + k]; + } + for(i = 0; i < nc; i++) { + xi[i] = v[xi1 + i]; + a[i] = iv[a1 + i]; + } + k = (d + 1) * nv; + for(i = 0; i < k; i++) + vval[i] = v[vv1 + i]; +} + +loess_grow(int *parameter, int *a, double *xi, double *vert, double *vval) +{ + int d, vc, nc, nv, a1, v1, xi1, vv1, i, j, k; + + d = parameter[0]; + vc = parameter[2]; + nc = parameter[3]; + nv = parameter[4]; + liv = parameter[5]; + lv = parameter[6]; + iv = Calloc(liv, int); + v = Calloc(lv, double); + + iv[1] = d; + iv[2] = parameter[1]; + iv[3] = vc; + iv[5] = iv[13] = nv; + iv[4] = iv[16] = nc; + iv[6] = 50; + iv[7] = iv[6] + nc; + iv[8] = iv[7] + vc * nc; + iv[9] = iv[8] + nc; + iv[10] = 50; + iv[12] = iv[10] + nv * d; + iv[11] = iv[12] + (d + 1) * nv; + iv[27] = 173; + + v1 = iv[10] - 1; + xi1 = iv[11] - 1; + a1 = iv[6] - 1; + vv1 = iv[12] - 1; + + for(i = 0; i < d; i++) { + k = nv * i; + v[v1 + k] = vert[i]; + v[v1 + vc - 1 + k] = vert[i + d]; + } + for(i = 0; i < nc; i++) { + v[xi1 + i] = xi[i]; + iv[a1 + i] = a[i]; + } + k = (d + 1) * nv; + for(i = 0; i < k; i++) + v[vv1 + i] = vval[i]; + + F77_SUB(ehg169)(&d, &vc, &nc, &nc, &nv, &nv, v+v1, iv+a1, + v+xi1, iv+iv[7]-1, iv+iv[8]-1, iv+iv[9]-1); +} + +loess_free() +{ + Free(v); + Free(iv); +} + +/* begin ehg's FORTRAN-callable C-codes */ + +void +F77_SUB(ehg182)(int *i) +{ +char *mess, mess2[50]; +switch(*i){ +case 100: mess="wrong version number in lowesd. Probably typo in caller."; break; +case 101: mess="d>dMAX in ehg131. Need to recompile with increased dimensions."; break; +case 102: mess="liv too small. (Discovered by lowesd)"; break; +case 103: mess="lv too small. (Discovered by lowesd)"; break; +case 104: mess="span too small. fewer data values than degrees of freedom."; break; +case 105: mess="k>d2MAX in ehg136. Need to recompile with increased dimensions."; break; +case 106: mess="lwork too small"; break; +case 107: mess="invalid value for kernel"; break; +case 108: mess="invalid value for ideg"; break; +case 109: mess="lowstt only applies when kernel=1."; break; +case 110: mess="not enough extra workspace for robustness calculation"; break; +case 120: mess="zero-width neighborhood. make span bigger"; break; +case 121: mess="all data on boundary of neighborhood. make span bigger"; break; +case 122: mess="extrapolation not allowed with blending"; break; +case 123: mess="ihat=1 (diag L) in l2fit only makes sense if z=x (eval=data)."; break; +case 171: mess="lowesd must be called first."; break; +case 172: mess="lowesf must not come between lowesb and lowese, lowesr, or lowesl."; break; +case 173: mess="lowesb must come before lowese, lowesr, or lowesl."; break; +case 174: mess="lowesb need not be called twice."; break; +case 175: mess="need setLf=.true. for lowesl."; break; +case 180: mess="nv>nvmax in cpvert."; break; +case 181: mess="nt>20 in eval."; break; +case 182: mess="svddc failed in l2fit."; break; +case 183: mess="didnt find edge in vleaf."; break; +case 184: mess="zero-width cell found in vleaf."; break; +case 185: mess="trouble descending to leaf in vleaf."; break; +case 186: mess="insufficient workspace for lowesf."; break; +case 187: mess="insufficient stack space"; break; +case 188: mess="lv too small for computing explicit L"; break; +case 191: mess="computed trace L was negative; something is wrong!"; break; +case 192: mess="computed delta was negative; something is wrong!"; break; +case 193: mess="workspace in loread appears to be corrupted"; break; +case 194: mess="trouble in l2fit/l2tr"; break; +case 195: mess="only constant, linear, or quadratic local models allowed"; break; +case 196: mess="degree must be at least 1 for vertex influence matrix"; break; +case 999: mess="not yet implemented"; break; +default: sprintf(mess=mess2,"Assert failed; error code %d\n",*i); break; + } + Recover(mess,NULL_ENTRY); /* in /usr/s/current/src/qpe/debug.c */ +} + +void +F77_SUB(ehg183)(char *s,int *i, int *n, int *inc) +{ + char mess[4000], num[20]; + int j; + strcpy(mess,s); + for (j=0; j<*n; j++) { + sprintf(num," %d",i[j * *inc]); + strcat(mess,num); + } + strcat(mess,"\n"); + Warning(mess,NULL_ENTRY); +} + +void +F77_SUB(ehg184)(char *s, double *x, int *n, int *inc) +{ + char mess[4000], num[30]; + int j; + strcpy(mess,s); + for (j=0; j<*n; j++) { + sprintf(num," %.5g",x[j * *inc]); + strcat(mess,num); + } + strcat(mess,"\n"); + Warning(mess,NULL_ENTRY); +} Added: trunk/Lib/sandbox/pyloess/sandbox/src/loessf.f =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/loessf.f 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/loessf.f 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,2196 @@ + subroutine ehg126(d,n,vc,x,v,nvmax) + integer d,execnt,i,j,k,n,nv,nvmax,vc + DOUBLE PRECISION machin,alpha,beta,mu,t + DOUBLE PRECISION v(nvmax,d),x(n,d) + DOUBLE PRECISION D1MACH + external D1MACH + save machin,execnt + data execnt /0/ +c MachInf -> machin + execnt=execnt+1 + if(execnt.eq.1)then + machin=D1MACH(2) + end if +c fill in vertices for bounding box of $x$ +c lower left, upper right + do 3 k=1,d + alpha=machin + beta=-machin + do 4 i=1,n + t=x(i,k) + alpha=min(alpha,t) + beta=max(beta,t) + 4 continue +c expand the box a little + mu=0.005D0*max(beta-alpha,1.d-10*max(DABS(alpha),DABS(beta))+1. + +d-30) + alpha=alpha-mu + beta=beta+mu + v(1,k)=alpha + v(vc,k)=beta + 3 continue +c remaining vertices + do 5 i=2,vc-1 + j=i-1 + do 6 k=1,d + v(i,k)=v(1+mod(j,2)*(vc-1),k) + j=DFLOAT(j)/2.D0 + 6 continue + 5 continue + return + end + subroutine ehg125(p,nv,v,vhit,nvmax,d,k,t,r,s,f,l,u) + logical i1,i2,match + integer d,execnt,h,i,i3,j,k,m,mm,nv,nvmax,p,r,s + integer f(r,0:1,s),l(r,0:1,s),u(r,0:1,s),vhit(nvmax) + DOUBLE PRECISION t + DOUBLE PRECISION v(nvmax,d) + external ehg182 + save execnt + data execnt /0/ + execnt=execnt+1 + h=nv + do 3 i=1,r + do 4 j=1,s + h=h+1 + do 5 i3=1,d + v(h,i3)=v(f(i,0,j),i3) + 5 continue + v(h,k)=t +c check for redundant vertex + match=.false. + m=1 +c top of while loop + 6 if(.not.match)then + i1=(m.le.nv) + else + i1=.false. + end if + if(.not.(i1))goto 7 + match=(v(m,1).eq.v(h,1)) + mm=2 +c top of while loop + 8 if(match)then + i2=(mm.le.d) + else + i2=.false. + end if + if(.not.(i2))goto 9 + match=(v(m,mm).eq.v(h,mm)) + mm=mm+1 + goto 8 +c bottom of while loop + 9 m=m+1 + goto 6 +c bottom of while loop + 7 m=m-1 + if(match)then + h=h-1 + else + m=h + if(vhit(1).ge.0)then + vhit(m)=p + end if + end if + l(i,0,j)=f(i,0,j) + l(i,1,j)=m + u(i,0,j)=m + u(i,1,j)=f(i,1,j) + 4 continue + 3 continue + nv=h + if(.not.(nv.le.nvmax))then + call ehg182(180) + end if + return + end + integer function ehg138(i,z,a,xi,lo,hi,ncmax) + logical i1 + integer d,execnt,i,j,nc,ncmax + integer a(ncmax),hi(ncmax),lo(ncmax) + DOUBLE PRECISION xi(ncmax),z(8) + save execnt + data execnt /0/ + execnt=execnt+1 +c descend tree until leaf or ambiguous + j=i +c top of while loop + 3 if(a(j).ne.0)then + i1=(z(a(j)).ne.xi(j)) + else + i1=.false. + end if + if(.not.(i1))goto 4 + if(z(a(j)).le.xi(j))then + j=lo(j) + else + j=hi(j) + end if + goto 3 +c bottom of while loop + 4 ehg138=j + return + end + subroutine ehg106(il,ir,k,nk,p,pi,n) + integer execnt,i,ii,il,ir,j,k,l,n,nk,r + integer pi(n) + DOUBLE PRECISION t + DOUBLE PRECISION p(nk,n) + save execnt + data execnt /0/ + execnt=execnt+1 +c find the $k$-th smallest of $n$ elements +c Floyd+Rivest, CACM Mar '75, Algorithm 489 + l=il + r=ir +c top of while loop + 3 if(.not.(l.lt.r))goto 4 +c to avoid recursion, sophisticated partition deleted +c partition $x sub {l..r}$ about $t$ + t=p(1,pi(k)) + i=l + j=r + ii=pi(l) + pi(l)=pi(k) + pi(k)=ii + if(t.lt.p(1,pi(r)))then + ii=pi(l) + pi(l)=pi(r) + pi(r)=ii + end if +c top of while loop + 5 if(.not.(i.lt.j))goto 6 + ii=pi(i) + pi(i)=pi(j) + pi(j)=ii + i=i+1 + j=j-1 +c top of while loop + 7 if(.not.(p(1,pi(i)).lt.t))goto 8 + i=i+1 + goto 7 +c bottom of while loop + 8 continue +c top of while loop + 9 if(.not.(t.lt.p(1,pi(j))))goto 10 + j=j-1 + goto 9 +c bottom of while loop + 10 goto 5 +c bottom of while loop + 6 if(p(1,pi(l)).eq.t)then + ii=pi(l) + pi(l)=pi(j) + pi(j)=ii + else + j=j+1 + ii=pi(r) + pi(r)=pi(j) + pi(j)=ii + end if + if(j.le.k)then + l=j+1 + end if + if(k.le.j)then + r=j-1 + end if + goto 3 +c bottom of while loop + 4 return + end + subroutine ehg127(q,n,d,nf,f,x,psi,y,rw,kernel,k,dist,eta,b,od,w,r + +cond,sing,sigma,u,e,dgamma,qraux,work,tol,dd,tdeg,cdeg,s) + integer column,d,dd,execnt,i,i3,i9,info,inorm2,j,jj,jpvt,k,kernel, + +n,nf,od,sing,tdeg + integer cdeg(8),psi(n) + double precision machep,f,i1,i10,i2,i4,i5,i6,i7,i8,rcond,rho,scal, + +tol + double precision g(15),sigma(15),u(15,15),e(15,15),b(nf,k),colnor( + +15),dist(n),eta(nf),dgamma(15),q(d),qraux(15),rw(n),s(0:od),w(nf), + +work(15),x(n,d),y(n) + external ehg106,ehg182,ehg184,dqrdc,dqrsl,dsvdc + integer idamax + external idamax + double precision d1mach + external d1mach + double precision ddot + external ddot + save machep,execnt + data execnt /0/ +c colnorm -> colnor +c E -> g +c MachEps -> machep +c V -> e +c X -> b + execnt=execnt+1 + if(execnt.eq.1)then + machep=d1mach(4) + end if +c sort by distance + do 3 i3=1,n + dist(i3)=0 + 3 continue + do 4 j=1,dd + i4=q(j) + do 5 i3=1,n + dist(i3)=dist(i3)+(x(i3,j)-i4)**2 + 5 continue + 4 continue + call ehg106(1,n,nf,1,dist,psi,n) + rho=dist(psi(nf))*max(1.d0,f) + if(.not.(0.lt.rho))then + call ehg182(120) + end if +c compute neighborhood weights + if(kernel.eq.2)then + do 6 i=1,nf + if(dist(psi(i)).lt.rho)then + i1=dsqrt(rw(psi(i))) + else + i1=0 + end if + w(i)=i1 + 6 continue + else + do 7 i3=1,nf + w(i3)=dsqrt(dist(psi(i3))/rho) + 7 continue + do 8 i3=1,nf + w(i3)=dsqrt(rw(psi(i3))*(1-w(i3)**3)**3) + 8 continue + end if + if(dabs(w(idamax(nf,w,1))).eq.0)then + call ehg184('at ',q,dd,1) + call ehg184('radius ',rho,1,1) + if(.not..false.)then + call ehg182(121) + end if + end if +c fill design matrix + column=1 + do 9 i3=1,nf + b(i3,column)=w(i3) + 9 continue + if(tdeg.ge.1)then + do 10 j=1,d + if(cdeg(j).ge.1)then + column=column+1 + i5=q(j) + do 11 i3=1,nf + b(i3,column)=w(i3)*(x(psi(i3),j)-i5) + 11 continue + end if + 10 continue + end if + if(tdeg.ge.2)then + do 12 j=1,d + if(cdeg(j).ge.1)then + if(cdeg(j).ge.2)then + column=column+1 + i6=q(j) + do 13 i3=1,nf + b(i3,column)=w(i3)*(x(psi(i3),j)-i6)**2 + 13 continue + end if + do 14 jj=j+1,d + if(cdeg(jj).ge.1)then + column=column+1 + i7=q(j) + i8=q(jj) + do 15 i3=1,nf + b(i3,column)=w(i3)*(x(psi(i3),j)-i7)*(x(psi(i3), + +jj)-i8) + 15 continue + end if + 14 continue + end if + 12 continue + k=column + end if + do 16 i3=1,nf + eta(i3)=w(i3)*y(psi(i3)) + 16 continue +c equilibrate columns + do 17 j=1,k + scal=0 + do 18 inorm2=1,nf + scal=scal+b(inorm2,j)**2 + 18 continue + scal=dsqrt(scal) + if(0.lt.scal)then + do 19 i3=1,nf + b(i3,j)=b(i3,j)/scal + 19 continue + colnor(j)=scal + else + colnor(j)=1 + end if + 17 continue +c singular value decomposition + call dqrdc(b,nf,nf,k,qraux,jpvt,work,0) + call dqrsl(b,nf,nf,k,qraux,eta,work,eta,eta,work,work,1000,info) + do 20 i9=1,k + do 21 i3=1,k + u(i3,i9)=0 + 21 continue + 20 continue + do 22 i=1,k + do 23 j=i,k + u(i,j)=b(i,j) + 23 continue + 22 continue + call dsvdc(u,15,k,k,sigma,g,u,15,e,15,work,21,info) + if(.not.(info.eq.0))then + call ehg182(182) + end if + tol=sigma(1)*(100*machep) + rcond=min(rcond,sigma(k)/sigma(1)) + if(sigma(k).le.tol)then + sing=sing+1 + if(sing.eq.1)then + call ehg184('Warning. pseudoinverse used at',q,d,1) + call ehg184('neighborhood radius',dsqrt(rho),1,1) + call ehg184('reciprocal condition number ',rcond,1,1) + else + if(sing.eq.2)then + call ehg184('There are other near singularities as well.' + +,rho,1,1) + end if + end if + end if +c compensate for equilibration + do 24 j=1,k + i10=colnor(j) + do 25 i3=1,k + e(j,i3)=e(j,i3)/i10 + 25 continue + 24 continue +c solve least squares problem + do 26 j=1,k + if(tol.lt.sigma(j))then + i2=ddot(k,u(1,j),1,eta,1)/sigma(j) + else + i2=0.d0 + end if + dgamma(j)=i2 + 26 continue + do 27 j=0,od +c bug fix 2006-07-04 for k=1, od>1. (thanks btyner at gmail.com) + if(j.lt.k)then + s(j)=ddot(k,e(j+1,1),15,dgamma,1) + else + s(j)=0.d0 + end if + 27 continue + return + end + subroutine ehg131(x,y,rw,trl,diagl,kernel,k,n,d,nc,ncmax,vc,nv,nvm + +ax,nf,f,a,c,hi,lo,pi,psi,v,vhit,vval,xi,dist,eta,b,ntol,fd,w,vval2 + +,rcond,sing,dd,tdeg,cdeg,lq,lf,setlf) + logical setlf + integer identi,d,dd,execnt,i1,i2,j,k,kernel,n,nc,ncmax,nf,ntol,nv, + +nvmax,sing,tdeg,vc + integer lq(nvmax,nf),a(ncmax),c(vc,ncmax),cdeg(8),hi(ncmax),lo(ncm + +ax),pi(n),psi(n),vhit(nvmax) + double precision f,fd,rcond,trl + double precision lf(0:d,nvmax,nf),b(*),delta(8),diagl(n),dist(n),e + +ta(nf),rw(n),v(nvmax,d),vval(0:d,nvmax),vval2(0:d,nvmax),w(nf),x(n + +,d),xi(ncmax),y(n) + external ehg126,ehg182,ehg139,ehg124 + double precision dnrm2 + external dnrm2 + save execnt + data execnt /0/ +c Identity -> identi +c X -> b + execnt=execnt+1 + if(.not.(d.le.8))then + call ehg182(101) + end if +c build $k$-d tree + call ehg126(d,n,vc,x,v,nvmax) + nv=vc + nc=1 + do 3 j=1,vc + c(j,nc)=j + vhit(j)=0 + 3 continue + do 4 i1=1,d + delta(i1)=v(vc,i1)-v(1,i1) + 4 continue + fd=fd*dnrm2(d,delta,1) + do 5 identi=1,n + pi(identi)=identi + 5 continue + call ehg124(1,n,d,n,nv,nc,ncmax,vc,x,pi,a,xi,lo,hi,c,v,vhit,nvmax, + +ntol,fd,dd) +c smooth + if(trl.ne.0)then + do 6 i2=1,nv + do 7 i1=0,d + vval2(i1,i2)=0 + 7 continue + 6 continue + end if + call ehg139(v,nvmax,nv,n,d,nf,f,x,pi,psi,y,rw,trl,kernel,k,dist,di + +st,eta,b,d,w,diagl,vval2,nc,vc,a,xi,lo,hi,c,vhit,rcond,sing,dd,tde + +g,cdeg,lq,lf,setlf,vval) + return + end + subroutine ehg133(n,d,vc,nvmax,nc,ncmax,a,c,hi,lo,v,vval,xi,m,z,s) + integer d,execnt,i,i1,m,nc,ncmax,nv,nvmax,vc + integer a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax) + double precision delta(8),s(m),v(nvmax,d),vval(0:d,nvmax),xi(ncmax + +),z(m,d) + double precision ehg128 + external ehg128 + save execnt + data execnt /0/ + execnt=execnt+1 + do 3 i=1,m + do 4 i1=1,d + delta(i1)=z(i,i1) + 4 continue + s(i)=ehg128(delta,d,ncmax,vc,a,xi,lo,hi,c,v,nvmax,vval) + 3 continue + return + end + subroutine ehg140(iw,i,j) + integer execnt,i,j + integer iw(i) + save execnt + data execnt /0/ + execnt=execnt+1 + iw(i)=j + return + end + subroutine ehg141(trl,n,deg,k,d,nsing,dk,delta1,delta2) + integer d,deg,dk,k,n,nsing + external ehg176 + double precision ehg176 + double precision corx,delta1,delta2,trl,z + double precision c(48), c1, c2, c3, c4 +c coef, d, deg, del + data c / .2971620d0,.3802660d0,.5886043d0,.4263766d0,.3346498d0,.6 + +271053d0,.5241198d0,.3484836d0,.6687687d0,.6338795d0,.4076457d0,.7 + +207693d0,.1611761d0,.3091323d0,.4401023d0,.2939609d0,.3580278d0,.5 + +555741d0,.3972390d0,.4171278d0,.6293196d0,.4675173d0,.4699070d0,.6 + +674802d0,.2848308d0,.2254512d0,.2914126d0,.5393624d0,.2517230d0,.3 + +898970d0,.7603231d0,.2969113d0,.4740130d0,.9664956d0,.3629838d0,.5 + +348889d0,.2075670d0,.2822574d0,.2369957d0,.3911566d0,.2981154d0,.3 + +623232d0,.5508869d0,.3501989d0,.4371032d0,.7002667d0,.4291632d0,.4 + +930370d0 / + if(deg.eq.0) dk=1 + if(deg.eq.1) dk=d+1 + if(deg.eq.2) dk=dfloat((d+2)*(d+1))/2.d0 + corx=dsqrt(k/dfloat(n)) + z=(dsqrt(k/trl)-corx)/(1-corx) + if(nsing .eq. 0 .and. 1 .lt. z) call ehg184('Chernobyl! trLn',trl,1,1) + z=min(1.0d0,max(0.0d0,z)) + c4=dexp(ehg176(z)) + i=1+3*(min(d,4)-1+4*(deg-1)) + if(d.le.4)then + c1=c(i) + c2=c(i+1) + c3=c(i+2) + else + c1=c(i)+(d-4)*(c(i)-c(i-3)) + c2=c(i+1)+(d-4)*(c(i+1)-c(i-2)) + c3=c(i+2)+(d-4)*(c(i+2)-c(i-1)) + endif + delta1=n-trl*dexp(c1*z**c2*(1-z)**c3*c4) + i=i+24 + if(d.le.4)then + c1=c(i) + c2=c(i+1) + c3=c(i+2) + else + c1=c(i)+(d-4)*(c(i)-c(i-3)) + c2=c(i+1)+(d-4)*(c(i+1)-c(i-2)) + c3=c(i+2)+(d-4)*(c(i+2)-c(i-1)) + endif + delta2=n-trl*dexp(c1*z**c2*(1-z)**c3*c4) + return + end + subroutine lowesc(n,l,ll,trl,delta1,delta2) + integer execnt,i,j,n + double precision delta1,delta2,trl + double precision l(n,n),ll(n,n) + double precision ddot + external ddot + save execnt + data execnt /0/ + execnt=execnt+1 +c compute $LL~=~(I-L)(I-L)'$ + do 3 i=1,n + l(i,i)=l(i,i)-1 + 3 continue + do 4 i=1,n + do 5 j=1,i + ll(i,j)=ddot(n,l(i,1),n,l(j,1),n) + 5 continue + 4 continue + do 6 i=1,n + do 7 j=i+1,n + ll(i,j)=ll(j,i) + 7 continue + 6 continue + do 8 i=1,n + l(i,i)=l(i,i)+1 + 8 continue +c accumulate first two traces + trl=0 + delta1=0 + do 9 i=1,n + trl=trl+l(i,i) + delta1=delta1+ll(i,i) + 9 continue +c $delta sub 2 = "tr" LL sup 2$ + delta2=0 + do 10 i=1,n + delta2=delta2+ddot(n,ll(i,1),n,ll(1,i),1) + 10 continue + return + end + subroutine ehg169(d,vc,nc,ncmax,nv,nvmax,v,a,xi,c,hi,lo) + integer d,execnt,i,j,k,mc,mv,nc,ncmax,nv,nvmax,p,vc + integer a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax),novhit(1) + DOUBLE PRECISION v(nvmax,d),xi(ncmax) + external ehg125,ehg182 + integer ifloor + external ifloor + save execnt + data execnt /0/ + execnt=execnt+1 +c as in bbox +c remaining vertices + do 3 i=2,vc-1 + j=i-1 + do 4 k=1,d + v(i,k)=v(1+mod(j,2)*(vc-1),k) + j=ifloor(DFLOAT(j)/2.D0) + 4 continue + 3 continue +c as in ehg131 + mc=1 + mv=vc + novhit(1)=-1 + do 5 j=1,vc + c(j,mc)=j + 5 continue +c as in rbuild + p=1 +c top of while loop + 6 if(.not.(p.le.nc))goto 7 + if(a(p).ne.0)then + k=a(p) +c left son + mc=mc+1 + lo(p)=mc +c right son + mc=mc+1 + hi(p)=mc + call ehg125(p,mv,v,novhit,nvmax,d,k,xi(p),2**(k-1),2**(d-k), + +c(1,p),c(1,lo(p)),c(1,hi(p))) + end if + p=p+1 + goto 6 +c bottom of while loop + 7 if(.not.(mc.eq.nc))then + call ehg182(193) + end if + if(.not.(mv.eq.nv))then + call ehg182(193) + end if + return + end + DOUBLE PRECISION function ehg176(z) + DOUBLE PRECISION z(*) + integer d,vc,nv,nc + integer a(17), c(2,17) + integer hi(17), lo(17) + DOUBLE PRECISION v(10,1) + DOUBLE PRECISION vval(0:1,10) + DOUBLE PRECISION xi(17) + DOUBLE PRECISION ehg128 + data d,vc,nv,nc /1,2,10,17/ + data a(1) /1/ + data hi(1),lo(1),xi(1) /3,2,0.3705D0/ + data c(1,1) /1/ + data c(2,1) /2/ + data a(2) /1/ + data hi(2),lo(2),xi(2) /5,4,0.2017D0/ + data c(1,2) /1/ + data c(2,2) /3/ + data a(3) /1/ + data hi(3),lo(3),xi(3) /7,6,0.5591D0/ + data c(1,3) /3/ + data c(2,3) /2/ + data a(4) /1/ + data hi(4),lo(4),xi(4) /9,8,0.1204D0/ + data c(1,4) /1/ + data c(2,4) /4/ + data a(5) /1/ + data hi(5),lo(5),xi(5) /11,10,0.2815D0/ + data c(1,5) /4/ + data c(2,5) /3/ + data a(6) /1/ + data hi(6),lo(6),xi(6) /13,12,0.4536D0/ + data c(1,6) /3/ + data c(2,6) /5/ + data a(7) /1/ + data hi(7),lo(7),xi(7) /15,14,0.7132D0/ + data c(1,7) /5/ + data c(2,7) /2/ + data a(8) /0/ + data c(1,8) /1/ + data c(2,8) /6/ + data a(9) /0/ + data c(1,9) /6/ + data c(2,9) /4/ + data a(10) /0/ + data c(1,10) /4/ + data c(2,10) /7/ + data a(11) /0/ + data c(1,11) /7/ + data c(2,11) /3/ + data a(12) /0/ + data c(1,12) /3/ + data c(2,12) /8/ + data a(13) /0/ + data c(1,13) /8/ + data c(2,13) /5/ + data a(14) /0/ + data c(1,14) /5/ + data c(2,14) /9/ + data a(15) /1/ + data hi(15),lo(15),xi(15) /17,16,0.8751D0/ + data c(1,15) /9/ + data c(2,15) /2/ + data a(16) /0/ + data c(1,16) /9/ + data c(2,16) /10/ + data a(17) /0/ + data c(1,17) /10/ + data c(2,17) /2/ + data vval(0,1) /-9.0572D-2/ + data v(1,1) /-5.D-3/ + data vval(1,1) /4.4844D0/ + data vval(0,2) /-1.0856D-2/ + data v(2,1) /1.005D0/ + data vval(1,2) /-0.7736D0/ + data vval(0,3) /-5.3718D-2/ + data v(3,1) /0.3705D0/ + data vval(1,3) /-0.3495D0/ + data vval(0,4) /2.6152D-2/ + data v(4,1) /0.2017D0/ + data vval(1,4) /-0.7286D0/ + data vval(0,5) /-5.8387D-2/ + data v(5,1) /0.5591D0/ + data vval(1,5) /0.1611D0/ + data vval(0,6) /9.5807D-2/ + data v(6,1) /0.1204D0/ + data vval(1,6) /-0.7978D0/ + data vval(0,7) /-3.1926D-2/ + data v(7,1) /0.2815D0/ + data vval(1,7) /-0.4457D0/ + data vval(0,8) /-6.4170D-2/ + data v(8,1) /0.4536D0/ + data vval(1,8) /3.2813D-2/ + data vval(0,9) /-2.0636D-2/ + data v(9,1) /0.7132D0/ + data vval(1,9) /0.3350D0/ + data vval(0,10) /4.0172D-2/ + data v(10,1) /0.8751D0/ + data vval(1,10) /-4.1032D-2/ + ehg176=ehg128(z,d,nc,vc,a,xi,lo,hi,c,v,nv,vval) + end + subroutine lowesa(trl,n,d,tau,nsing,delta1,delta2) + integer d,dka,dkb,execnt,n,nsing,tau + double precision alpha,d1a,d1b,d2a,d2b,delta1,delta2,trl + external ehg141 + save execnt + data execnt /0/ + execnt=execnt+1 + call ehg141(trl,n,1,tau,d,nsing,dka,d1a,d2a) + call ehg141(trl,n,2,tau,d,nsing,dkb,d1b,d2b) + alpha=dfloat(tau-dka)/dfloat(dkb-dka) + delta1=(1-alpha)*d1a+alpha*d1b + delta2=(1-alpha)*d2a+alpha*d2b + return + end + subroutine ehg191(m,z,l,d,n,nf,nv,ncmax,vc,a,xi,lo,hi,c,v,nvmax,vv + +al2,lf,lq) + integer lq1,d,execnt,i,i1,i2,j,m,n,nc,ncmax,nf,nv,nvmax,p,vc + integer lq(nvmax,nf),a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax) + double precision l(m,n),lf(0:d,nvmax,nf),v(nvmax,d),vval2(0:d,nvma + +x),xi(ncmax),z(m,d),zi(8) + double precision ehg128 + external ehg128 + save execnt + data execnt /0/ + execnt=execnt+1 + do 3 j=1,n + do 4 i2=1,nv + do 5 i1=0,d + vval2(i1,i2)=0 + 5 continue + 4 continue + do 6 i=1,nv +c linear search for i in Lq + lq1=lq(i,1) + lq(i,1)=j + p=nf +c top of while loop + 7 if(.not.(lq(i,p).ne.j))goto 8 + p=p-1 + goto 7 +c bottom of while loop + 8 lq(i,1)=lq1 + if(lq(i,p).eq.j)then + do 9 i1=0,d + vval2(i1,i)=lf(i1,i,p) + 9 continue + end if + 6 continue + do 10 i=1,m + do 11 i1=1,d + zi(i1)=z(i,i1) + 11 continue + l(i,j)=ehg128(zi,d,ncmax,vc,a,xi,lo,hi,c,v,nvmax,vval2) + 10 continue + 3 continue + return + end + subroutine ehg196(tau,d,f,trl) + integer d,dka,dkb,execnt,tau + double precision alpha,f,trl,trla,trlb + external ehg197 + save execnt + data execnt /0/ + execnt=execnt+1 + call ehg197(1,tau,d,f,dka,trla) + call ehg197(2,tau,d,f,dkb,trlb) + alpha=dfloat(tau-dka)/dfloat(dkb-dka) + trl=(1-alpha)*trla+alpha*trlb + return + end + subroutine ehg197(deg,tau,d,f,dk,trl) + integer d,deg,dk,tau + double precision trl, f + dk = 0 + if(deg.eq.1) dk=d+1 + if(deg.eq.2) dk=dfloat((d+2)*(d+1))/2.d0 + g1 = (-0.08125d0*d+0.13d0)*d+1.05d0 + trl = dk*(1+max(0.d0,(g1-f)/f)) + return + end + subroutine ehg192(y,d,n,nf,nv,nvmax,vval,lf,lq) + integer d,execnt,i,i1,i2,j,n,nf,nv,nvmax + integer lq(nvmax,nf) + DOUBLE PRECISION i3 + DOUBLE PRECISION lf(0:d,nvmax,nf),vval(0:d,nvmax),y(n) + save execnt + data execnt /0/ + execnt=execnt+1 + do 3 i2=1,nv + do 4 i1=0,d + vval(i1,i2)=0 + 4 continue + 3 continue + do 5 i=1,nv + do 6 j=1,nf + i3=y(lq(i,j)) + do 7 i1=0,d + vval(i1,i)=vval(i1,i)+i3*lf(i1,i,j) + 7 continue + 6 continue + 5 continue + return + end + DOUBLE PRECISION function ehg128(z,d,ncmax,vc,a,xi,lo,hi,c,v,nvmax + +,vval) + logical i10,i2,i3,i4,i5,i6,i7,i8,i9 + integer d,execnt,i,i1,i11,i12,ig,ii,j,lg,ll,m,nc,ncmax,nt,nv,nvmax + +,ur,vc + integer a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax),t(20) + DOUBLE PRECISION ge,gn,gs,gw,gpe,gpn,gps,gpw,h,phi0,phi1,psi0,psi1 + +,s,sew,sns,v0,v1,xibar + DOUBLE PRECISION g(0:8,256),g0(0:8),g1(0:8),v(nvmax,d),vval(0:d,nv + +max),xi(ncmax),z(d) + external ehg182,ehg184 + save execnt + data execnt /0/ + execnt=execnt+1 +c locate enclosing cell + nt=1 + t(nt)=1 + j=1 +c top of while loop + 3 if(.not.(a(j).ne.0))goto 4 + nt=nt+1 +c bug fix 2006-07-18 (thanks, btyner at gmail.com) + if(z(a(j)).le.xi(j))then + i1=lo(j) + else + i1=hi(j) + end if + t(nt)=i1 + if(.not.(nt.lt.20))then + call ehg182(181) + end if + j=t(nt) + goto 3 +c bottom of while loop + 4 continue +c tensor + do 5 i12=1,vc + do 6 i11=0,d + g(i11,i12)=vval(i11,c(i12,j)) + 6 continue + 5 continue + lg=vc + ll=c(1,j) + ur=c(vc,j) + do 7 i=d,1,-1 + h=(z(i)-v(ll,i))/(v(ur,i)-v(ll,i)) + if(h.lt.-.001D0)then + call ehg184('eval ',z,d,1) + call ehg184('lowerlimit ',v(ll,1),d,nvmax) + else + if(1.001D0.lt.h)then + call ehg184('eval ',z,d,1) + call ehg184('upperlimit ',v(ur,1),d,nvmax) + end if + end if + if(-.001D0.le.h)then + i2=(h.le.1.001D0) + else + i2=.false. + end if + if(.not.i2)then + call ehg182(122) + end if + lg=DFLOAT(lg)/2.D0 + do 8 ig=1,lg +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + g(0,ig)=phi0*g(0,ig)+phi1*g(0,ig+lg)+(psi0*g(i,ig)+psi1*g(i, + +ig+lg))*(v(ur,i)-v(ll,i)) + do 9 ii=1,i-1 + g(ii,ig)=phi0*g(ii,ig)+phi1*g(ii,ig+lg) + 9 continue + 8 continue + 7 continue + s=g(0,1) +c blending + if(d.eq.2)then +c ----- North ----- + v0=v(ll,1) + v1=v(ur,1) + do 10 i11=0,d + g0(i11)=vval(i11,c(3,j)) + 10 continue + do 11 i11=0,d + g1(i11)=vval(i11,c(4,j)) + 11 continue + xibar=v(ur,2) + m=nt-1 +c top of while loop + 12 if(m.eq.0)then + i4=.true. + else + if(a(t(m)).eq.2)then + i3=(xi(t(m)).eq.xibar) + else + i3=.false. + end if + i4=i3 + end if + if(.not.(.not.i4))goto 13 + m=m-1 +c voidp junk + goto 12 +c bottom of while loop + 13 if(m.ge.1)then + m=hi(t(m)) +c top of while loop + 14 if(.not.(a(m).ne.0))goto 15 + if(z(a(m)).le.xi(m))then + m=lo(m) + else + m=hi(m) + end if + goto 14 +c bottom of while loop + 15 if(v0.lt.v(c(1,m),1))then + v0=v(c(1,m),1) + do 16 i11=0,d + g0(i11)=vval(i11,c(1,m)) + 16 continue + end if + if(v(c(2,m),1).lt.v1)then + v1=v(c(2,m),1) + do 17 i11=0,d + g1(i11)=vval(i11,c(2,m)) + 17 continue + end if + end if + h=(z(1)-v0)/(v1-v0) +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + gn=phi0*g0(0)+phi1*g1(0)+(psi0*g0(1)+psi1*g1(1))*(v1-v0) + gpn=phi0*g0(2)+phi1*g1(2) +c ----- South ----- + v0=v(ll,1) + v1=v(ur,1) + do 18 i11=0,d + g0(i11)=vval(i11,c(1,j)) + 18 continue + do 19 i11=0,d + g1(i11)=vval(i11,c(2,j)) + 19 continue + xibar=v(ll,2) + m=nt-1 +c top of while loop + 20 if(m.eq.0)then + i6=.true. + else + if(a(t(m)).eq.2)then + i5=(xi(t(m)).eq.xibar) + else + i5=.false. + end if + i6=i5 + end if + if(.not.(.not.i6))goto 21 + m=m-1 +c voidp junk + goto 20 +c bottom of while loop + 21 if(m.ge.1)then + m=lo(t(m)) +c top of while loop + 22 if(.not.(a(m).ne.0))goto 23 + if(z(a(m)).le.xi(m))then + m=lo(m) + else + m=hi(m) + end if + goto 22 +c bottom of while loop + 23 if(v0.lt.v(c(3,m),1))then + v0=v(c(3,m),1) + do 24 i11=0,d + g0(i11)=vval(i11,c(3,m)) + 24 continue + end if + if(v(c(4,m),1).lt.v1)then + v1=v(c(4,m),1) + do 25 i11=0,d + g1(i11)=vval(i11,c(4,m)) + 25 continue + end if + end if + h=(z(1)-v0)/(v1-v0) +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + gs=phi0*g0(0)+phi1*g1(0)+(psi0*g0(1)+psi1*g1(1))*(v1-v0) + gps=phi0*g0(2)+phi1*g1(2) +c ----- East ----- + v0=v(ll,2) + v1=v(ur,2) + do 26 i11=0,d + g0(i11)=vval(i11,c(2,j)) + 26 continue + do 27 i11=0,d + g1(i11)=vval(i11,c(4,j)) + 27 continue + xibar=v(ur,1) + m=nt-1 +c top of while loop + 28 if(m.eq.0)then + i8=.true. + else + if(a(t(m)).eq.1)then + i7=(xi(t(m)).eq.xibar) + else + i7=.false. + end if + i8=i7 + end if + if(.not.(.not.i8))goto 29 + m=m-1 +c voidp junk + goto 28 +c bottom of while loop + 29 if(m.ge.1)then + m=hi(t(m)) +c top of while loop + 30 if(.not.(a(m).ne.0))goto 31 + if(z(a(m)).le.xi(m))then + m=lo(m) + else + m=hi(m) + end if + goto 30 +c bottom of while loop + 31 if(v0.lt.v(c(1,m),2))then + v0=v(c(1,m),2) + do 32 i11=0,d + g0(i11)=vval(i11,c(1,m)) + 32 continue + end if + if(v(c(3,m),2).lt.v1)then + v1=v(c(3,m),2) + do 33 i11=0,d + g1(i11)=vval(i11,c(3,m)) + 33 continue + end if + end if + h=(z(2)-v0)/(v1-v0) +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + ge=phi0*g0(0)+phi1*g1(0)+(psi0*g0(2)+psi1*g1(2))*(v1-v0) + gpe=phi0*g0(1)+phi1*g1(1) +c ----- West ----- + v0=v(ll,2) + v1=v(ur,2) + do 34 i11=0,d + g0(i11)=vval(i11,c(1,j)) + 34 continue + do 35 i11=0,d + g1(i11)=vval(i11,c(3,j)) + 35 continue + xibar=v(ll,1) + m=nt-1 +c top of while loop + 36 if(m.eq.0)then + i10=.true. + else + if(a(t(m)).eq.1)then + i9=(xi(t(m)).eq.xibar) + else + i9=.false. + end if + i10=i9 + end if + if(.not.(.not.i10))goto 37 + m=m-1 +c voidp junk + goto 36 +c bottom of while loop + 37 if(m.ge.1)then + m=lo(t(m)) +c top of while loop + 38 if(.not.(a(m).ne.0))goto 39 + if(z(a(m)).le.xi(m))then + m=lo(m) + else + m=hi(m) + end if + goto 38 +c bottom of while loop + 39 if(v0.lt.v(c(2,m),2))then + v0=v(c(2,m),2) + do 40 i11=0,d + g0(i11)=vval(i11,c(2,m)) + 40 continue + end if + if(v(c(4,m),2).lt.v1)then + v1=v(c(4,m),2) + do 41 i11=0,d + g1(i11)=vval(i11,c(4,m)) + 41 continue + end if + end if + h=(z(2)-v0)/(v1-v0) +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + gw=phi0*g0(0)+phi1*g1(0)+(psi0*g0(2)+psi1*g1(2))*(v1-v0) + gpw=phi0*g0(1)+phi1*g1(1) +c NS + h=(z(2)-v(ll,2))/(v(ur,2)-v(ll,2)) +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + sns=phi0*gs+phi1*gn+(psi0*gps+psi1*gpn)*(v(ur,2)-v(ll,2)) +c EW + h=(z(1)-v(ll,1))/(v(ur,1)-v(ll,1)) +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + sew=phi0*gw+phi1*ge+(psi0*gpw+psi1*gpe)*(v(ur,1)-v(ll,1)) + s=(sns+sew)-s + end if + ehg128=s + return + end + integer function ifloor(x) + DOUBLE PRECISION x + ifloor=x + if(ifloor.gt.x) ifloor=ifloor-1 + end + DOUBLE PRECISION functionDSIGN(a1,a2) + DOUBLE PRECISION a1, a2 + DSIGN=DABS(a1) + if(a2.ge.0)DSIGN=-DSIGN + end + subroutine ehg136(u,lm,m,n,d,nf,f,x,psi,y,rw,kernel,k,dist,eta,b,o + +d,o,ihat,w,rcond,sing,dd,tdeg,cdeg,s) + integer identi,d,dd,execnt,i,i1,ihat,info,j,k,kernel,l,lm,m,n,nf,o + +d,sing,tdeg + integer cdeg(8),psi(n) + double precision f,i2,rcond,scale,tol + double precision o(m,n),sigma(15),e(15,15),g(15,15),b(nf,k),dist(n + +),eta(nf),dgamma(15),q(8),qraux(15),rw(n),s(0:od,m),u(lm,d),w(nf), + +work(15),x(n,d),y(n) + external ehg127,ehg182,dqrsl + double precision ddot + external ddot + save execnt + data execnt /0/ +c V -> g +c U -> e +c Identity -> identi +c L -> o +c X -> b + execnt=execnt+1 + if(.not.(k.le.nf-1))then + call ehg182(104) + end if + if(.not.(k.le.15))then + call ehg182(105) + end if + do 3 identi=1,n + psi(identi)=identi + 3 continue + do 4 l=1,m + do 5 i1=1,d + q(i1)=u(l,i1) + 5 continue + call ehg127(q,n,d,nf,f,x,psi,y,rw,kernel,k,dist,eta,b,od,w,rcon + +d,sing,sigma,e,g,dgamma,qraux,work,tol,dd,tdeg,cdeg,s(0,l)) + if(ihat.eq.1)then +c $L sub {l,l} = +c V sub {1,:} SIGMA sup {+} U sup T +c (Q sup T W e sub i )$ + if(.not.(m.eq.n))then + call ehg182(123) + end if +c find $i$ such that $l = psi sub i$ + i=1 +c top of while loop + 6 if(.not.(l.ne.psi(i)))goto 7 + i=i+1 + if(.not.(i.lt.nf))then + call ehg182(123) + end if + goto 6 +c bottom of while loop + 7 do 8 i1=1,nf + eta(i1)=0 + 8 continue + eta(i)=w(i) +c $eta = Q sup T W e sub i$ + call dqrsl(b,nf,nf,k,qraux,eta,eta,eta,eta,eta,eta,1000,info + +) +c $gamma = U sup T eta sub {1:k}$ + do 9 i1=1,k + dgamma(i1)=0 + 9 continue + do 10 j=1,k + i2=eta(j) + do 11 i1=1,k + dgamma(i1)=dgamma(i1)+i2*e(j,i1) + 11 continue + 10 continue +c $gamma = SIGMA sup {+} gamma$ + do 12 j=1,k + if(tol.lt.sigma(j))then + dgamma(j)=dgamma(j)/sigma(j) + else + dgamma(j)=0.d0 + end if + 12 continue +c voidp junk +c voidp junk + o(l,1)=ddot(k,g(1,1),15,dgamma,1) + else + if(ihat.eq.2)then +c $L sub {l,:} = +c V sub {1,:} SIGMA sup {+} +c ( U sup T Q sup T ) W $ + do 13 i1=1,n + o(l,i1)=0 + 13 continue + do 14 j=1,k + do 15 i1=1,nf + eta(i1)=0 + 15 continue + do 16 i1=1,k + eta(i1)=e(i1,j) + 16 continue + call dqrsl(b,nf,nf,k,qraux,eta,eta,work,work,work,work + +,10000,info) + if(tol.lt.sigma(j))then + scale=1.d0/sigma(j) + else + scale=0.d0 + end if + do 17 i1=1,nf + eta(i1)=eta(i1)*(scale*w(i1)) + 17 continue + do 18 i=1,nf + o(l,psi(i))=o(l,psi(i))+g(1,j)*eta(i) + 18 continue + 14 continue + end if + end if + 4 continue + return + end + subroutine ehg139(v,nvmax,nv,n,d,nf,f,x,pi,psi,y,rw,trl,kernel,k,d + +ist,phi,eta,b,od,w,diagl,vval2,ncmax,vc,a,xi,lo,hi,c,vhit,rcond,si + +ng,dd,tdeg,cdeg,lq,lf,setlf,s) + logical setlf + integer identi,d,dd,execnt,i,i2,i3,i5,i6,ii,ileaf,info,j,k,kernel, + +l,n,nc,ncmax,nf,nleaf,nv,nvmax,od,sing,tdeg,vc + integer lq(nvmax,nf),a(ncmax),c(vc,ncmax),cdeg(8),hi(ncmax),leaf(2 + +56),lo(ncmax),phi(n),pi(n),psi(n),vhit(nvmax) + DOUBLE PRECISION f,i1,i4,i7,rcond,scale,term,tol,trl + DOUBLE PRECISION lf(0:d,nvmax,nf),sigma(15),u(15,15),e(15,15),b(nf + +,k),diagl(n),dist(n),eta(nf),DGAMMA(15),q(8),qraux(15),rw(n),s(0:o + +d,nv),v(nvmax,d),vval2(0:d,nv),w(nf),work(15),x(n,d),xi(ncmax),y(n + +),z(8) + external ehg127,ehg182,DQRSL,ehg137 + DOUBLE PRECISION ehg128 + external ehg128 + DOUBLE PRECISION DDOT + external DDOT + save execnt + data execnt /0/ +c V -> e +c Identity -> identi +c X -> b + execnt=execnt+1 +c l2fit with trace(L) + if(.not.(k.le.nf-1))then + call ehg182(104) + end if + if(.not.(k.le.15))then + call ehg182(105) + end if + if(trl.ne.0)then + do 3 i5=1,n + diagl(i5)=0 + 3 continue + do 4 i6=1,nv + do 5 i5=0,d + vval2(i5,i6)=0 + 5 continue + 4 continue + end if + do 6 identi=1,n + psi(identi)=identi + 6 continue + do 7 l=1,nv + do 8 i5=1,d + q(i5)=v(l,i5) + 8 continue + call ehg127(q,n,d,nf,f,x,psi,y,rw,kernel,k,dist,eta,b,od,w,rcon + +d,sing,sigma,u,e,DGAMMA,qraux,work,tol,dd,tdeg,cdeg,s(0,l)) + if(trl.ne.0)then +c invert $psi$ + do 9 i5=1,n + phi(i5)=0 + 9 continue + do 10 i=1,nf + phi(psi(i))=i + 10 continue + do 11 i5=1,d + z(i5)=v(l,i5) + 11 continue + call ehg137(z,vhit(l),leaf,nleaf,d,nv,nvmax,ncmax,vc,a,xi,lo + +,hi,c,v) + do 12 ileaf=1,nleaf + do 13 ii=lo(leaf(ileaf)),hi(leaf(ileaf)) + i=phi(pi(ii)) + if(i.ne.0)then + if(.not.(psi(i).eq.pi(ii)))then + call ehg182(194) + end if + do 14 i5=1,nf + eta(i5)=0 + 14 continue + eta(i)=w(i) +c $eta = Q sup T W e sub i$ + call DQRSL(b,nf,nf,k,qraux,eta,work,eta,eta,work,wo + +rk,1000,info) + do 15 j=1,k + if(tol.lt.sigma(j))then + i4=DDOT(k,u(1,j),1,eta,1)/sigma(j) + else + i4=0.D0 + end if + DGAMMA(j)=i4 + 15 continue + do 16 j=1,d+1 +c bug fix 2006-07-15 for k=1, od>1. (thanks btyner at gmail.com) + if(j.le.k)then + vval2(j-1,l)=DDOT(k,e(j,1),15,DGAMMA,1) + else + vval2(j-1,l)=0 + end if + 16 continue + do 17 i5=1,d + z(i5)=x(pi(ii),i5) + 17 continue + term=ehg128(z,d,ncmax,vc,a,xi,lo,hi,c,v,nvmax,vval2 + +) + diagl(pi(ii))=diagl(pi(ii))+term + do 18 i5=0,d + vval2(i5,l)=0 + 18 continue + end if + 13 continue + 12 continue + end if + if(setlf)then +c $Lf sub {:,l,:} = V SIGMA sup {+} U sup T Q sup T W$ + if(.not.(k.ge.d+1))then + call ehg182(196) + end if + do 19 i5=1,nf + lq(l,i5)=psi(i5) + 19 continue + do 20 i6=1,nf + do 21 i5=0,d + lf(i5,l,i6)=0 + 21 continue + 20 continue + do 22 j=1,k + do 23 i5=1,nf + eta(i5)=0 + 23 continue + do 24 i5=1,k + eta(i5)=u(i5,j) + 24 continue + call DQRSL(b,nf,nf,k,qraux,eta,eta,work,work,work,work,10 + +000,info) + if(tol.lt.sigma(j))then + scale=1.D0/sigma(j) + else + scale=0.D0 + end if + do 25 i5=1,nf + eta(i5)=eta(i5)*(scale*w(i5)) + 25 continue + do 26 i=1,nf + i7=eta(i) + do 27 i5=0,d + if(i5.lt.k)then + lf(i5,l,i)=lf(i5,l,i)+e(1+i5,j)*i7 + else + lf(i5,l,i)=0 + end if + 27 continue + 26 continue + 22 continue + end if + 7 continue + if(trl.ne.0)then + if(n.le.0)then + trl=0.D0 + else + i3=n + i1=diagl(i3) + do 28 i2=i3-1,1,-1 + i1=diagl(i2)+i1 + 28 continue + trl=i1 + end if + end if + return + end + subroutine dqrdc(x,ldx,n,p,qraux,jpvt,work,job) + integer ldx,n,p,job + integer jpvt(1) + double precision x(ldx,1),qraux(1),work(1) +c +c dqrdc uses householder transformations to compute the qr +c factorization of an n by p matrix x. column pivoting +c based on the 2-norms of the reduced columns may be +c performed at the users option. +c +c on entry +c +c x double precision(ldx,p), where ldx .ge. n. +c x contains the matrix whose decomposition is to be +c computed. +c +c ldx integer. +c ldx is the leading dimension of the array x. +c +c n integer. +c n is the number of rows of the matrix x. +c +c p integer. +c p is the number of columns of the matrix x. +c +c jpvt integer(p). +c jpvt contains integers that control the selection +c of the pivot columns. the k-th column x(k) of x +c is placed in one of three classes according to the +c value of jpvt(k). +c +c if jpvt(k) .gt. 0, then x(k) is an initial +c column. +c +c if jpvt(k) .eq. 0, then x(k) is a free column. +c +c if jpvt(k) .lt. 0, then x(k) is a final column. +c +c before the decomposition is computed, initial columns +c are moved to the beginning of the array x and final +c columns to the end. both initial and final columns +c are frozen in place during the computation and only +c free columns are moved. at the k-th stage of the +c reduction, if x(k) is occupied by a free column +c it is interchanged with the free column of largest +c reduced norm. jpvt is not referenced if +c job .eq. 0. +c +c work double precision(p). +c work is a work array. work is not referenced if +c job .eq. 0. +c +c job integer. +c job is an integer that initiates column pivoting. +c if job .eq. 0, no pivoting is done. +c if job .ne. 0, pivoting is done. +c +c on return +c +c x x contains in its upper triangle the upper +c triangular matrix r of the qr factorization. +c below its diagonal x contains information from +c which the orthogonal part of the decomposition +c can be recovered. note that if pivoting has +c been requested, the decomposition is not that +c of the original matrix x but that of x +c with its columns permuted as described by jpvt. +c +c qraux double precision(p). +c qraux contains further information required to recover +c the orthogonal part of the decomposition. +c +c jpvt jpvt(k) contains the index of the column of the +c original matrix that has been interchanged into +c the k-th column, if pivoting was requested. +c +c linpack. this version dated 08/14/78 . +c g.w. stewart, university of maryland, argonne national lab. +c +c dqrdc uses the following functions and subprograms. +c +c blas daxpy,ddot,dscal,dswap,dnrm2 +c fortran dabs,dmax1,min0,dsqrt +c +c internal variables +c + integer j,jp,l,lp1,lup,maxj,pl,pu + double precision maxnrm,dnrm2,tt + double precision ddot,nrmxl,t + logical negj,swapj +c +c + pl = 1 + pu = 0 + if (job .eq. 0) go to 60 +c +c pivoting has been requested. rearrange the columns +c according to jpvt. +c + do 20 j = 1, p + swapj = jpvt(j) .gt. 0 + negj = jpvt(j) .lt. 0 + jpvt(j) = j + if (negj) jpvt(j) = -j + if (.not.swapj) go to 10 + if (j .ne. pl) call dswap(n,x(1,pl),1,x(1,j),1) + jpvt(j) = jpvt(pl) + jpvt(pl) = j + pl = pl + 1 + 10 continue + 20 continue + pu = p + do 50 jj = 1, p + j = p - jj + 1 + if (jpvt(j) .ge. 0) go to 40 + jpvt(j) = -jpvt(j) + if (j .eq. pu) go to 30 + call dswap(n,x(1,pu),1,x(1,j),1) + jp = jpvt(pu) + jpvt(pu) = jpvt(j) + jpvt(j) = jp + 30 continue + pu = pu - 1 + 40 continue + 50 continue + 60 continue +c +c compute the norms of the free columns. +c + if (pu .lt. pl) go to 80 + do 70 j = pl, pu + qraux(j) = dnrm2(n,x(1,j),1) + work(j) = qraux(j) + 70 continue + 80 continue +c +c perform the householder reduction of x. +c + lup = min0(n,p) + do 200 l = 1, lup + if (l .lt. pl .or. l .ge. pu) go to 120 +c +c locate the column of largest norm and bring it +c into the pivot position. +c + maxnrm = 0.0d0 + maxj = l + do 100 j = l, pu + if (qraux(j) .le. maxnrm) go to 90 + maxnrm = qraux(j) + maxj = j + 90 continue + 100 continue + if (maxj .eq. l) go to 110 + call dswap(n,x(1,l),1,x(1,maxj),1) + qraux(maxj) = qraux(l) + work(maxj) = work(l) + jp = jpvt(maxj) + jpvt(maxj) = jpvt(l) + jpvt(l) = jp + 110 continue + 120 continue + qraux(l) = 0.0d0 + if (l .eq. n) go to 190 +c +c compute the householder transformation for column l. +c + nrmxl = dnrm2(n-l+1,x(l,l),1) + if (nrmxl .eq. 0.0d0) go to 180 + if (x(l,l) .ne. 0.0d0) nrmxl = dsign(nrmxl,x(l,l)) + call dscal(n-l+1,1.0d0/nrmxl,x(l,l),1) + x(l,l) = 1.0d0 + x(l,l) +c +c apply the transformation to the remaining columns, +c updating the norms. +c + lp1 = l + 1 + if (p .lt. lp1) go to 170 + do 160 j = lp1, p + t = -ddot(n-l+1,x(l,l),1,x(l,j),1)/x(l,l) + call daxpy(n-l+1,t,x(l,l),1,x(l,j),1) + if (j .lt. pl .or. j .gt. pu) go to 150 + if (qraux(j) .eq. 0.0d0) go to 150 + tt = 1.0d0 - (dabs(x(l,j))/qraux(j))**2 + tt = dmax1(tt,0.0d0) + t = tt + tt = 1.0d0 + 0.05d0*tt*(qraux(j)/work(j))**2 + if (tt .eq. 1.0d0) go to 130 + qraux(j) = qraux(j)*dsqrt(t) + go to 140 + 130 continue + qraux(j) = dnrm2(n-l,x(l+1,j),1) + work(j) = qraux(j) + 140 continue + 150 continue + 160 continue + 170 continue +c +c save the transformation. +c + qraux(l) = x(l,l) + x(l,l) = -nrmxl + 180 continue + 190 continue + 200 continue + return + end + integer function idamax(n,dx,incx) +c +c finds the index of element having max. absolute value. +c jack dongarra, linpack, 3/11/78. +c + double precision dx(1),dmax + integer i,incx,ix,n +c + idamax = 0 + if( n .lt. 1 ) return + idamax = 1 + if(n.eq.1)return + if(incx.eq.1)go to 20 +c +c code for increment not equal to 1 +c + ix = 1 + dmax = dabs(dx(1)) + ix = ix + incx + do 10 i = 2,n + if(dabs(dx(ix)).le.dmax) go to 5 + idamax = i + dmax = dabs(dx(ix)) + 5 ix = ix + incx + 10 continue + return +c +c code for increment equal to 1 +c + 20 dmax = dabs(dx(1)) + do 30 i = 2,n + if(dabs(dx(i)).le.dmax) go to 30 + idamax = i + dmax = dabs(dx(i)) + 30 continue + return + end + subroutine lowesb(xx,yy,ww,diagl,infl,iv,liv,lv,wv) + logical infl,setlf + integer execnt + integer iv(*) + DOUBLE PRECISION trl + DOUBLE PRECISION diagl(*),wv(*),ww(*),xx(*),yy(*) + external ehg131,ehg182,ehg183 + integer ifloor + external ifloor + save execnt + data execnt /0/ + execnt=execnt+1 + if(.not.(iv(28).ne.173))then + call ehg182(174) + end if + if(iv(28).ne.172)then + if(.not.(iv(28).eq.171))then + call ehg182(171) + end if + end if + iv(28)=173 + if(infl)then + trl=1.D0 + else + trl=0.D0 + end if + setlf=(iv(27).ne.iv(25)) + call ehg131(xx,yy,ww,trl,diagl,iv(20),iv(29),iv(3),iv(2),iv(5),iv( + +17),iv(4),iv(6),iv(14),iv(19),wv(1),iv(iv(7)),iv(iv(8)),iv(iv(9)), + +iv(iv(10)),iv(iv(22)),iv(iv(27)),wv(iv(11)),iv(iv(23)),wv(iv(13)), + +wv(iv(12)),wv(iv(15)),wv(iv(16)),wv(iv(18)),ifloor(iv(3)*wv(2)),wv + +(3),wv(iv(26)),wv(iv(24)),wv(4),iv(30),iv(33),iv(32),iv(41),iv(iv( + +25)),wv(iv(34)),setlf) + if(iv(14).lt.iv(6)+DFLOAT(iv(4))/2.D0)then + call ehg183('Warning. k-d tree limited by memory; nvmax=',iv(14 + +),1,1) + else + if(iv(17).lt.iv(5)+2)then + call ehg183('Warning. k-d tree limited by memory. ncmax=',iv + +(17),1,1) + end if + end if + return + end + subroutine lowesd(versio,iv,liv,lv,v,d,n,f,ideg,nvmax,setlf) + logical setlf + integer bound,d,execnt,i,i1,i2,ideg,j,liv,lv,n,ncmax,nf,nvmax,vc,v + +ersio + integer iv(liv) + double precision f + double precision v(lv) + external ehg182 + integer ifloor + external ifloor + save execnt + data execnt /0/ +c version -> versio + execnt=execnt+1 + if(.not.(versio.eq.106))then + call ehg182(100) + end if + iv(28)=171 + iv(2)=d + iv(3)=n + vc=2**d + iv(4)=vc + if(.not.(0.lt.f))then + call ehg182(120) + end if + nf=min(n,ifloor(n*f)) + iv(19)=nf + iv(20)=1 + if(ideg.eq.0)then + i1=1 + else + if(ideg.eq.1)then + i1=d+1 + else + if(ideg.eq.2)then + i1=dfloat((d+2)*(d+1))/2.d0 + end if + end if + end if + iv(29)=i1 + iv(21)=1 + iv(14)=nvmax + ncmax=nvmax + iv(17)=ncmax + iv(30)=0 + iv(32)=ideg + if(.not.(ideg.ge.0))then + call ehg182(195) + end if + if(.not.(ideg.le.2))then + call ehg182(195) + end if + iv(33)=d + do 3 i2=41,49 + iv(i2)=ideg + 3 continue + iv(7)=50 + iv(8)=iv(7)+ncmax + iv(9)=iv(8)+vc*ncmax + iv(10)=iv(9)+ncmax + iv(22)=iv(10)+ncmax +c initialize permutation + j=iv(22)-1 + do 4 i=1,n + iv(j+i)=i + 4 continue + iv(23)=iv(22)+n + iv(25)=iv(23)+nvmax + if(setlf)then + iv(27)=iv(25)+nvmax*nf + else + iv(27)=iv(25) + end if + bound=iv(27)+n + if(.not.(bound-1.le.liv))then + call ehg182(102) + end if + iv(11)=50 + iv(13)=iv(11)+nvmax*d + iv(12)=iv(13)+(d+1)*nvmax + iv(15)=iv(12)+ncmax + iv(16)=iv(15)+n + iv(18)=iv(16)+nf + iv(24)=iv(18)+iv(29)*nf + iv(34)=iv(24)+(d+1)*nvmax + if(setlf)then + iv(26)=iv(34)+(d+1)*nvmax*nf + else + iv(26)=iv(34) + end if + bound=iv(26)+nf + if(.not.(bound-1.le.lv))then + call ehg182(103) + end if + v(1)=f + v(2)=0.05d0 + v(3)=0.d0 + v(4)=1.d0 + return + end + subroutine lowese(iv,liv,lv,wv,m,z,s) + integer execnt,m + integer iv(*) + double precision s(m),wv(*),z(m,1) + external ehg133,ehg182 + save execnt + data execnt /0/ + execnt=execnt+1 + if(.not.(iv(28).ne.172))then + call ehg182(172) + end if + if(.not.(iv(28).eq.173))then + call ehg182(173) + end if + call ehg133(iv(3),iv(2),iv(4),iv(14),iv(5),iv(17),iv(iv(7)),iv(iv( + +8)),iv(iv(9)),iv(iv(10)),wv(iv(11)),wv(iv(13)),wv(iv(12)),m,z,s) + return + end + subroutine lowesf(xx,yy,ww,iv,liv,lv,wv,m,z,l,ihat,s) + logical i1 + integer execnt,ihat,m,n + integer iv(*) + double precision l(m,*),s(m),wv(*),ww(*),xx(*),yy(*),z(m,1) + external ehg182,ehg136 + save execnt + data execnt /0/ + execnt=execnt+1 + if(171.le.iv(28))then + i1=(iv(28).le.174) + else + i1=.false. + end if + if(.not.i1)then + call ehg182(171) + end if + iv(28)=172 + if(.not.(iv(14).ge.iv(19)))then + call ehg182(186) + end if + call ehg136(z,m,m,iv(3),iv(2),iv(19),wv(1),xx,iv(iv(22)),yy,ww,iv( + +20),iv(29),wv(iv(15)),wv(iv(16)),wv(iv(18)),0,l,ihat,wv(iv(26)),wv + +(4),iv(30),iv(33),iv(32),iv(41),s) + return + end + subroutine lowesl(iv,liv,lv,wv,m,z,l) + integer execnt,m,n + integer iv(*) + double precision l(m,*),wv(*),z(m,1) + external ehg182,ehg191 + save execnt + data execnt /0/ + execnt=execnt+1 + if(.not.(iv(28).ne.172))then + call ehg182(172) + end if + if(.not.(iv(28).eq.173))then + call ehg182(173) + end if + if(.not.(iv(26).ne.iv(34)))then + call ehg182(175) + end if + call ehg191(m,z,l,iv(2),iv(3),iv(19),iv(6),iv(17),iv(4),iv(iv(7)), + +wv(iv(12)),iv(iv(10)),iv(iv(9)),iv(iv(8)),wv(iv(11)),iv(14),wv(iv( + +24)),wv(iv(34)),iv(iv(25))) + return + end + subroutine lowesr(yy,iv,liv,lv,wv) + integer execnt + integer iv(*) + DOUBLE PRECISION wv(*),yy(*) + external ehg182,ehg192 + save execnt + data execnt /0/ + execnt=execnt+1 + if(.not.(iv(28).ne.172))then + call ehg182(172) + end if + if(.not.(iv(28).eq.173))then + call ehg182(173) + end if + call ehg192(yy,iv(2),iv(3),iv(19),iv(6),iv(14),wv(iv(13)),wv(iv(34 + +)),iv(iv(25))) + return + end + subroutine lowesw(res,n,rw,pi) + integer identi,execnt,i,i1,n,nh + integer pi(n) + double precision cmad,rsmall + double precision res(n),rw(n) + external ehg106 + integer ifloor + external ifloor + double precision d1mach + external d1mach + save execnt + data execnt /0/ +c Identity -> identi + execnt=execnt+1 +c tranliterated from Devlin's ratfor +c find median of absolute residuals + do 3 i1=1,n + rw(i1)=dabs(res(i1)) + 3 continue + do 4 identi=1,n + pi(identi)=identi + 4 continue + nh=ifloor(dfloat(n)/2.d0)+1 +c partial sort to find 6*mad + call ehg106(1,n,nh,1,rw,pi,n) + if((n-nh)+1.lt.nh)then + call ehg106(1,nh-1,nh-1,1,rw,pi,n) + cmad=3*(rw(pi(nh))+rw(pi(nh-1))) + else + cmad=6*rw(pi(nh)) + end if + rsmall=d1mach(1) + if(cmad.lt.rsmall)then + do 5 i1=1,n + rw(i1)=1 + 5 continue + else + do 6 i=1,n + if(cmad*0.999d0.lt.rw(i))then + rw(i)=0 + else + if(cmad*0.001d0.lt.rw(i))then + rw(i)=(1-(rw(i)/cmad)**2)**2 + else + rw(i)=1 + end if + end if + 6 continue + end if + return + end + subroutine lowesp(n,y,yhat,pwgts,rwgts,pi,ytilde) + integer identi,execnt,i2,i3,i5,m,n + integer pi(n) + double precision c,i1,i4,mad + double precision pwgts(n),rwgts(n),y(n),yhat(n),ytilde(n) + external ehg106 + integer ifloor + external ifloor + save execnt + data execnt /0/ +c Identity -> identi + execnt=execnt+1 +c median absolute deviation + do 3 i5=1,n + ytilde(i5)=dabs(y(i5)-yhat(i5))*dsqrt(pwgts(i5)) + 3 continue + do 4 identi=1,n + pi(identi)=identi + 4 continue + m=ifloor(dfloat(n)/2.d0)+1 + call ehg106(1,n,m,1,ytilde,pi,n) + if((n-m)+1.lt.m)then + call ehg106(1,m-1,m-1,1,ytilde,pi,n) + mad=(ytilde(pi(m-1))+ytilde(pi(m)))/2 + else + mad=ytilde(pi(m)) + end if +c magic constant + c=(6*mad)**2/5 + do 5 i5=1,n + ytilde(i5)=1-((y(i5)-yhat(i5))**2*pwgts(i5))/c + 5 continue + do 6 i5=1,n + ytilde(i5)=ytilde(i5)*dsqrt(rwgts(i5)) + 6 continue + if(n.le.0)then + i4=0.d0 + else + i3=n + i1=ytilde(i3) + do 7 i2=i3-1,1,-1 + i1=ytilde(i2)+i1 + 7 continue + i4=i1 + end if + c=n/i4 +c pseudovalues + do 8 i5=1,n + ytilde(i5)=yhat(i5)+(c*rwgts(i5))*(y(i5)-yhat(i5)) + 8 continue + return + end + subroutine ehg124(ll,uu,d,n,nv,nc,ncmax,vc,x,pi,a,xi,lo,hi,c,v,vhi + +t,nvmax,fc,fd,dd) + logical i1,i2,i3,leaf + integer d,dd,execnt,fc,i4,inorm2,k,l,ll,m,n,nc,ncmax,nv,nvmax,p,u, + +uu,vc,lower,upper,check,offset + integer a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax),pi(n),vhit(nvmax) + DOUBLE PRECISION diam,fd + DOUBLE PRECISION diag(8),sigma(8),v(nvmax,d),x(n,d),xi(ncmax) + external ehg125,ehg106,ehg129 + integer IDAMAX + external IDAMAX + save execnt + data execnt /0/ + execnt=execnt+1 + p=1 + l=ll + u=uu + lo(p)=l + hi(p)=u +c top of while loop + 3 if(.not.(p.le.nc))goto 4 + do 5 i4=1,dd + diag(i4)=v(c(vc,p),i4)-v(c(1,p),i4) + 5 continue + diam=0 + do 6 inorm2=1,dd + diam=diam+diag(inorm2)**2 + 6 continue + diam=DSQRT(diam) + if((u-l)+1.le.fc)then + i1=.true. + else + i1=(diam.le.fd) + end if + if(i1)then + leaf=.true. + else + if(ncmax.lt.nc+2)then + i2=.true. + else + i2=(nvmax.lt.nv+DFLOAT(vc)/2.D0) + end if + leaf=i2 + end if + if(.not.leaf)then + call ehg129(l,u,dd,x,pi,n,sigma) + k=IDAMAX(dd,sigma,1) + m=DFLOAT(l+u)/2.D0 + call ehg106(l,u,m,1,x(1,k),pi,n) + +c bug fix from btyner at gmail.com 2006-07-20 + offset = 0 + 7 if(((m+offset).ge.u).or.((m+offset).lt.l))then + goto 8 + else + if(offset.lt.0)then + lower = l + check = m + offset + upper = check + else + lower = m + offset + 1 + check = lower + upper = u + end if + call ehg106(lower,upper,check,1,x(1,k),pi,n) + if(x(pi(m + offset),k).eq.x(pi(m+offset+1),k))then + offset = (-offset) + if(offset.ge.0)then + offset = offset + 1 + end if + goto 7 + else + m = m + offset + goto 8 + end if + end if + + 8 if(v(c(1,p),k).eq.x(pi(m),k))then + leaf=.true. + else + leaf=(v(c(vc,p),k).eq.x(pi(m),k)) + end if + end if + if(leaf)then + a(p)=0 + else + a(p)=k + xi(p)=x(pi(m),k) +c left son + nc=nc+1 + lo(p)=nc + lo(nc)=l + hi(nc)=m +c right son + nc=nc+1 + hi(p)=nc + lo(nc)=m+1 + hi(nc)=u + call ehg125(p,nv,v,vhit,nvmax,d,k,xi(p),2**(k-1),2**(d-k),c( + +1,p),c(1,lo(p)),c(1,hi(p))) + end if + p=p+1 + l=lo(p) + u=hi(p) + goto 3 +c bottom of while loop + 4 return + end + subroutine ehg129(l,u,d,x,pi,n,sigma) + integer d,execnt,i,k,l,n,u + integer pi(n) + DOUBLE PRECISION machin,alpha,beta,t + DOUBLE PRECISION sigma(d),x(n,d) + DOUBLE PRECISION D1MACH + external D1MACH + save machin,execnt + data execnt /0/ +c MachInf -> machin + execnt=execnt+1 + if(execnt.eq.1)then + machin=D1MACH(2) + end if + do 3 k=1,d + alpha=machin + beta=-machin + do 4 i=l,u + t=x(pi(i),k) + alpha=min(alpha,x(pi(i),k)) + beta=max(beta,t) + 4 continue + sigma(k)=beta-alpha + 3 continue + return + end + subroutine ehg137(z,kappa,leaf,nleaf,d,nv,nvmax,ncmax,vc,a,xi,lo,h + +i,c,v) + integer d,execnt,nc,ncmax,nleaf,p,stackt + integer a(ncmax),hi(ncmax),leaf(256),lo(ncmax),pstack(20) + DOUBLE PRECISION xi(ncmax),z(d) + external ehg182 + save execnt + data execnt /0/ +c stacktop -> stackt + execnt=execnt+1 +c find leaf cells affected by $z$ + stackt=0 + p=1 + nleaf=0 +c top of while loop + 3 if(.not.(0.lt.p))goto 4 + if(a(p).eq.0)then +c leaf + nleaf=nleaf+1 + leaf(nleaf)=p +c Pop + if(stackt.ge.1)then + p=pstack(stackt) + else + p=0 + end if + stackt=max(0,stackt-1) + else + if(z(a(p)).eq.xi(p))then +c Push + stackt=stackt+1 + if(.not.(stackt.le.20))then + call ehg182(187) + end if + pstack(stackt)=hi(p) + p=lo(p) + else + if(z(a(p)).le.xi(p))then + p=lo(p) + else + p=hi(p) + end if + end if + end if + goto 3 +c bottom of while loop + 4 if(.not.(nleaf.le.256))then + call ehg182(185) + end if + return + end Added: trunk/Lib/sandbox/pyloess/sandbox/src/misc.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/misc.c 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/misc.c 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,334 @@ +#include "S.h" +#include "loess.h" +#include +#include + +static double +fmin(double a, double b) +{ + return(a < b ? a : b); +} + +static double +fmax(double a, double b) +{ + return(a > b ? a : b); +} + + + + +void +anova(loess *one, loess *two, + struct anova_struct *out) +{ + double one_d1, one_d2, one_s, two_d1, two_d2, two_s, + rssdiff, d1diff, tmp, pf(); + int max_enp; + + one_d1 = one->outputs.one_delta; + one_d2 = one->outputs.two_delta; + one_s = one->outputs.s; + two_d1 = two->outputs.one_delta; + two_d2 = two->outputs.two_delta; + two_s = two->outputs.s; + + rssdiff = fabs(one_s * one_s * one_d1 - two_s * two_s * two_d1); + d1diff = fabs(one_d1 - two_d1); + out->dfn = d1diff * d1diff / fabs(one_d2 - two_d2); + max_enp = (one->outputs.enp > two->outputs.enp); + tmp = max_enp ? one_d1 : two_d1; + out->dfd = tmp * tmp / (max_enp ? one_d2 : two_d2); + tmp = max_enp ? one_s : two_s; + out->F_value = (rssdiff / d1diff) / (tmp * tmp); + out->Pr_F = 1 - pf(out->F_value, out->dfn, out->dfd); +} + +void +pointwise(predicted *pre, int m, double coverage, + struct ci_struct *ci) +{ + double t_dist, limit, fit, qt(); + int i; + + ci->fit = (double *) malloc(m * sizeof(double)); + ci->upper = (double *) malloc(m * sizeof(double)); + ci->lower = (double *) malloc(m * sizeof(double)); + + t_dist = qt(1 - (1 - coverage)/2, pre->df); + for(i = 0; i < m; i++) { + limit = pre->se_fit[i] * t_dist; + ci->fit[i] = fit = pre->fit[i]; + ci->upper[i] = fit + limit; + ci->lower[i] = fit - limit; + } +} + +void +pw_free_mem(struct ci_struct *ci) +{ + free(ci->fit); + free(ci->upper); + free(ci->lower); +} + +double +pf(double q, double df1, double df2) +{ + double ibeta(); + return(ibeta(q*df1/(df2+q*df1), df1/2, df2/2)); +} + +double +qt(double p, double df) +{ + double t, invibeta(); + t = invibeta(fabs(2*p-1), 0.5, df/2); + return((p>0.5?1:-1) * sqrt(t*df/(1-t))); +} + +/**********************************************************************/ + /* + * Incomplete beta function. + * Reference: Abramowitz and Stegun, 26.5.8. + * Assumptions: 0 <= x <= 1; a,b > 0. + */ +#define DOUBLE_EPS 2.2204460492503131E-16 +#define IBETA_LARGE 1.0e30 +#define IBETA_SMALL 1.0e-30 + +double +ibeta(double x, double a, double b) +{ + int flipped = 0, i, k, count; + double I, temp, pn[6], ak, bk, next, prev, factor, val; + + if (x <= 0) + return(0); + if (x >= 1) + return(1); + + /* use ibeta(x,a,b) = 1-ibeta(1-x,b,a) */ + if ((a+b+1)*x > (a+1)) { + flipped = 1; + temp = a; + a = b; + b = temp; + x = 1 - x; + } + + pn[0] = 0.0; + pn[2] = pn[3] = pn[1] = 1.0; + count = 1; + val = x/(1.0-x); + bk = 1.0; + next = 1.0; + do { + count++; + k = count/2; + prev = next; + if (count%2 == 0) + ak = -((a+k-1.0)*(b-k)*val)/((a+2.0*k-2.0)*(a+2.0*k-1.0)); + else + ak = ((a+b+k-1.0)*k*val)/((a+2.0*k)*(a+2.0*k-1.0)); + pn[4] = bk*pn[2] + ak*pn[0]; + pn[5] = bk*pn[3] + ak*pn[1]; + next = pn[4] / pn[5]; + for (i=0; i<=3; i++) + pn[i] = pn[i+2]; + if (fabs(pn[4]) >= IBETA_LARGE) + for (i=0; i<=3; i++) + pn[i] /= IBETA_LARGE; + if (fabs(pn[4]) <= IBETA_SMALL) + for (i=0; i<=3; i++) + pn[i] /= IBETA_SMALL; + } while (fabs(next-prev) > DOUBLE_EPS*prev); + factor = a*log(x) + (b-1)*log(1-x); + factor -= gamma(a+1) + gamma(b) - gamma(a+b); + I = exp(factor) * next; + return(flipped ? 1-I : I); +} + +/* + * Rational approximation to inverse Gaussian distribution. + * Absolute error is bounded by 4.5e-4. + * Reference: Abramowitz and Stegun, page 933. + * Assumption: 0 < p < 1. + */ + +static double num[] = { + 2.515517, + 0.802853, + 0.010328 +}; + +static double den[] = { + 1.000000, + 1.432788, + 0.189269, + 0.001308 +}; + +double +invigauss_quick(double p) +{ + int lower; + double t, n, d, q; + + if(p == 0.5) + return(0); + lower = p < 0.5; + p = lower ? p : 1 - p; + t = sqrt(-2 * log(p)); + n = (num[2]*t + num[1])*t + num[0]; + d = ((den[3]*t + den[2])*t + den[1])*t + den[0]; + q = lower ? n/d - t : t - n/d; + return(q); +} + +/* + * Inverse incomplete beta function. + * Assumption: 0 <= p <= 1, a,b > 0. + */ + +double +invibeta(double p, double a, double b) +{ + int i; + double ql, qr, qm, qdiff; + double pl, pr, pm, pdiff; + double invibeta_quick(), ibeta(); + +/* MEANINGFUL(qm);*/ + qm = 0; + if(p == 0 || p == 1) + return(p); + + /* initialize [ql,qr] containing the root */ + ql = qr = invibeta_quick(p, a, b); + pl = pr = ibeta(ql, a, b); + if(pl == p) + return(ql); + if(pl < p) + while(1) { + qr += 0.05; + if(qr >= 1) { + pr = qr = 1; + break; + } + pr = ibeta(qr, a, b); + if(pr == p) + return(pr); + if(pr > p) + break; + } + else + while(1) { + ql -= 0.05; + if(ql <= 0) { + pl = ql = 0; + break; + } + pl = ibeta(ql, a, b); + if(pl == p) + return(pl); + if(pl < p) + break; + } + + /* a few steps of bisection */ + for(i = 0; i < 5; i++) { + qm = (ql + qr) / 2; + pm = ibeta(qm, a, b); + qdiff = qr - ql; + pdiff = pm - p; + if(fabs(qdiff) < DOUBLE_EPS*qm || fabs(pdiff) < DOUBLE_EPS) + return(qm); + if(pdiff < 0) { + ql = qm; + pl = pm; + } else { + qr = qm; + pr = pm; + } + } + + /* a few steps of secant */ + for(i = 0; i < 40; i++) { + qm = ql + (p-pl)*(qr-ql)/(pr-pl); + pm = ibeta(qm, a, b); + qdiff = qr - ql; + pdiff = pm - p; + if(fabs(qdiff) < 2*DOUBLE_EPS*qm || fabs(pdiff) < 2*DOUBLE_EPS) + return(qm); + if(pdiff < 0) { + ql = qm; + pl = pm; + } else { + qr = qm; + pr = pm; + } + } + + /* no convergence */ + return(qm); +} + +/* + * Quick approximation to inverse incomplete beta function, + * by matching first two moments with the Gaussian distribution. + * Assumption: 0 < p < 1, a,b > 0. + */ + +double +invibeta_quick(double p, double a, double b) +{ + double x, m, s, fmax(), fmin(), invigauss_quick(); + + x = a + b; + m = a / x; + s = sqrt((a*b) / (x*x*(x+1))); + return(fmax(0.0, fmin(1.0, invigauss_quick(p)*s + m))); +} + +int +max(int a, int b) +{ + return(a > b ? a : b); +} + +typedef double doublereal; +typedef int integer; + +void +Recover(char *a, int *b) +{ + printf(a); + exit(1); +} + +void +Warning(char *a, int *b) +{ + printf(a); +} + +/* d1mach may be replaced by Fortran code: + mail netlib at netlib.bell-labs.com + send d1mach from core. +*/ + +#include + +doublereal F77_SUB(d1mach) (integer *i) +{ +switch(*i){ + case 1: return DBL_MIN; + case 2: return DBL_MAX; + case 3: return DBL_EPSILON/FLT_RADIX; + case 4: return DBL_EPSILON; + case 5: return log10(FLT_RADIX); + default: Recover("Invalid argument to d1mach()", 0L); + } +} + Added: trunk/Lib/sandbox/pyloess/sandbox/src/predict.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/predict.c 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/sandbox/src/predict.c 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,172 @@ +#include "S.h" +#include "loess.h" +#include +#include + +void +predict(double *eval, int m, loess *lo, predicted *pre, + int se) +{ + int size_info[3]; + void pred_(); + + pre->fit = (double *) malloc(m * sizeof(double)); + pre->se_fit = (double *) malloc(m * sizeof(double)); + pre->residual_scale = lo->outputs.s; + pre->df = (lo->outputs.one_delta * lo->outputs.one_delta) / +lo->outputs.two_delta; + + size_info[0] = lo->inputs.p; + size_info[1] = lo->inputs.n; + size_info[2] = m; + + pred_(lo->inputs.y, lo->inputs.x, eval, size_info, &lo->outputs.s, + lo->inputs.weights, + lo->outputs.robust, + &lo->model.span, + &lo->model.degree, + &lo->model.normalize, + lo->model.parametric, + lo->model.drop_square, + &lo->control.surface, + &lo->control.cell, + &lo->model.family, + lo->kd_tree.parameter, + lo->kd_tree.a, + lo->kd_tree.xi, + lo->kd_tree.vert, + lo->kd_tree.vval, + lo->outputs.divisor, + &se, + pre->fit, + pre->se_fit); +} + +void +pred_(double *y, double *x_, double *new_x, int *size_info, double *s, + double *weights, double *robust, double *span, int *degree, + int *normalize, int *parametric, int *drop_square, char **surface, + double *cell, char **family, int *parameter, int *a, double *xi, + double *vert, double *vval, double *divisor, int *se, double *fit, + double *se_fit) +{ + double *x, *x_tmp, *x_evaluate, *L, new_cell, z, tmp, *fit_tmp, + *temp, sum, mean; + int N, D, M, sum_drop_sqr = 0, sum_parametric = 0, + nonparametric = 0, *order_parametric, *order_drop_sqr; + int i, j, k, p, cut, comp(); + + D = size_info[0]; + N = size_info[1]; + M = size_info[2]; + + x = (double *) malloc(N * D * sizeof(double)); + x_tmp = (double *) malloc(N * D * sizeof(double)); + x_evaluate = (double *) malloc(M * D * sizeof(double)); + L = (double *) malloc(N * M * sizeof(double)); + order_parametric = (int *) malloc(D * sizeof(int)); + order_drop_sqr = (int *) malloc(D * sizeof(int)); + temp = (double *) malloc(N * D * sizeof(double)); + + for(i = 0; i < (N * D); i++) + x_tmp[i] = x_[i]; + for(i = 0; i < D; i++) { + k = i * M; + for(j = 0; j < M; j++) { + p = k + j; + new_x[p] = new_x[p] / divisor[i]; + } + } + if(!strcmp(*surface, "direct") || se) { + for(i = 0; i < D; i++) { + k = i * N; + for(j = 0; j < N; j++) { + p = k + j; + x_tmp[p] = x_[p] / divisor[i]; + } + } + } + j = D - 1; + for(i = 0; i < D; i++) { + sum_drop_sqr = sum_drop_sqr + drop_square[i]; + sum_parametric = sum_parametric + parametric[i]; + if(parametric[i]) + order_parametric[j--] = i; + else + order_parametric[nonparametric++] = i; + } + for(i = 0; i < D; i++) { + order_drop_sqr[i] = 2 - drop_square[order_parametric[i]]; + k = i * M; + p = order_parametric[i] * M; + for(j = 0; j < M; j++) + x_evaluate[k + j] = new_x[p + j]; + k = i * N; + p = order_parametric[i] * N; + for(j = 0; j < N; j++) + x[k + j] = x_tmp[p + j]; + } + for(i = 0; i < N; i++) + robust[i] = weights[i] * robust[i]; + + if(!strcmp(*surface, "direct")) { + if(*se) { + loess_dfitse(y, x, x_evaluate, weights, robust, + !strcmp(*family, "gaussian"), span, degree, + &nonparametric, order_drop_sqr, &sum_drop_sqr, + &D, &N, &M, fit, L); + } + else { + loess_dfit(y, x, x_evaluate, robust, span, degree, + &nonparametric, order_drop_sqr, &sum_drop_sqr, + &D, &N, &M, fit); + } + } + else { + loess_ifit(parameter, a, xi, vert, vval, &M, x_evaluate, fit); + if(*se) { + new_cell = (*span) * (*cell); + fit_tmp = (double *) malloc(M * sizeof(double)); + loess_ise(y, x, x_evaluate, weights, span, degree, + &nonparametric, order_drop_sqr, &sum_drop_sqr, + &new_cell, &D, &N, &M, fit_tmp, L); + free(fit_tmp); + } + } + if(*se) { + for(i = 0; i < N; i++) { + k = i * M; + for(j = 0; j < M; j++) { + p = k + j; + L[p] = L[p] / weights[i]; + L[p] = L[p] * L[p]; + } + } + for(i = 0; i < M; i++) { + tmp = 0; + for(j = 0; j < N; j++) + tmp = tmp + L[i + j * M]; + se_fit[i] = (*s) * sqrt(tmp); + } + } + free(x); + free(x_tmp); + free(x_evaluate); + free(L); + free(order_parametric); + free(order_drop_sqr); + free(temp); +} + +void +pred_free_mem(predicted *pre) +{ + free(pre->fit); + free(pre->se_fit); +} + + + + + + Added: trunk/Lib/sandbox/pyloess/setup.py =================================================================== --- trunk/Lib/sandbox/pyloess/setup.py 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/setup.py 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,26 @@ +#!/usr/bin/env python +__version__ = '1.0' +__revision__ = "$Revision: 2811 $" +__date__ = '$Date: 2007-03-02 06:30:02 -0500 (Fri, 02 Mar 2007) $' + +import os +from os.path import join + +def configuration(parent_package='',top_path=None): + from numpy.distutils.misc_util import Configuration + confgr = Configuration('pyloess',parent_package,top_path) + confgr.add_extension('_lowess', + sources=[join('src', 'f_lowess.pyf'), + join('src', 'lowess.f'),] + ) + confgr.add_extension('_stl', + sources=[join('src', 'f_stl.pyf'), + join('src', 'stl.f')], + ) + confgr.add_data_dir('tests') + return confgr + +if __name__ == "__main__": + from numpy.distutils.core import setup + config = configuration(top_path='').todict() + setup(**config) \ No newline at end of file Added: trunk/Lib/sandbox/pyloess/src/f_lowess.pyf =================================================================== --- trunk/Lib/sandbox/pyloess/src/f_lowess.pyf 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/src/f_lowess.pyf 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,38 @@ +! -*- f90 -*- +! Note: the context of this file is case sensitive. + +python module _lowess ! in + interface ! in :_lowess + subroutine lowess(x,y,n,f,nsteps,delta,ys,rw,res) ! in :_lowess:lowess.f + double precision dimension(n), intent(in) :: x + double precision dimension(n),depend(n), intent(in) :: y + integer optional,check(len(x)>=n),depend(x) :: n=len(x) + double precision intent(in) :: f + integer intent(in) :: nsteps + double precision intent(in) :: delta + double precision dimension(n),depend(n), intent(out) :: ys + double precision dimension(n),depend(n), intent(out) :: rw + double precision dimension(n),depend(n), intent(out) :: res + end subroutine lowess + subroutine lowest(x,y,n,xs,ys,nleft,nright,w,userw,rw,ok) ! in :_lowess:lowess.f + double precision dimension(n) :: x + double precision dimension(n),depend(n) :: y + integer optional,check(len(x)>=n),depend(x) :: n=len(x) + double precision :: xs + double precision :: ys + integer :: nleft + integer :: nright + double precision dimension(n),depend(n) :: w + logical :: userw + double precision dimension(n),depend(n) :: rw + logical :: ok + end subroutine lowest + subroutine ssort(a,n) ! in :_lowess:lowess.f + real dimension(n) :: a + integer optional,check(len(a)>=n),depend(a) :: n=len(a) + end subroutine ssort + end interface +end python module _lowess + +! This file was auto-generated with f2py (version:2_3522). +! See http://cens.ioc.ee/projects/f2py2e/ Added: trunk/Lib/sandbox/pyloess/src/f_stl.pyf =================================================================== --- trunk/Lib/sandbox/pyloess/src/f_stl.pyf 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/src/f_stl.pyf 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,129 @@ +! -*- f90 -*- +! Note: the context of this file is case sensitive. + +python module _stl ! in + interface ! in :_stl + subroutine stl(y,n,np,ns,nt,nl,isdeg,itdeg,ildeg,nsjump,ntjump,nljump,ni,no,rw,season,trend,work) ! in :_stl:stl.f + double precision dimension(n), intent(in) :: y + integer optional,check(len(y)>=n),depend(y) :: n=len(y) + integer :: np + integer :: ns + integer :: nt + integer :: nl + integer :: isdeg + integer :: itdeg + integer :: ildeg + integer :: nsjump + integer :: ntjump + integer :: nljump + integer :: ni + integer :: no + double precision dimension(n),depend(n), intent(out) :: rw + double precision dimension(n),depend(n), intent(out) :: season + double precision dimension(n),depend(n), intent(out) :: trend + double precision dimension(n+2*np,5),depend(n,np), intent(out) :: work + end subroutine stl + subroutine ess(y,n,len_bn,ideg,njump,userw,rw,ys,res) ! in :_stl:stl.f + double precision dimension(n) :: y + integer optional,check(len(y)>=n),depend(y) :: n=len(y) + integer :: len_bn + integer :: ideg + integer :: njump + logical :: userw + double precision dimension(n),depend(n) :: rw + double precision dimension(n),depend(n) :: ys + double precision dimension(n),depend(n) :: res + end subroutine ess + subroutine est(y,n,len_bn,ideg,xs,ys,nleft,nright,w,userw,rw,ok) ! in :_stl:stl.f + double precision dimension(n) :: y + integer optional,check(len(y)>=n),depend(y) :: n=len(y) + integer :: len_bn + integer :: ideg + double precision :: xs + double precision :: ys + integer :: nleft + integer :: nright + double precision dimension(n),depend(n) :: w + logical :: userw + double precision dimension(n),depend(n) :: rw + logical :: ok + end subroutine est + subroutine fts(x,n,np,trend,work) ! in :_stl:stl.f + double precision dimension(n) :: x + integer optional,check(len(x)>=n),depend(x) :: n=len(x) + integer :: np + double precision dimension(n),depend(n) :: trend + double precision dimension(n),depend(n) :: work + end subroutine fts + subroutine ma(x,n,len_bn,ave) ! in :_stl:stl.f + double precision dimension(n) :: x + integer optional,check(len(x)>=n),depend(x) :: n=len(x) + integer :: len_bn + double precision dimension(n),depend(n) :: ave + end subroutine ma + subroutine onestp(y,n,np,ns,nt,nl,isdeg,itdeg,ildeg,nsjump,ntjump,nljump,ni,userw,rw,season,trend,work) ! in :_stl:stl.f + double precision dimension(n), intent(in) :: y + integer optional,check(len(y)>=n),depend(y) :: n=len(y) + integer intent(in) :: np + integer intent(in) :: ns + integer intent(in) :: nt + integer intent(in) :: nl + integer intent(in) :: isdeg + integer intent(in) :: itdeg + integer intent(in) :: ildeg + integer intent(in) :: nsjump + integer intent(in) :: ntjump + integer intent(in) :: nljump + integer intent(in) :: ni + logical intent(in) :: userw + double precision dimension(n),depend(n), intent(out) :: rw + double precision dimension(n),depend(n), intent(out) :: season + double precision dimension(n),depend(n), intent(out) :: trend + double precision dimension(n+2*np,5),depend(n,np), intent(out) :: work + end subroutine onestp + subroutine rwts(y,n,fit,rw) ! in :_stl:stl.f + double precision dimension(n) :: y + integer optional,check(len(y)>=n),depend(y) :: n=len(y) + double precision dimension(n),depend(n) :: fit + double precision dimension(n),depend(n) :: rw + end subroutine rwts + subroutine ss(y,n,np,ns,isdeg,nsjump,userw,rw,season,work1,work2,work3,work4) ! in :_stl:stl.f + double precision dimension(n) :: y + integer optional,check(len(y)>=n),depend(y) :: n=len(y) + integer :: np + integer :: ns + integer :: isdeg + integer :: nsjump + logical :: userw + double precision dimension(n),depend(n) :: rw + double precision dimension(n+2*np),depend(n,np) :: season + double precision dimension(n),depend(n) :: work1 + double precision dimension(n),depend(n) :: work2 + double precision dimension(n),depend(n) :: work3 + double precision dimension(n),depend(n) :: work4 + end subroutine ss + subroutine stlez(y,n,np,ns,isdeg,itdeg,robust,no,rw,season,trend,work) ! in :_stl:stl.f + double precision dimension(n) :: y + integer optional,check(len(y)>=n),depend(y) :: n=len(y) + integer :: np + integer :: ns + integer :: isdeg + integer :: itdeg + logical :: robust + integer :: no + double precision dimension(n),depend(n) :: rw + double precision dimension(n),depend(n) :: season + double precision dimension(n),depend(n) :: trend + double precision dimension(n+2*np,7),depend(n,np) :: work + end subroutine stlez + subroutine psort(a,n,ind,ni) ! in :_stl:stl.f + double precision dimension(n) :: a + integer optional,check(len(a)>=n),depend(a) :: n=len(a) + integer dimension(ni) :: ind + integer optional,check(len(ind)>=ni),depend(ind) :: ni=len(ind) + end subroutine psort + end interface +end python module _stl + +! This file was auto-generated with f2py (version:2_3522). +! See http://cens.ioc.ee/projects/f2py2e/ Added: trunk/Lib/sandbox/pyloess/src/lowess.f =================================================================== --- trunk/Lib/sandbox/pyloess/src/lowess.f 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/src/lowess.f 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,615 @@ +* wsc at research.bell-labs.com Mon Dec 30 16:55 EST 1985 +* W. S. Cleveland +* Bell Laboratories +* Murray Hill NJ 07974 +* +* outline of this file: +* lines 1-72 introduction +* 73-177 documentation for lowess +* 178-238 ratfor version of lowess +* 239-301 documentation for lowest +* 302-350 ratfor version of lowest +* 351-end test driver and fortran version of lowess and lowest +* +* a multivariate version is available by "send dloess from a" +* +* COMPUTER PROGRAMS FOR LOCALLY WEIGHTED REGRESSION +* +* This package consists of two FORTRAN programs for +* smoothing scatterplots by robust locally weighted +* regression, or lowess. The principal routine is LOWESS +* which computes the smoothed values using the method +* described in The Elements of Graphing Data, by William S. +* Cleveland (Wadsworth, 555 Morego Street, Monterey, +* California 93940). +* +* LOWESS calls a support routine, LOWEST, the code for +* which is included. LOWESS also calls a routine SORT, which +* the user must provide. +* +* To reduce the computations, LOWESS requires that the +* arrays X and Y, which are the horizontal and vertical +* coordinates, respectively, of the scatterplot, be such that +* X is sorted from smallest to largest. The user must +* therefore use another sort routine which will sort X and Y +* according to X. +* To summarize the scatterplot, YS, the fitted values, +* should be plotted against X. No graphics routines are +* available in the package and must be supplied by the user. +* +* The FORTRAN code for the routines LOWESS and LOWEST has +* been generated from higher level RATFOR programs +* (B. W. Kernighan, ``RATFOR: A Preprocessor for a Rational +* Fortran,'' Software Practice and Experience, Vol. 5 (1975), +* which are also included. +* +* The following are data and output from LOWESS that can +* be used to check your implementation of the routines. The +* notation (10)v means 10 values of v. +* +* +* +* +* X values: +* 1 2 3 4 5 (10)6 8 10 12 14 50 +* +* Y values: +* 18 2 15 6 10 4 16 11 7 3 14 17 20 12 9 13 1 8 5 19 +* +* +* YS values with F = .25, NSTEPS = 0, DELTA = 0.0 +* 13.659 11.145 8.701 9.722 10.000 (10)11.300 13.000 6.440 5.596 +* 5.456 18.998 +* +* YS values with F = .25, NSTEPS = 0 , DELTA = 3.0 +* 13.659 12.347 11.034 9.722 10.511 (10)11.300 13.000 6.440 5.596 +* 5.456 18.998 +* +* YS values with F = .25, NSTEPS = 2, DELTA = 0.0 +* 14.811 12.115 8.984 9.676 10.000 (10)11.346 13.000 6.734 5.744 +* 5.415 18.998 +* +* +* +* +* LOWESS +* +* +* +* Calling sequence +* +* CALL LOWESS(X,Y,N,F,NSTEPS,DELTA,YS,RW,RES) +* +* Purpose +* +* LOWESS computes the smooth of a scatterplot of Y against X +* using robust locally weighted regression. Fitted values, +* YS, are computed at each of the values of the horizontal +* axis in X. +* +* Argument description +* +* X = Input; abscissas of the points on the +* scatterplot; the values in X must be ordered +* from smallest to largest. +* Y = Input; ordinates of the points on the +* scatterplot. +* N = Input; dimension of X,Y,YS,RW, and RES. +* F = Input; specifies the amount of smoothing; F is +* the fraction of points used to compute each +* fitted value; as F increases the smoothed values +* become smoother; choosing F in the range .2 to +* .8 usually results in a good fit; if you have no +* idea which value to use, try F = .5. +* NSTEPS = Input; the number of iterations in the robust +* fit; if NSTEPS = 0, the nonrobust fit is +* returned; setting NSTEPS equal to 2 should serve +* most purposes. +* DELTA = input; nonnegative parameter which may be used +* to save computations; if N is less than 100, set +* DELTA equal to 0.0; if N is greater than 100 you +* should find out how DELTA works by reading the +* additional instructions section. +* YS = Output; fitted values; YS(I) is the fitted value +* at X(I); to summarize the scatterplot, YS(I) +* should be plotted against X(I). +* RW = Output; robustness weights; RW(I) is the weight +* given to the point (X(I),Y(I)); if NSTEPS = 0, +* RW is not used. +* RES = Output; residuals; RES(I) = Y(I)-YS(I). +* +* +* Other programs called +* +* LOWEST +* SSORT +* +* Additional instructions +* +* DELTA can be used to save computations. Very roughly the +* algorithm is this: on the initial fit and on each of the +* NSTEPS iterations locally weighted regression fitted values +* are computed at points in X which are spaced, roughly, DELTA +* apart; then the fitted values at the remaining points are +* computed using linear interpolation. The first locally +* weighted regression (l.w.r.) computation is carried out at +* X(1) and the last is carried out at X(N). Suppose the +* l.w.r. computation is carried out at X(I). If X(I+1) is +* greater than or equal to X(I)+DELTA, the next l.w.r. +* computation is carried out at X(I+1). If X(I+1) is less +* than X(I)+DELTA, the next l.w.r. computation is carried out +* at the largest X(J) which is greater than or equal to X(I) +* but is not greater than X(I)+DELTA. Then the fitted values +* for X(K) between X(I) and X(J), if there are any, are +* computed by linear interpolation of the fitted values at +* X(I) and X(J). If N is less than 100 then DELTA can be set +* to 0.0 since the computation time will not be too great. +* For larger N it is typically not necessary to carry out the +* l.w.r. computation for all points, so that much computation +* time can be saved by taking DELTA to be greater than 0.0. +* If DELTA = Range (X)/k then, if the values in X were +* uniformly scattered over the range, the full l.w.r. +* computation would be carried out at approximately k points. +* Taking k to be 50 often works well. +* +* Method +* +* The fitted values are computed by using the nearest neighbor +* routine and robust locally weighted regression of degree 1 +* with the tricube weight function. A few additional features +* have been added. Suppose r is FN truncated to an integer. +* Let h be the distance to the r-th nearest neighbor +* from X(I). All points within h of X(I) are used. Thus if +* the r-th nearest neighbor is exactly the same distance as +* other points, more than r points can possibly be used for +* the smooth at X(I). There are two cases where robust +* locally weighted regression of degree 0 is actually used at +* X(I). One case occurs when h is 0.0. The second case +* occurs when the weighted standard error of the X(I) with +* respect to the weights w(j) is less than .001 times the +* range of the X(I), where w(j) is the weight assigned to the +* j-th point of X (the tricube weight times the robustness +* weight) divided by the sum of all of the weights. Finally, +* if the w(j) are all zero for the smooth at X(I), the fitted +* value is taken to be Y(I). +* +* +* +* +* subroutine lowess(x,y,n,f,nsteps,delta,ys,rw,res) +* real x(n),y(n),ys(n),rw(n),res(n) +* logical ok +* if (n<2){ ys(1) = y(1); return } +* ns = max0(min0(ifix(f*float(n)),n),2) # at least two, at most n points +* for(iter=1; iter<=nsteps+1; iter=iter+1){ # robustness iterations +* nleft = 1; nright = ns +* last = 0 # index of prev estimated point +* i = 1 # index of current point +* repeat{ +* while(nright1,rw,ok) +* # fitted value at x(i) +* if (!ok) ys(i) = y(i) +* # all weights zero - copy over value (all rw==0) +* if (lastcut) break # i one beyond last pt within cut +* if(x(i)==x(last)){ # exact match in x +* ys(i) = ys(last) +* last = i +* } +* } +* i=max0(last+1,i-1) +* # back 1 point so interpolation within delta, but always go forward +* } until(last>=n) +* do i = 1,n # residuals +* res(i) = y(i)-ys(i) +* if (iter>nsteps) break # compute robustness weights except last time +* do i = 1,n +* rw(i) = abs(res(i)) +* call sort(rw,n) +* m1 = 1+n/2; m2 = n-m1+1 +* cmad = 3.0*(rw(m1)+rw(m2)) # 6 median abs resid +* c9 = .999*cmad; c1 = .001*cmad +* do i = 1,n { +* r = abs(res(i)) +* if(r<=c1) rw(i)=1. # near 0, avoid underflow +* else if(r>c9) rw(i)=0. # near 1, avoid underflow +* else rw(i) = (1.0-(r/cmad)**2)**2 +* } +* } +* return +* end +* +* +* +* +* LOWEST +* +* +* +* Calling sequence +* +* CALL LOWEST(X,Y,N,XS,YS,NLEFT,NRIGHT,W,USERW,RW,OK) +* +* Purpose +* +* LOWEST is a support routine for LOWESS and ordinarily will +* not be called by the user. The fitted value, YS, is +* computed at the value, XS, of the horizontal axis. +* Robustness weights, RW, can be employed in computing the +* fit. +* +* Argument description +* +* +* X = Input; abscissas of the points on the +* scatterplot; the values in X must be ordered +* from smallest to largest. +* Y = Input; ordinates of the points on the +* scatterplot. +* N = Input; dimension of X,Y,W, and RW. +* XS = Input; value of the horizontal axis at which the +* smooth is computed. +* YS = Output; fitted value at XS. +* NLEFT = Input; index of the first point which should be +* considered in computing the fitted value. +* NRIGHT = Input; index of the last point which should be +* considered in computing the fitted value. +* W = Output; W(I) is the weight for Y(I) used in the +* expression for YS, which is the sum from +* I = NLEFT to NRIGHT of W(I)*Y(I); W(I) is +* defined only at locations NLEFT to NRIGHT. +* USERW = Input; logical variable; if USERW is .TRUE., a +* robust fit is carried out using the weights in +* RW; if USERW is .FALSE., the values in RW are +* not used. +* RW = Input; robustness weights. +* OK = Output; logical variable; if the weights for the +* smooth are all 0.0, the fitted value, YS, is not +* computed and OK is set equal to .FALSE.; if the +* fitted value is computed OK is set equal to +* +* +* Method +* +* The smooth at XS is computed using (robust) locally weighted +* regression of degree 1. The tricube weight function is used +* with h equal to the maximum of XS-X(NLEFT) and X(NRIGHT)-XS. +* Two cases where the program reverts to locally weighted +* regression of degree 0 are described in the documentation +* for LOWESS. +* +* +* +* +* subroutine lowest(x,y,n,xs,ys,nleft,nright,w,userw,rw,ok) +* real x(n),y(n),w(n),rw(n) +* logical userw,ok +* range = x(n)-x(1) +* h = amax1(xs-x(nleft),x(nright)-xs) +* h9 = .999*h +* h1 = .001*h +* a = 0.0 # sum of weights +* for(j=nleft; j<=n; j=j+1){ # compute weights (pick up all ties on right) +* w(j)=0. +* r = abs(x(j)-xs) +* if (r<=h9) { # small enough for non-zero weight +* if (r>h1) w(j) = (1.0-(r/h)**3)**3 +* else w(j) = 1. +* if (userw) w(j) = rw(j)*w(j) +* a = a+w(j) +* } +* else if(x(j)>xs)break # get out at first zero wt on right +* } +* nrt=j-1 # rightmost pt (may be greater than nright because of ties) +* if (a<=0.0) ok = FALSE +* else { # weighted least squares +* ok = TRUE +* do j = nleft,nrt +* w(j) = w(j)/a # make sum of w(j) == 1 +* if (h>0.) { # use linear fit +* a = 0.0 +* do j = nleft,nrt +* a = a+w(j)*x(j) # weighted center of x values +* b = xs-a +* c = 0.0 +* do j = nleft,nrt +* c = c+w(j)*(x(j)-a)**2 +* if(sqrt(c)>.001*range) { +* # points are spread out enough to compute slope +* b = b/c +* do j = nleft,nrt +* w(j) = w(j)*(1.0+b*(x(j)-a)) +* } +* } +* ys = 0.0 +* do j = nleft,nrt +* ys = ys+w(j)*y(j) +* } +* return +* end +* +* +* +c test driver for lowess +c for expected output, see introduction + double precision x(20), y(20), ys(20), rw(20), res(20) + data x /1,2,3,4,5,10*6,8,10,12,14,50/ + data y /18,2,15,6,10,4,16,11,7,3,14,17,20,12,9,13,1,8,5,19/ + call lowess(x,y,20,.25,0,0.,ys,rw,res) + write(6,*) ys + call lowess(x,y,20,.25,0,3.,ys,rw,res) + write(6,*) ys + call lowess(x,y,20,.25,2,0.,ys,rw,res) + write(6,*) ys + end +c************************************************************** +c Fortran output from ratfor +c + subroutine lowess(x, y, n, f, nsteps, delta, ys, rw, res) + integer n, nsteps + double precision x(n), y(n), f, delta, ys(n), rw(n), res(n) + integer nright, i, j, iter, last, mid(2), ns, nleft + double precision cut, cmad, r, d1, d2 + double precision c1, c9, alpha, denom, dabs + logical ok + if (n .ge. 2) goto 1 + ys(1) = y(1) + return +c at least two, at most n points + 1 ns = max(min(int(f*dble(n)), n), 2) + iter = 1 + goto 3 + 2 iter = iter+1 + 3 if (iter .gt. nsteps+1) goto 22 +c robustness iterations + nleft = 1 + nright = ns +c index of prev estimated point + last = 0 +c index of current point + i = 1 + 4 if (nright .ge. n) goto 5 +c move nleft, nright to right if radius decreases + d1 = x(i)-x(nleft) +c if d1<=d2 with x(nright+1)==x(nright), lowest fixes + d2 = x(nright+1)-x(i) + if (d1 .le. d2) goto 5 +c radius will not decrease by move right + nleft = nleft+1 + nright = nright+1 + goto 4 +c fitted value at x(i) + 5 call lowest(x, y, n, x(i), ys(i), nleft, nright, res, iter + + .gt. 1, rw, ok) + if (.not. ok) ys(i) = y(i) +c all weights zero - copy over value (all rw==0) + if (last .ge. i-1) goto 9 + denom = x(i)-x(last) +c skipped points -- interpolate +c non-zero - proof? + j = last+1 + goto 7 + 6 j = j+1 + 7 if (j .ge. i) goto 8 + alpha = (x(j)-x(last))/denom + ys(j) = alpha*ys(i)+(1.D0-alpha)*ys(last) + goto 6 + 8 continue +c last point actually estimated + 9 last = i +c x coord of close points + cut = x(last)+delta + i = last+1 + goto 11 + 10 i = i+1 + 11 if (i .gt. n) goto 13 +c find close points + if (x(i) .gt. cut) goto 13 +c i one beyond last pt within cut + if (x(i) .ne. x(last)) goto 12 + ys(i) = ys(last) +c exact match in x + last = i + 12 continue + goto 10 +c back 1 point so interpolation within delta, but always go forward + 13 i = max(last+1, i-1) + 14 if (last .lt. n) goto 4 +c residuals + do 15 i = 1, n + res(i) = y(i)-ys(i) + 15 continue + if (iter .gt. nsteps) goto 22 +c compute robustness weights except last time + do 16 i = 1, n + rw(i) = dabs(res(i)) + 16 continue + call ssort(rw,n) + mid(1) = n/2+1 + mid(2) = n-mid(1)+1 +c 6 median abs resid + cmad = 3.D0*(rw(mid(1))+rw(mid(2))) + c9 = .999999D0*cmad + c1 = .000001D0*cmad + do 21 i = 1, n + r = dabs(res(i)) + if (r .gt. c1) goto 17 + rw(i) = 1.D0 +c near 0, avoid underflow + goto 20 + 17 if (r .le. c9) goto 18 + rw(i) = 0.D0 +c near 1, avoid underflow + goto 19 + 18 rw(i) = (1.D0-(r/cmad)**2.D0)**2.D0 + 19 continue + 20 continue + 21 continue + goto 2 + 22 return + end + + + subroutine lowest(x, y, n, xs, ys, nleft, nright, w, userw + +, rw, ok) + integer n + integer nleft, nright + double precision x(n), y(n), xs, ys, w(n), rw(n) + logical userw, ok + integer nrt, j + double precision dabs, a, b, c, h, r + double precision h1, dsqrt, h9, max, range + range = x(n)-x(1) + h = max(xs-x(nleft), x(nright)-xs) + h9 = .999999D0*h + h1 = .000001D0*h +c sum of weights + a = 0.D0 + j = nleft + goto 2 + 1 j = j+1 + 2 if (j .gt. n) goto 7 +c compute weights (pick up all ties on right) + w(j) = 0.D0 + r = dabs(x(j)-xs) + if (r .gt. h9) goto 5 + if (r .le. h1) goto 3 + w(j) = (1.D0-(r/h)**3.D0)**3.D0 +c small enough for non-zero weight + goto 4 + 3 w(j) = 1.D0 + 4 if (userw) w(j) = rw(j)*w(j) + a = a+w(j) + goto 6 + 5 if (x(j) .gt. xs) goto 7 +c get out at first zero wt on right + 6 continue + goto 1 +c rightmost pt (may be greater than nright because of ties) + 7 nrt = j-1 + if (a .gt. 0.D0) goto 8 + ok = .false. + goto 16 + 8 ok = .true. +c weighted least squares + do 9 j = nleft, nrt +c make sum of w(j) == 1 + w(j) = w(j)/a + 9 continue + if (h .le. 0.D0) goto 14 + a = 0.D0 +c use linear fit + do 10 j = nleft, nrt +c weighted center of x values + a = a+w(j)*x(j) + 10 continue + b = xs-a + c = 0.D0 + do 11 j = nleft, nrt + c = c+w(j)*(x(j)-a)**2 + 11 continue + if (dsqrt(c) .le. .0000001D0*range) goto 13 + b = b/c +c points are spread out enough to compute slope + do 12 j = nleft, nrt + w(j) = w(j)*(b*(x(j)-a)+1.D0) + 12 continue + 13 continue + 14 ys = 0.D0 + do 15 j = nleft, nrt + ys = ys+w(j)*y(j) + 15 continue + 16 return + end + + + subroutine ssort(a,n) + +C Sorting by Hoare method, C.A.C.M. (1961) 321, modified by Singleton +C C.A.C.M. (1969) 185. + double precision a(n) + integer iu(16), il(16) + integer p + + i =1 + j = n + m = 1 + 5 if (i.ge.j) goto 70 +c first order a(i),a(j),a((i+j)/2), and use median to split the data + 10 k=i + ij=(i+j)/2 + t=a(ij) + if(a(i) .le. t) goto 20 + a(ij)=a(i) + a(i)=t + t=a(ij) + 20 l=j + if(a(j).ge.t) goto 40 + a(ij)=a(j) + a(j)=t + t=a(ij) + if(a(i).le.t) goto 40 + a(ij)=a(i) + a(i)=t + t=a(ij) + goto 40 + 30 a(l)=a(k) + a(k)=tt + 40 l=l-1 + if(a(l) .gt. t) goto 40 + tt=a(l) +c split the data into a(i to l) .lt. t, a(k to j) .gt. t + 50 k=k+1 + if(a(k) .lt. t) goto 50 + if(k .le. l) goto 30 + p=m + m=m+1 +c split the larger of the segments + if (l-i .le. j-k) goto 60 + il(p)=i + iu(p)=l + i=k + goto 80 + 60 il(p)=k + iu(p)=j + j=l + goto 80 + 70 m=m-1 + if(m .eq. 0) return + i =il(m) + j=iu(m) +c short sections are sorted by bubble sort + 80 if (j-i .gt. 10) goto 10 + if (i .eq. 1) goto 5 + i=i-1 + 90 i=i+1 + if(i .eq. j) goto 70 + t=a(i+1) + if(a(i) .le. t) goto 90 + k=i + 100 a(k+1)=a(k) + k=k-1 + if(t .lt. a(k)) goto 100 + a(k+1)=t + goto 90 + + end \ No newline at end of file Added: trunk/Lib/sandbox/pyloess/src/stl.f =================================================================== --- trunk/Lib/sandbox/pyloess/src/stl.f 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/src/stl.f 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,554 @@ + subroutine stl(y,n,np,ns,nt,nl,isdeg,itdeg,ildeg,nsjump,ntjump, + &nljump,ni,no,rw,season,trend,work) + integer n, np, ns, nt, nl, isdeg, itdeg, ildeg, nsjump, ntjump, + &nljump, ni, no, k + integer newns, newnt, newnl, newnp + double precision y(n), rw(n), season(n), trend(n), work(n+2*np,5) + logical userw + userw = .false. + k = 0 + do 23000 i = 1,n + trend(i) = 0.D0 +23000 continue + newns = max(3,ns) + newnt = max(3,nt) + newnl = max(3,nl) + newnp = max(2,np) + if(.not.(mod(newns,2) .eq. 0))goto 23002 + newns = newns + 1 +23002 continue + if(.not.(mod(newnt,2) .eq. 0))goto 23004 + newnt = newnt + 1 +23004 continue + if(.not.(mod(newnl,2) .eq. 0))goto 23006 + newnl = newnl + 1 +23006 continue +23008 continue + call onestp(y,n,newnp,newns,newnt,newnl,isdeg,itdeg,ildeg,nsjump, + &ntjump,nljump,ni,userw,rw,season, trend, work) + k = k+1 + if(.not.(k .gt. no))goto 23011 + goto 23010 +23011 continue + do 23013 i = 1,n + work(i,1) = trend(i)+season(i) +23013 continue + call rwts(y,n,work(1,1),rw) + userw = .true. +23009 goto 23008 +23010 continue + if(.not.(no .le. 0))goto 23015 + do 23017 i = 1,n + rw(i) = 1.D0 +23017 continue +23015 continue + return + end + + + subroutine ess(y,n,len,ideg,njump,userw,rw,ys,res) + integer n, len, ideg, njump, newnj, nleft, nright, nsh, k, i, j + double precision y(n), rw(n), ys(n), res(n), delta + logical ok, userw + if(.not.(n .lt. 2))goto 23019 + ys(1) = y(1) + return +23019 continue + newnj = min(njump, n-1) + if(.not.(len .ge. n))goto 23021 + nleft = 1 + nright = n + do 23023 i = 1,n,newnj + call est(y,n,len,ideg,dble(i),ys(i),nleft,nright,res,userw,rw,ok) + if(.not.( .not. ok))goto 23025 + ys(i) = y(i) +23025 continue +23023 continue + goto 23022 +23021 continue + if(.not.(newnj .eq. 1))goto 23027 + nsh = (len+1)/2 + nleft = 1 + nright = len + do 23029 i = 1,n + if(.not.(i .gt. nsh .and. nright .ne. n))goto 23031 + nleft = nleft+1 + nright = nright+1 +23031 continue + call est(y,n,len,ideg,dble(i),ys(i),nleft,nright,res,userw,rw,ok) + if(.not.( .not. ok))goto 23033 + ys(i) = y(i) +23033 continue +23029 continue + goto 23028 +23027 continue + nsh = (len+1)/2 + do 23035 i = 1,n,newnj + if(.not.(i .lt. nsh))goto 23037 + nleft = 1 + nright = len + goto 23038 +23037 continue + if(.not.(i .ge. n-nsh+1))goto 23039 + nleft = n-len+1 + nright = n + goto 23040 +23039 continue + nleft = i-nsh+1 + nright = len+i-nsh +23040 continue +23038 continue + call est(y,n,len,ideg,dble(i),ys(i),nleft,nright,res,userw,rw,ok) + if(.not.( .not. ok))goto 23041 + ys(i) = y(i) +23041 continue +23035 continue +23028 continue +23022 continue + if(.not.(newnj .ne. 1))goto 23043 + do 23045 i = 1,n-newnj,newnj + delta = (ys(i+newnj)-ys(i))/dble(newnj) + do 23047 j = i+1,i+newnj-1 + ys(j) = ys(i)+delta*dble(j-i) +23047 continue +23045 continue + k = ((n-1)/newnj)*newnj+1 + if(.not.(k .ne. n))goto 23049 + call est(y,n,len,ideg,dble(n),ys(n),nleft,nright,res,userw,rw,ok) + if(.not.( .not. ok))goto 23051 + ys(n) = y(n) +23051 continue + if(.not.(k .ne. n-1))goto 23053 + delta = (ys(n)-ys(k))/dble(n-k) + do 23055 j = k+1,n-1 + ys(j) = ys(k)+delta*dble(j-k) +23055 continue +23053 continue +23049 continue +23043 continue + return + end + + + subroutine est(y,n,len,ideg,xs,ys,nleft,nright,w,userw,rw,ok) + integer n, len, ideg, nleft, nright, j + double precision y(n), w(n), rw(n), xs, ys, range, h, h1, h9, a, + &b, c, r + logical userw,ok + range = dble(n)-dble(1) + h = max(xs-dble(nleft),dble(nright)-xs) + if(.not.(len .gt. n))goto 23057 + h = h+dble((len-n)/2) +23057 continue + h9 = .999999D0*h + h1 = .000001D0*h + a = 0.D0 + do 23059 j = nleft,nright + w(j) = 0.D0 + r = dabs(dble(j)-xs) + if(.not.(r .le. h9))goto 23061 + if(.not.(r .le. h1))goto 23063 + w(j) = 1.D0 + goto 23064 +23063 continue + w(j) = (1.D0-(r/h)**3.D0)**3.D0 +23064 continue + if(.not.(userw))goto 23065 + w(j) = rw(j)*w(j) +23065 continue + a = a+w(j) +23061 continue +23059 continue + if(.not.(a .le. 0.D0))goto 23067 + ok = .false. + goto 23068 +23067 continue + ok = .true. + do 23069 j = nleft,nright + w(j) = w(j)/a +23069 continue + if(.not.((h .gt. 0.D0) .and. (ideg .gt. 0)))goto 23071 + a = 0.D0 + do 23073 j = nleft,nright + a = a+w(j)*dble(j) +23073 continue + b = xs-a + c = 0.D0 + do 23075 j = nleft,nright + c = c+w(j)*(dble(j)-a)**2.D0 +23075 continue + if(.not.(sqrt(c) .gt. .001*range))goto 23077 + b = b/c + do 23079 j = nleft,nright + w(j) = w(j)*(b*(dble(j)-a)+1.D0) +23079 continue +23077 continue +23071 continue + ys = 0.D0 + do 23081 j = nleft,nright + ys = ys+w(j)*y(j) +23081 continue +23068 continue + return + end + + + subroutine fts(x,n,np,trend,work) + integer n, np + double precision x(n), trend(n), work(n) + call ma(x,n,np,trend) + call ma(trend,n-np+1,np,work) + call ma(work,n-2*np+2,3,trend) + return + end + + + subroutine ma(x, n, len, ave) + integer n, len, i, j, k, m, newn + double precision x(n), ave(n), flen, v + newn = n-len+1 + flen = dble(len) + v = 0.D0 + do 23083 i = 1,len + v = v+x(i) +23083 continue + ave(1) = v/flen + if(.not.(newn .gt. 1))goto 23085 + k = len + m = 0 + do 23087 j = 2, newn + k = k+1 + m = m+1 + v = v-x(m)+x(k) + ave(j) = v/flen +23087 continue +23085 continue + return + end + + + subroutine onestp(y,n,np,ns,nt,nl,isdeg,itdeg,ildeg,nsjump,ntjump, + &nljump,ni,userw,rw,season,trend,work) + integer n,ni,np,ns,nt,nsjump,ntjump,nl,nljump,isdeg,itdeg,ildeg + double precision y(n),rw(n),season(n),trend(n),work(n+2*np,5) + logical userw + do 23089 j = 1,ni + do 23091 i = 1,n + work(i,1) = y(i)-trend(i) +23091 continue + call ss(work(1,1),n,np,ns,isdeg,nsjump,userw,rw,work(1,2),work(1, + &3),work(1,4),work(1,5),season) + call fts(work(1,2),n+2*np,np,work(1,3),work(1,1)) + call ess(work(1,3),n,nl,ildeg,nljump,.false.,work(1,4),work(1,1), + &work(1,5)) + do 23093 i = 1,n + season(i) = work(np+i,2)-work(i,1) +23093 continue + do 23095 i = 1,n + work(i,1) = y(i)-season(i) +23095 continue + call ess(work(1,1),n,nt,itdeg,ntjump,userw,rw,trend,work(1,3)) +23089 continue + return + end + + + subroutine rwts(y,n,fit,rw) + integer mid(2), n + double precision y(n), fit(n), rw(n), cmad, c9, c1, r + do 23097 i = 1,n + rw(i) = dabs(y(i)-fit(i)) +23097 continue + mid(1) = n/2+1 + mid(2) = n-mid(1)+1 + call psort(rw,n,mid,2) + cmad = 3.D0*(rw(mid(1))+rw(mid(2))) + c9 = .999999D0*cmad + c1 = .000001D0*cmad + do 23099 i = 1,n + r = dabs(y(i)-fit(i)) + if(.not.(r .le. c1))goto 23101 + rw(i) = 1. + goto 23102 +23101 continue + if(.not.(r .le. c9))goto 23103 + rw(i) = (1.D0-(r/cmad)**2.D0)**2.D0 + goto 23104 +23103 continue + rw(i) = 0.D0 +23104 continue +23102 continue +23099 continue + return + end + + + subroutine ss(y,n,np,ns,isdeg,nsjump,userw,rw,season,work1,work2, + &work3,work4) + integer n, np, ns, isdeg, nsjump, nright, nleft, i, j, k + double precision y(n), rw(n), season(n+2*np), work1(n), work2(n), + &work3(n), work4(n), xs + logical userw,ok + j=1 +23105 if(.not.(j .le. np))goto 23107 + k = (n-j)/np+1 + do 23108 i = 1,k + work1(i) = y((i-1)*np+j) +23108 continue + if(.not.(userw))goto 23110 + do 23112 i = 1,k + work3(i) = rw((i-1)*np+j) +23112 continue +23110 continue + call ess(work1,k,ns,isdeg,nsjump,userw,work3,work2(2),work4) + xs = 0.D0 + nright = min0(ns,k) + call est(work1,k,ns,isdeg,xs,work2(1),1,nright,work4,userw,work3, + &ok) + if(.not.( .not. ok))goto 23114 + work2(1) = work2(2) +23114 continue + xs = dble(k+1) + nleft = max0(1,k-ns+1) + call est(work1,k,ns,isdeg,xs,work2(k+2),nleft,k,work4,userw,work3, + &ok) + if(.not.( .not. ok))goto 23116 + work2(k+2) = work2(k+1) +23116 continue + do 23118 m = 1,k+2 + season((m-1)*np+j) = work2(m) +23118 continue + j=j+1 + goto 23105 +23107 continue + return + end + + + subroutine stlez(y, n, np, ns, isdeg, itdeg, robust, no, rw, + &season, trend, work) + logical robust + integer n, i, j, np, ns, no, nt, nl, ni, nsjump, ntjump, nljump, + &newns, newnp + integer isdeg, itdeg, ildeg + double precision y(n), rw(n), season(n), trend(n), work(n+2*np,7) + double precision maxs, mins, maxt, mint, maxds, maxdt, difs, dift + ildeg = itdeg + newns = max(3,ns) + if(.not.(mod(newns,2) .eq. 0))goto 23120 + newns = newns+1 +23120 continue + newnp = max(2,np) + nt = (1.5*newnp)/(1 - 1.5/newns) + 0.5 + nt = max(3,nt) + if(.not.(mod(nt,2) .eq. 0))goto 23122 + nt = nt+1 +23122 continue + nl = newnp + if(.not.(mod(nl,2) .eq. 0))goto 23124 + nl = nl+1 +23124 continue + if(.not.(robust))goto 23126 + ni = 1 + goto 23127 +23126 continue + ni = 2 +23127 continue + nsjump = max(1,int(dble(newns)/10.D0 + 0.9D0)) + ntjump = max(1,int(dble(nt)/10.D0 + 0.9D0)) + nljump = max(1,int(dble(nl)/10.D0 + 0.9D0)) + do 23128 i = 1,n + trend(i) = 0.D0 +23128 continue + call onestp(y,n,newnp,newns,nt,nl,isdeg,itdeg,ildeg,nsjump,ntjump, + &nljump,ni,.false.,rw,season,trend,work) + no = 0 + if(.not.(robust))goto 23130 + j=1 +23132 if(.not.(j .le. 15))goto 23134 + do 23135 i = 1,n + work(i,6) = season(i) + work(i,7) = trend(i) + work(i,1) = trend(i)+season(i) +23135 continue + call rwts(y,n,work(1,1),rw) + call onestp(y, n, newnp, newns, nt, nl, isdeg, itdeg, ildeg, + &nsjump,ntjump, nljump, ni, .true., rw, season, trend, work) + no = no+1 + maxs = work(1,6) + mins = work(1,6) + maxt = work(1,7) + mint = work(1,7) + maxds = dabs(work(1,6) - season(1)) + maxdt = dabs(work(1,7) - trend(1)) + do 23137 i = 2,n + if(.not.(maxs .lt. work(i,6)))goto 23139 + maxs = work(i,6) +23139 continue + if(.not.(maxt .lt. work(i,7)))goto 23141 + maxt = work(i,7) +23141 continue + if(.not.(mins .gt. work(i,6)))goto 23143 + mins = work(i,6) +23143 continue + if(.not.(mint .gt. work(i,7)))goto 23145 + mint = work(i,7) +23145 continue + difs = dabs(work(i,6) - season(i)) + dift = dabs(work(i,7) - trend(i)) + if(.not.(maxds .lt. difs))goto 23147 + maxds = difs +23147 continue + if(.not.(maxdt .lt. dift))goto 23149 + maxdt = dift +23149 continue +23137 continue + if(.not.((maxds/(maxs-mins) .lt. .01) .and. + & (maxdt/(maxt-mint) .lt. .01)))goto 23151 + goto 23134 +23151 continue + j=j+1 + goto 23132 +23134 continue +23130 continue + if(.not.( .not. robust))goto 23153 + do 23155 i = 1,n + rw(i) = 1.D0 +23155 continue +23153 continue + return + end + + + subroutine psort(a,n,ind,ni) + double precision a(n) + integer n,ind(ni),ni + integer indu(16),indl(16),iu(16),il(16),p,jl,ju,i,j,m,k,ij,l + double precision t,tt + if(.not.(n .lt. 0 .or. ni .lt. 0))goto 23157 + return +23157 continue + if(.not.(n .lt. 2 .or. ni .eq. 0))goto 23159 + return +23159 continue + jl = 1 + ju = ni + indl(1) = 1 + indu(1) = ni + i = 1 + j = n + m = 1 +23161 continue + if(.not.(i .lt. j))goto 23164 + go to 10 +23164 continue +23166 continue + m = m-1 + if(.not.(m .eq. 0))goto 23169 + goto 23163 +23169 continue + i = il(m) + j = iu(m) + jl = indl(m) + ju = indu(m) + if(.not.(jl .le. ju))goto 23171 +23173 if(.not.(j-i .gt. 10))goto 23174 +10 k = i + ij = (i+j)/2 + t = a(ij) + if(.not.(a(i) .gt. t))goto 23175 + a(ij) = a(i) + a(i) = t + t = a(ij) +23175 continue + l = j + if(.not.(a(j) .lt. t))goto 23177 + a(ij) = a(j) + a(j) = t + t = a(ij) + if(.not.(a(i) .gt. t))goto 23179 + a(ij) = a(i) + a(i) = t + t = a(ij) +23179 continue +23177 continue +23181 continue + l = l-1 + if(.not.(a(l) .le. t))goto 23184 + tt = a(l) +23186 continue + k = k+1 +23187 if(.not.(a(k) .ge. t))goto 23186 + if(.not.(k .gt. l))goto 23189 + goto 23183 +23189 continue + a(l) = a(k) + a(k) = tt +23184 continue +23182 goto 23181 +23183 continue + indl(m) = jl + indu(m) = ju + p = m + m = m+1 + if(.not.(l-i .le. j-k))goto 23191 + il(p) = k + iu(p) = j + j = l +23193 continue + if(.not.(jl .gt. ju))goto 23196 + goto 23167 +23196 continue + if(.not.(ind(ju) .le. j))goto 23198 + goto 23195 +23198 continue + ju = ju-1 +23194 goto 23193 +23195 continue + indl(p) = ju+1 + goto 23192 +23191 continue + il(p) = i + iu(p) = l + i = k +23200 continue + if(.not.(jl .gt. ju))goto 23203 + goto 23167 +23203 continue + if(.not.(ind(jl) .ge. i))goto 23205 + goto 23202 +23205 continue + jl = jl+1 +23201 goto 23200 +23202 continue + indu(p) = jl-1 +23192 continue + goto 23173 +23174 continue + if(.not.(i .eq. 1))goto 23207 + goto 23168 +23207 continue + i = i-1 +23209 continue + i = i+1 + if(.not.(i .eq. j))goto 23212 + goto 23211 +23212 continue + t = a(i+1) + if(.not.(a(i) .gt. t))goto 23214 + k = i +23216 continue + a(k+1) = a(k) + k = k-1 +23217 if(.not.(t .ge. a(k)))goto 23216 + a(k+1) = t +23214 continue +23210 goto 23209 +23211 continue +23171 continue +23167 goto 23166 +23168 continue +23162 goto 23161 +23163 continue + return + end Added: trunk/Lib/sandbox/pyloess/tests/__init__.py =================================================================== --- trunk/Lib/sandbox/pyloess/tests/__init__.py 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/tests/__init__.py 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,7 @@ +""" +Test suite for lowess, stl. +""" +__author__ = "Pierre GF Gerard-Marchant" +__version__ = '1.0' +__revision__ = "$Revision: 150 $" +__date__ = '$Date: 2007-02-28 23:42:16 -0500 (Wed, 28 Feb 2007) $' Added: trunk/Lib/sandbox/pyloess/tests/co2_data =================================================================== --- trunk/Lib/sandbox/pyloess/tests/co2_data 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/tests/co2_data 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,87 @@ +315.58 316.39 316.79 317.82 +318.39 318.22 316.68 315.01 +314.02 313.55 315.02 315.75 +316.52 317.1 317.79 319.22 +320.08 319.7 318.27 315.99 +314.24 314.05 315.05 316.23 +316.92 317.76 318.54 319.49 +320.64 319.85 318.7 316.96 +315.17 315.47 316.19 317.17 +318.12 318.72 319.79 320.68 +321.28 320.89 319.79 317.56 +316.46 315.59 316.85 317.87 +318.87 319.25 320.13 321.49 +322.34 321.62 319.85 317.87 +316.36 316.24 317.13 318.46 +319.57 320.23 320.89 321.54 +322.2 321.9 320.42 318.6 +316.73 317.15 317.94 318.91 +319.73 320.78 321.23 322.49 +322.59 322.35 321.61 319.24 +318.23 317.76 319.36 319.5 +320.35 321.4 322.22 323.45 +323.8 323.5 322.16 320.09 +318.26 317.66 319.47 320.7 +322.06 322.23 322.78 324.1 +324.63 323.79 322.34 320.73 +319 318.99 320.41 321.68 +322.3 322.89 323.59 324.65 +325.3 325.15 323.88 321.8 +319.99 319.86 320.88 322.36 +323.59 324.23 325.34 326.33 +327.03 326.24 325.39 323.16 +321.87 321.31 322.34 323.74 +324.61 325.58 326.55 327.81 +327.82 327.53 326.29 324.66 +323.12 323.09 324.01 325.1 +326.12 326.62 327.16 327.94 +329.15 328.79 327.53 325.65 +323.6 323.78 325.13 326.26 +326.93 327.84 327.96 329.93 +330.25 329.24 328.13 326.42 +324.97 325.29 326.56 327.73 +328.73 329.7 330.46 331.7 +332.66 332.22 331.02 329.39 +327.58 327.27 328.3 328.81 +329.44 330.89 331.62 332.85 +333.29 332.44 331.35 329.58 +327.58 327.55 328.56 329.73 +330.45 330.98 331.63 332.88 +333.63 333.53 331.9 330.08 +328.59 328.31 329.44 330.64 +331.62 332.45 333.36 334.46 +334.84 334.29 333.04 330.88 +329.23 328.83 330.18 331.5 +332.8 333.22 334.54 335.82 +336.45 335.97 334.65 332.4 +331.28 330.73 332.05 333.54 +334.65 335.06 336.32 337.39 +337.66 337.56 336.24 334.39 +332.43 332.22 333.61 334.78 +335.88 336.43 337.61 338.53 +339.06 338.92 337.39 335.72 +333.64 333.65 335.07 336.53 +337.82 338.19 339.89 340.56 +341.22 340.92 339.26 337.27 +335.66 335.54 336.71 337.79 +338.79 340.06 340.93 342.02 +342.65 341.8 340.01 337.94 +336.17 336.28 337.76 339.05 +340.18 341.04 342.16 343.01 +343.64 342.91 341.72 339.52 +337.75 337.68 339.14 340.37 +341.32 342.45 343.05 344.91 +345.77 345.3 343.98 342.41 +339.89 340.03 341.19 342.87 +343.74 344.55 345.28 347 +347.37 346.74 345.36 343.19 +340.97 341.2 342.76 343.96 +344.82 345.82 347.24 348.09 +348.66 347.9 346.27 344.21 +342.88 342.58 343.99 345.31 +345.98 346.72 347.63 349.24 +349.83 349.1 347.52 345.43 +344.48 343.89 345.29 346.54 +347.66 348.07 349.12 350.55 +351.34 350.8 349.1 347.54 +346.2 346.2 347.44 348.67 Added: trunk/Lib/sandbox/pyloess/tests/co2_results_double =================================================================== --- trunk/Lib/sandbox/pyloess/tests/co2_results_double 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/tests/co2_results_double 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,7 @@ + -0.131254643360572 0.517069428110988 1.08182067584919 2.13326637358770 2.73375546874132 2.23997776835891 0.929699515256501 -1.11444707420409 -2.67573821245580 -2.87856330488736 -1.90209785853191 -0.960288396846844 -0.127309599506098 0.519123971628999 1.09845833595895 2.15377745092389 2.74178279831138 2.24390654627401 0.927034947716549 -1.11840574881049 -2.69421608102192 -2.89832584564760 -1.91246650303411 -0.960459432315943 -0.123323614572555 0.521218070743582 1.11513416618278 2.17432369186148 2.74984228497017 2.24786402897563 0.924395632660881 -1.12234432639115 -2.71267900802084 -2.91807776589179 -1.92282884807142 -0.960626468256293 -0.119335930046407 0.523313128694124 1.13181021448592 2.19487004452363 2.75790177699876 2.25182151436214 0.921756317605213 -1.12628287349056 -2.73114187405725 -2.93782932476804 -1.93319053133537 -0.960792260330621 -0.115346419561576 0.525409317286149 1.14848669811335 2.21541273077976 2.76595350089103 2.25576409079413 0.919094952776809 -1.13025072305144 -2.74964129524388 -2.95762143862511 -1.94359676941072 -0.961001887200727 -0.111663528494415 0.527041806941144 1.16591699949743 2.23572475782599 2.77558209490346 2.26100862164176 0.916135515605680 -1.13521851311631 -2.76853269649236 -2.97819389766126 -1.95447404199440 -0.961469922313078 -0.107860654017195 0.528789664565914 1.18345805341101 2.25613699562502 2.78530035789200 2.26632885561176 0.913237815703161 -1.14013859201476 -2.78739041267661 -2.99874290502888 -1.96533809630523 -0.961929689327584 -0.104054461617129 0.530539382987096 1.20099951099456 2.27654943992924 2.79501863022095 2.27164909425196 0.910340115800643 -1.14505866933551 -2.80624812570546 -3.01929207422557 -1.97620247742963 -0.962391060045031 -0.100251149809378 0.532282176944238 1.21853000024234 2.29694352384120 2.80471115010115 2.27693520990275 0.907399922368041 -1.15002684464570 -2.82515954118310 -3.03989522748933 -1.98712112423937 -0.962900372915200 -9.657142836469074E-002 0.534498365407295 1.23663732630217 2.31763175742248 2.81524537246355 2.28255222950951 0.904114205312311 -1.15622306722147 -2.84480538227602 -3.06114244925604 -1.99798435060416 -0.963119381070332 -9.277853340694056E-002 0.536818220007927 1.25483881112409 2.33840092971464 2.82584731348562 2.28822285505067 0.900867981465680 -1.16239113573849 -2.86443440846052 -3.08237920554798 -2.00884346092780 -0.963336241276855 -8.898545859310647E-002 0.539138117293329 1.27304020145945 2.35917005259441 2.83644925016947 2.29389347842271 0.897621757619049 -1.16855899932509 -2.88406302478419 -3.10361326189795 -2.01969758122834 -0.963539280350215 -8.516973153606598E-002 0.541497365991697 1.29129764237755 2.38001852337338 2.84715383206899 2.29969629210904 0.894537269185294 -1.17453457130906 -2.90346879331549 -3.12459976725524 -2.03027944733590 -0.963462846700087 -8.318137128004088E-002 0.543878489204072 1.30556339626621 2.40086196051427 2.86349649009386 2.30662073374580 0.887792197369512 -1.18505484118622 -2.92012438706208 -3.14478006706923 -2.03869306366509 -0.962605359946822 -8.131952325850622E-002 0.546127682709739 1.31969180297595 2.42157577340269 2.87971724679271 2.31343828536589 0.880955246846406 -1.19565053554695 -2.93683895106848 -3.16500456560729 -2.04713610718260 -0.961766931458097 -7.946636457773126E-002 0.548371989282220 1.33381912516008 2.44228903304709 2.89593798152913 2.32025582600477 0.874118296323300 -1.20624598994303 -2.95355303514557 -3.18522530648506 -2.05557211530886 -0.960907763364043 -7.757876207755750E-002 0.550679154240705 1.34803772029682 2.46313591470192 2.91233468733382 2.32730163521162 0.867561911867873 -1.21650906054413 -2.96988291770040 -3.20502042283162 -2.06354107589496 -0.959566493512336 -7.730219052307574E-002 0.550357935231823 1.35866963091892 2.48275195707344 2.93421989150165 2.33628089748756 0.856814006163955 -1.23047890110198 -2.98132949467161 -3.22331217432112 -2.07013703786751 -0.958710477392881 -7.712537096548630E-002 0.549926745420134 1.36918135193231 2.50225440094597 2.95599808828023 2.34516971366972 0.845992215661742 -1.24450607549849 -2.99281685452186 -3.24163247691575 -2.07674931917128 -0.957864064655987 -7.695143884179889E-002 0.549494111512313 1.37969307218733 2.52175684968569 2.97777629555155 2.35405853509826 0.835170425159529 -1.25853325141979 -3.00430421742168 -3.25995284087020 -2.08336172014513 -0.957018509640572 -7.677910249098863E-002 0.549056980809610 1.39019739462547 2.54124599510881 2.99953529400655 2.36292081968353 0.824314769787128 -1.27259985902399 -3.01583657881712 -3.27831926911595 -2.09002125120596 -0.956215270085997 -7.659034326116144E-002 0.548303305832745 1.40189817662095 2.56059404473287 3.02216449393333 2.37249493004545 0.812882095499132 -1.28748162695347 -3.02788580296873 -3.29720423678765 -2.09686072038062 -0.955524593494270 -7.628314748519592E-002 0.547660207647820 1.41370167565417 2.58003235634854 3.04487150080557 2.38213274135591 0.801499016162785 -1.30232615353693 -3.03991013937994 -3.31607228287846 -2.10369123413391 -0.954828406701153 -7.597388672782887E-002 0.547018261938728 1.42550541465766 2.59947079083601 3.06757851345117 2.39177055555305 0.790115936826438 -1.31717061821239 -3.05193435197517 -3.33493973126345 -2.11052067629153 -0.954130057562446 -7.566137287494026E-002 0.546380413810568 1.43731409572749 2.61891435943207 3.09029085224759 2.40141467672878 0.778740145296439 -1.33200480401653 -3.06394529463410 -3.35378911923031 -2.11732726754918 -0.953403895217910 -7.602451339366684E-002 0.546239431030685 1.44876402506477 2.63888506323516 3.11434437457380 2.41097132000011 0.766666985700136 -1.34824458585656 -3.07630256711981 -3.37247512859970 -2.12367610934446 -0.952323810467218 -7.635206537097822E-002 0.546127432756093 1.46023633487122 2.65887223673730 3.13840845582895 2.42053368947150 0.754594719575008 -1.36448616515093 -3.08866432798535 -3.39116569389385 -2.13002957460944 -0.951247011186959 -7.668156481946027E-002 0.546014308367871 1.47170833992158 2.67885925398630 3.16247252933391 2.43009605506780 0.742522453449881 -1.38072769771166 -3.10102599538363 -3.40985565045688 -2.13638191587943 -0.950167084869187 -7.700593418790123E-002 0.545910597459656 1.48319404185191 2.69886726639568 3.18656489627965 2.43969768454088 0.730500421637537 -1.39690705311059 -3.11331354277110 -3.42846020971871 -2.14263758255784 -0.948981962890397 + 315.551939725323 315.644481572339 315.737023419355 315.831019342046 315.925015264737 316.017871370006 316.110727475274 316.202019778800 316.293312082325 316.398957194298 316.504602306271 316.616296186514 316.727990066757 316.807925805088 316.887861543420 316.931141044518 316.974420545617 317.009107349720 317.043794153822 317.079929437763 317.116064721703 317.145706993755 317.175349265808 317.217323426682 317.259297587556 317.333560803835 317.407824020115 317.503177240388 317.598530460661 317.693263457235 317.787996453809 317.877822068571 317.967647683333 318.050567993525 318.133488303716 318.210189243932 318.286890184147 318.358269704290 318.429649224433 318.490571336492 318.551493448551 318.604564508711 318.657635568871 318.704397175047 318.751158781223 318.799682725764 318.848206670306 318.893484228360 318.938761786415 318.971518019974 319.004274253534 319.036061188978 319.067848124423 319.111286397250 319.154724670078 319.201719446166 319.248714222255 319.284772974631 319.320831727008 319.357168859719 319.393505992430 319.440776405357 319.488046818284 319.536228132110 319.584409445937 319.624345612089 319.664281778242 319.706243792973 319.748205807704 319.801823191447 319.855440575190 319.916163786446 319.976886997702 320.047187868720 320.117488739738 320.196045022062 320.274601304387 320.342956883518 320.411312462648 320.477813606563 320.544314750478 320.619464561199 320.694614371920 320.767508281146 320.840402190372 320.894032842931 320.947663495491 321.000026728028 321.052389960566 321.121797898971 321.191205837375 321.260278580623 321.329351323871 321.385910769388 321.442470214905 321.490940957730 321.539411700554 321.589024066796 321.638636433037 321.692886430859 321.747136428681 321.807410271409 321.867684114138 321.932598715622 321.997513317105 322.066533621897 322.135553926688 322.222083283889 322.308612641090 322.397868000686 322.487123360281 322.560303090986 322.633482821692 322.714287308585 322.795091795478 322.908260930562 323.021430065647 323.150533438384 323.279636811122 323.406616081944 323.533595352765 323.665482985268 323.797370617771 323.924810654343 324.052250690915 324.157171357403 324.262092023892 324.359777947874 324.457463871855 324.556286968541 324.655110065228 324.752623165413 324.850136265599 324.960022466940 325.069908668282 325.197416497441 325.324924326600 325.446490625083 325.568056923567 325.666280376633 325.764503829700 325.848864548032 325.933225266364 326.017071987071 326.100918707778 326.175668162728 326.250417617679 326.323939678717 326.397461739755 326.484110353133 326.570758966511 326.668917429334 326.767075892157 326.861808991717 326.956542091276 327.033335451432 327.110128811587 327.191444480573 327.272760149559 327.385077493485 327.497394837411 327.629431366801 327.761467896192 327.914194748308 328.066921600425 328.248121894823 328.429322189222 328.638637270929 328.847952352636 329.060521894823 329.273091437010 329.451251567944 329.629411698878 329.765631868200 329.901852037522 329.994517707214 330.087183376907 330.156606311731 330.226029246556 330.265626534325 330.305223822094 330.323366805201 330.341509788308 330.368464497079 330.395419205849 330.433097452678 330.470775699507 330.495675736625 330.520575773744 330.540523844711 330.560471915678 330.599888688797 330.639305461916 330.698128574083 330.756951686250 330.830811600114 330.904671513979 330.997038064963 331.089404615948 331.204868521107 331.320332426266 331.430668355679 331.541004285091 331.626799906690 331.712595528288 331.781599415280 331.850603302271 331.910793078141 331.970982854011 332.037661841837 332.104340829664 332.188600437080 332.272860044496 332.384631494404 332.496402944312 332.631585554655 332.766768164998 332.918152479767 333.069536794536 333.229342023138 333.389147251741 333.545866305444 333.702585359147 333.848586388998 333.994587418849 334.126660196019 334.258732973190 334.387671725906 334.516610478623 334.648009639758 334.779408800893 334.902725346625 335.026041892356 335.139417944176 335.252793995995 335.361458254357 335.470122512718 335.573790214812 335.677457916906 335.779511353252 335.881564789598 335.989359512658 336.097154235719 336.218065610003 336.338976984288 336.476357256642 336.613737528996 336.769402814510 336.925068100023 337.091013012734 337.256957925444 337.420581414309 337.584204903175 337.740545944728 337.896886986282 338.042603733218 338.188320480154 338.310523251021 338.432726021888 338.544130098184 338.655534174480 338.765442959544 338.875351744608 338.966731194332 339.058110644055 339.128072537222 339.198034430388 339.268379466158 339.338724501929 339.424039477127 339.509354452325 339.599580850248 339.689807248171 339.786401591064 339.882995933956 339.997126144263 340.111256354571 340.235990611348 340.360724868124 340.473730387176 340.586735906228 340.689158181393 340.791580456557 340.900727360221 341.009874263885 341.154872396777 341.299870529668 341.483472761808 341.667074993948 341.868242153109 342.069409312271 342.264456214578 342.459503116885 342.650449487265 342.841395857645 343.021253454262 343.201111050878 343.354468577260 343.507826103641 343.637191865892 343.766557628142 343.886350911358 344.006144194574 344.115057152717 344.223970110859 344.323751742253 344.423533373646 344.526471089294 344.629408804942 344.735184447806 344.840960090669 344.940830075417 345.040700060165 345.142825602093 345.244951144021 345.353258414239 345.461565684457 345.561742598325 345.661919512192 345.747183300792 345.832447089391 345.918321519461 346.004195949531 346.100779004480 346.197362059429 346.299593561791 346.401825064153 346.512186102756 346.622547141358 346.744061652652 346.865576163946 346.988500888955 347.111425613964 347.232657355122 347.353889096279 347.483494160462 347.613099224645 347.764657761497 347.916216298350 348.111704887568 348.307193476786 348.500459990222 348.693726503657 348.890983069679 349.088239635700 349.291727004359 349.495214373018 349.702691602918 + 0.947488031764416 0.882390707609878 0.998157647188866 0.952418608947733 0.817270789273660 0.996885051409493 0.728085695102151 0.990851982305767 0.637884911652333 0.990072880709515 0.595762565698863 0.972711816092563 0.965856676712861 0.841499815568552 0.886523232980042 0.965146976116641 0.741668277822855 0.591837991311972 0.792193970670084 0.997641002602193 0.912710251366073 0.928807209498480 0.898237850232544 0.999266296612623 0.851886377313259 0.964215762668314 0.999965289268365 0.908641401475467 0.823260760767501 0.977611315847939 0.999974349583762 0.889567351166186 0.981488117858243 0.692616403426253 0.999799300554367 0.989320449671225 0.986825156618664 0.919534533638257 0.884225650135546 0.999760151806573 0.994414971601326 0.997951916161087 0.887100740140224 0.999562269234954 0.585920531538786 0.853141175940922 0.991037805096357 0.992152573567451 0.999332011617492 0.823545047162815 0.996443576352900 0.874206648004056 0.504419990571978 0.857988673199827 0.880110420364086 0.900473538757466 0.945823442689414 0.988574826041659 0.857348906652125 0.987735219949253 0.834849581142526 0.860603669548175 0.876631518580033 0.867738652432744 0.925070932274631 0.999566920332460 0.942733182253283 0.997254316870668 0.848459702866706 0.718212115789131 0.994416519154735 0.997261147415274 0.940630243662637 0.914072981316579 0.985177959596764 0.996989902230292 0.495901708774148 0.831373909694944 0.811585411032084 0.972422902327099 0.546506568978507 0.945466147984970 0.265167252870300 0.780073398100054 0.624172807601586 0.994702160557937 0.990471279156271 0.926205743368332 0.992289442371609 0.968178822977318 0.986639627303399 0.999350711154713 0.840996129164800 0.182032780051221 0.999420135756517 0.915674903525654 0.282483995465186 0.974733431424663 0.985662777337056 0.967728208260297 0.988995028275044 0.798827379975444 0.595406669550792 0.993177956795018 0.926237360222123 0.999240100281311 0.831292225438565 0.594676637874432 0.984614780462075 0.993177780480680 0.955256473058929 0.879741440104462 0.939025147345531 0.939963934618185 0.914610953158321 0.994504016810673 0.913917505780136 0.891820062027726 0.646946420306272 0.986077202293310 0.949554346292742 0.999015136479037 0.804778629910955 0.987191788882639 0.949946668384419 0.900620180118301 0.872239965517043 0.995495686190679 0.824647797345363 0.944362118100568 0.781994122827541 0.995249330421569 0.940627092330763 0.986553210751971 0.895606345391544 0.839413763311823 0.721710696426580 0.897831775256494 0.929067967094475 0.938208550669446 0.861961823764060 0.696886207592241 0.971019508447038 0.989448569084288 0.965598560947786 0.981922340009845 0.701411404420612 0.104600308707135 0.983164500996082 0.998017240668145 0.982302668213245 0.935061774348980 0.846669208371132 0.988816946876684 0.886186572312611 0.891383147444920 0.985965748104140 0.961108151167829 0.327083058925475 0.917596615233765 0.984060890087786 0.217730716921630 0.508169585980581 0.804407334152152 0.941039626571956 0.889349173772447 0.920662880643609 0.989464185236220 0.997605465838400 0.979297066753547 0.957172016172363 0.932132506038552 0.949575189698423 0.946393910886845 0.854301739303652 0.324800555892071 0.583488485913683 0.793620289936204 0.957643066851486 0.515647886050300 7.587988206706671E-002 0.996867521589717 0.997314974002783 0.989598664164471 0.999803995476453 0.791306381858096 0.999556931659123 0.812664089299613 0.999670698308111 0.900955932641992 0.992430774756580 0.976684805319769 0.975935960902469 0.839419982497541 0.541881541911152 0.650753760709872 0.920590438442358 0.885607859732216 0.993861723237700 0.983788524221900 0.863800866013731 0.980691997132225 0.995615856317590 0.998035099067158 0.999811714758427 0.964988924043206 0.941495533701261 0.985448935005877 0.989091806279382 0.984726628049543 0.983865840183017 0.978314689920389 0.989713063012797 0.748690231413388 0.850392645437634 0.926729817273933 0.964055523221987 0.858174179764269 0.971942532484567 0.975564067037686 0.973059960674606 0.982890313458071 0.974544248477077 0.880302225261198 0.823633420842541 0.939346535967996 0.952335555793629 0.972133528480918 0.882069362488227 0.957244691296426 0.931996655132657 0.998759581996794 0.730520403082927 0.987445088111139 0.943077947728455 0.830796266171339 0.995962582309898 0.976397067467406 0.999842741306551 0.994396191911193 0.980866711135284 0.974783154853931 0.958741105591158 0.887673550805615 0.821573436078837 0.981655775478357 0.994525598973073 0.902253799209502 0.820031864288388 0.927527981444656 0.969506633058071 0.993067476133660 0.762049414169121 0.976744402242804 0.321074631755019 0.996577589308699 0.999892202223984 0.867305592691854 0.999769688520615 0.999590503549087 0.998317218746979 0.990283611839627 0.984615565457175 0.873629200967010 0.925085621757581 0.649935802425659 0.752761503409992 0.915204684728773 0.822061098076671 0.999993666123134 0.794484496418216 0.679678268772147 0.512279128327064 0.907667460096379 0.998334986500622 0.999989606657796 0.932594465060915 0.824912191750586 0.668096805665421 0.994350905307304 0.999882062973145 0.932293050204642 0.953093150199542 0.980705662019545 0.892601959093755 0.945217594123708 0.991556051414152 0.930916373128400 0.850512922777617 0.994452949956122 0.554705372831289 0.997552734207715 0.889705207453044 0.867636913380303 0.733054431000601 0.189343181073062 0.826890203083248 0.999990059425219 0.873347393089944 0.937402781828196 0.991024201719805 0.960198320684717 0.931895807744739 0.836099661156904 0.994896965661127 0.999555521329668 0.925705142591297 0.999705976575668 0.337357688658303 0.927201512426989 0.997233493771151 0.996180780623039 0.965115513480998 0.945214504620896 0.400652424056755 0.978910246416990 0.988197843822846 0.983488981782400 0.944786229818726 0.898731539524064 0.958107295811193 0.997020194126272 0.975042358663448 0.949058616986090 0.966457179198796 0.971509076915235 0.866937202889720 0.990404613199697 0.992862121865960 0.985910200969520 0.978506742931891 0.892033009545154 0.536045358478198 0.994294000448681 0.991893801076137 0.999776834875325 0.943669866205371 0.887873440548549 0.835155315552832 0.865672193714240 0.957628043010181 0.958717440718235 0.765411016459182 0.998796714540848 0.872204491067018 0.752159100110003 0.982845533894251 0.980718422156039 + 2 + -0.131254643360572 0.517069428110988 1.08182067584919 2.13326637358770 2.73375546874132 2.23997776835891 0.929699515256501 -1.11444707420409 -2.67573821245580 -2.87856330488736 -1.90209785853191 -0.960288396846844 -0.127309599506098 0.519123971628999 1.09845833595895 2.15377745092389 2.74178279831138 2.24390654627401 0.927034947716549 -1.11840574881049 -2.69421608102192 -2.89832584564760 -1.91246650303411 -0.960459432315943 -0.123323614572555 0.521218070743582 1.11513416618278 2.17432369186148 2.74984228497017 2.24786402897563 0.924395632660881 -1.12234432639115 -2.71267900802084 -2.91807776589179 -1.92282884807142 -0.960626468256293 -0.119335930046407 0.523313128694124 1.13181021448592 2.19487004452363 2.75790177699876 2.25182151436214 0.921756317605213 -1.12628287349056 -2.73114187405725 -2.93782932476804 -1.93319053133537 -0.960792260330621 -0.115346419561576 0.525409317286149 1.14848669811335 2.21541273077976 2.76595350089103 2.25576409079413 0.919094952776809 -1.13025072305144 -2.74964129524388 -2.95762143862511 -1.94359676941072 -0.961001887200727 -0.111663528494415 0.527041806941144 1.16591699949743 2.23572475782599 2.77558209490346 2.26100862164176 0.916135515605680 -1.13521851311631 -2.76853269649236 -2.97819389766126 -1.95447404199440 -0.961469922313078 -0.107860654017195 0.528789664565914 1.18345805341101 2.25613699562502 2.78530035789200 2.26632885561176 0.913237815703161 -1.14013859201476 -2.78739041267661 -2.99874290502888 -1.96533809630523 -0.961929689327584 -0.104054461617129 0.530539382987096 1.20099951099456 2.27654943992924 2.79501863022095 2.27164909425196 0.910340115800643 -1.14505866933551 -2.80624812570546 -3.01929207422557 -1.97620247742963 -0.962391060045031 -0.100251149809378 0.532282176944238 1.21853000024234 2.29694352384120 2.80471115010115 2.27693520990275 0.907399922368041 -1.15002684464570 -2.82515954118310 -3.03989522748933 -1.98712112423937 -0.962900372915200 -9.657142836469074E-002 0.534498365407295 1.23663732630217 2.31763175742248 2.81524537246355 2.28255222950951 0.904114205312311 -1.15622306722147 -2.84480538227602 -3.06114244925604 -1.99798435060416 -0.963119381070332 -9.277853340694056E-002 0.536818220007927 1.25483881112409 2.33840092971464 2.82584731348562 2.28822285505067 0.900867981465680 -1.16239113573849 -2.86443440846052 -3.08237920554798 -2.00884346092780 -0.963336241276855 -8.898545859310647E-002 0.539138117293329 1.27304020145945 2.35917005259441 2.83644925016947 2.29389347842271 0.897621757619049 -1.16855899932509 -2.88406302478419 -3.10361326189795 -2.01969758122834 -0.963539280350215 -8.516973153606598E-002 0.541497365991697 1.29129764237755 2.38001852337338 2.84715383206899 2.29969629210904 0.894537269185294 -1.17453457130906 -2.90346879331549 -3.12459976725524 -2.03027944733590 -0.963462846700087 -8.318137128004088E-002 0.543878489204072 1.30556339626621 2.40086196051427 2.86349649009386 2.30662073374580 0.887792197369512 -1.18505484118622 -2.92012438706208 -3.14478006706923 -2.03869306366509 -0.962605359946822 -8.131952325850622E-002 0.546127682709739 1.31969180297595 2.42157577340269 2.87971724679271 2.31343828536589 0.880955246846406 -1.19565053554695 -2.93683895106848 -3.16500456560729 -2.04713610718260 -0.961766931458097 -7.946636457773126E-002 0.548371989282220 1.33381912516008 2.44228903304709 2.89593798152913 2.32025582600477 0.874118296323300 -1.20624598994303 -2.95355303514557 -3.18522530648506 -2.05557211530886 -0.960907763364043 -7.757876207755750E-002 0.550679154240705 1.34803772029682 2.46313591470192 2.91233468733382 2.32730163521162 0.867561911867873 -1.21650906054413 -2.96988291770040 -3.20502042283162 -2.06354107589496 -0.959566493512336 -7.730219052307574E-002 0.550357935231823 1.35866963091892 2.48275195707344 2.93421989150165 2.33628089748756 0.856814006163955 -1.23047890110198 -2.98132949467161 -3.22331217432112 -2.07013703786751 -0.958710477392881 -7.712537096548630E-002 0.549926745420134 1.36918135193231 2.50225440094597 2.95599808828023 2.34516971366972 0.845992215661742 -1.24450607549849 -2.99281685452186 -3.24163247691575 -2.07674931917128 -0.957864064655987 -7.695143884179889E-002 0.549494111512313 1.37969307218733 2.52175684968569 2.97777629555155 2.35405853509826 0.835170425159529 -1.25853325141979 -3.00430421742168 -3.25995284087020 -2.08336172014513 -0.957018509640572 -7.677910249098863E-002 0.549056980809610 1.39019739462547 2.54124599510881 2.99953529400655 2.36292081968353 0.824314769787128 -1.27259985902399 -3.01583657881712 -3.27831926911595 -2.09002125120596 -0.956215270085997 -7.659034326116144E-002 0.548303305832745 1.40189817662095 2.56059404473287 3.02216449393333 2.37249493004545 0.812882095499132 -1.28748162695347 -3.02788580296873 -3.29720423678765 -2.09686072038062 -0.955524593494270 -7.628314748519592E-002 0.547660207647820 1.41370167565417 2.58003235634854 3.04487150080557 2.38213274135591 0.801499016162785 -1.30232615353693 -3.03991013937994 -3.31607228287846 -2.10369123413391 -0.954828406701153 -7.597388672782887E-002 0.547018261938728 1.42550541465766 2.59947079083601 3.06757851345117 2.39177055555305 0.790115936826438 -1.31717061821239 -3.05193435197517 -3.33493973126345 -2.11052067629153 -0.954130057562446 -7.566137287494026E-002 0.546380413810568 1.43731409572749 2.61891435943207 3.09029085224759 2.40141467672878 0.778740145296439 -1.33200480401653 -3.06394529463410 -3.35378911923031 -2.11732726754918 -0.953403895217910 -7.602451339366684E-002 0.546239431030685 1.44876402506477 2.63888506323516 3.11434437457380 2.41097132000011 0.766666985700136 -1.34824458585656 -3.07630256711981 -3.37247512859970 -2.12367610934446 -0.952323810467218 -7.635206537097822E-002 0.546127432756093 1.46023633487122 2.65887223673730 3.13840845582895 2.42053368947150 0.754594719575008 -1.36448616515093 -3.08866432798535 -3.39116569389385 -2.13002957460944 -0.951247011186959 -7.668156481946027E-002 0.546014308367871 1.47170833992158 2.67885925398630 3.16247252933391 2.43009605506780 0.742522453449881 -1.38072769771166 -3.10102599538363 -3.40985565045688 -2.13638191587943 -0.950167084869187 -7.700593418790123E-002 0.545910597459656 1.48319404185191 2.69886726639568 3.18656489627965 2.43969768454088 0.730500421637537 -1.39690705311059 -3.11331354277110 -3.42846020971871 -2.14263758255784 -0.948981962890397 + 315.551939725323 315.644481572339 315.737023419355 315.831019342046 315.925015264737 316.017871370006 316.110727475274 316.202019778800 316.293312082325 316.398957194298 316.504602306271 316.616296186514 316.727990066757 316.807925805088 316.887861543420 316.931141044518 316.974420545617 317.009107349720 317.043794153822 317.079929437763 317.116064721703 317.145706993755 317.175349265808 317.217323426682 317.259297587556 317.333560803835 317.407824020115 317.503177240388 317.598530460661 317.693263457235 317.787996453809 317.877822068571 317.967647683333 318.050567993525 318.133488303716 318.210189243932 318.286890184147 318.358269704290 318.429649224433 318.490571336492 318.551493448551 318.604564508711 318.657635568871 318.704397175047 318.751158781223 318.799682725764 318.848206670306 318.893484228360 318.938761786415 318.971518019974 319.004274253534 319.036061188978 319.067848124423 319.111286397250 319.154724670078 319.201719446166 319.248714222255 319.284772974631 319.320831727008 319.357168859719 319.393505992430 319.440776405357 319.488046818284 319.536228132110 319.584409445937 319.624345612089 319.664281778242 319.706243792973 319.748205807704 319.801823191447 319.855440575190 319.916163786446 319.976886997702 320.047187868720 320.117488739738 320.196045022062 320.274601304387 320.342956883518 320.411312462648 320.477813606563 320.544314750478 320.619464561199 320.694614371920 320.767508281146 320.840402190372 320.894032842931 320.947663495491 321.000026728028 321.052389960566 321.121797898971 321.191205837375 321.260278580623 321.329351323871 321.385910769388 321.442470214905 321.490940957730 321.539411700554 321.589024066796 321.638636433037 321.692886430859 321.747136428681 321.807410271409 321.867684114138 321.932598715622 321.997513317105 322.066533621897 322.135553926688 322.222083283889 322.308612641090 322.397868000686 322.487123360281 322.560303090986 322.633482821692 322.714287308585 322.795091795478 322.908260930562 323.021430065647 323.150533438384 323.279636811122 323.406616081944 323.533595352765 323.665482985268 323.797370617771 323.924810654343 324.052250690915 324.157171357403 324.262092023892 324.359777947874 324.457463871855 324.556286968541 324.655110065228 324.752623165413 324.850136265599 324.960022466940 325.069908668282 325.197416497441 325.324924326600 325.446490625083 325.568056923567 325.666280376633 325.764503829700 325.848864548032 325.933225266364 326.017071987071 326.100918707778 326.175668162728 326.250417617679 326.323939678717 326.397461739755 326.484110353133 326.570758966511 326.668917429334 326.767075892157 326.861808991717 326.956542091276 327.033335451432 327.110128811587 327.191444480573 327.272760149559 327.385077493485 327.497394837411 327.629431366801 327.761467896192 327.914194748308 328.066921600425 328.248121894823 328.429322189222 328.638637270929 328.847952352636 329.060521894823 329.273091437010 329.451251567944 329.629411698878 329.765631868200 329.901852037522 329.994517707214 330.087183376907 330.156606311731 330.226029246556 330.265626534325 330.305223822094 330.323366805201 330.341509788308 330.368464497079 330.395419205849 330.433097452678 330.470775699507 330.495675736625 330.520575773744 330.540523844711 330.560471915678 330.599888688797 330.639305461916 330.698128574083 330.756951686250 330.830811600114 330.904671513979 330.997038064963 331.089404615948 331.204868521107 331.320332426266 331.430668355679 331.541004285091 331.626799906690 331.712595528288 331.781599415280 331.850603302271 331.910793078141 331.970982854011 332.037661841837 332.104340829664 332.188600437080 332.272860044496 332.384631494404 332.496402944312 332.631585554655 332.766768164998 332.918152479767 333.069536794536 333.229342023138 333.389147251741 333.545866305444 333.702585359147 333.848586388998 333.994587418849 334.126660196019 334.258732973190 334.387671725906 334.516610478623 334.648009639758 334.779408800893 334.902725346625 335.026041892356 335.139417944176 335.252793995995 335.361458254357 335.470122512718 335.573790214812 335.677457916906 335.779511353252 335.881564789598 335.989359512658 336.097154235719 336.218065610003 336.338976984288 336.476357256642 336.613737528996 336.769402814510 336.925068100023 337.091013012734 337.256957925444 337.420581414309 337.584204903175 337.740545944728 337.896886986282 338.042603733218 338.188320480154 338.310523251021 338.432726021888 338.544130098184 338.655534174480 338.765442959544 338.875351744608 338.966731194332 339.058110644055 339.128072537222 339.198034430388 339.268379466158 339.338724501929 339.424039477127 339.509354452325 339.599580850248 339.689807248171 339.786401591064 339.882995933956 339.997126144263 340.111256354571 340.235990611348 340.360724868124 340.473730387176 340.586735906228 340.689158181393 340.791580456557 340.900727360221 341.009874263885 341.154872396777 341.299870529668 341.483472761808 341.667074993948 341.868242153109 342.069409312271 342.264456214578 342.459503116885 342.650449487265 342.841395857645 343.021253454262 343.201111050878 343.354468577260 343.507826103641 343.637191865892 343.766557628142 343.886350911358 344.006144194574 344.115057152717 344.223970110859 344.323751742253 344.423533373646 344.526471089294 344.629408804942 344.735184447806 344.840960090669 344.940830075417 345.040700060165 345.142825602093 345.244951144021 345.353258414239 345.461565684457 345.561742598325 345.661919512192 345.747183300792 345.832447089391 345.918321519461 346.004195949531 346.100779004480 346.197362059429 346.299593561791 346.401825064153 346.512186102756 346.622547141358 346.744061652652 346.865576163946 346.988500888955 347.111425613964 347.232657355122 347.353889096279 347.483494160462 347.613099224645 347.764657761497 347.916216298350 348.111704887568 348.307193476786 348.500459990222 348.693726503657 348.890983069679 349.088239635700 349.291727004359 349.495214373018 349.702691602918 + 0.947488031764416 0.882390707609878 0.998157647188866 0.952418608947733 0.817270789273660 0.996885051409493 0.728085695102151 0.990851982305767 0.637884911652333 0.990072880709515 0.595762565698863 0.972711816092563 0.965856676712861 0.841499815568552 0.886523232980042 0.965146976116641 0.741668277822855 0.591837991311972 0.792193970670084 0.997641002602193 0.912710251366073 0.928807209498480 0.898237850232544 0.999266296612623 0.851886377313259 0.964215762668314 0.999965289268365 0.908641401475467 0.823260760767501 0.977611315847939 0.999974349583762 0.889567351166186 0.981488117858243 0.692616403426253 0.999799300554367 0.989320449671225 0.986825156618664 0.919534533638257 0.884225650135546 0.999760151806573 0.994414971601326 0.997951916161087 0.887100740140224 0.999562269234954 0.585920531538786 0.853141175940922 0.991037805096357 0.992152573567451 0.999332011617492 0.823545047162815 0.996443576352900 0.874206648004056 0.504419990571978 0.857988673199827 0.880110420364086 0.900473538757466 0.945823442689414 0.988574826041659 0.857348906652125 0.987735219949253 0.834849581142526 0.860603669548175 0.876631518580033 0.867738652432744 0.925070932274631 0.999566920332460 0.942733182253283 0.997254316870668 0.848459702866706 0.718212115789131 0.994416519154735 0.997261147415274 0.940630243662637 0.914072981316579 0.985177959596764 0.996989902230292 0.495901708774148 0.831373909694944 0.811585411032084 0.972422902327099 0.546506568978507 0.945466147984970 0.265167252870300 0.780073398100054 0.624172807601586 0.994702160557937 0.990471279156271 0.926205743368332 0.992289442371609 0.968178822977318 0.986639627303399 0.999350711154713 0.840996129164800 0.182032780051221 0.999420135756517 0.915674903525654 0.282483995465186 0.974733431424663 0.985662777337056 0.967728208260297 0.988995028275044 0.798827379975444 0.595406669550792 0.993177956795018 0.926237360222123 0.999240100281311 0.831292225438565 0.594676637874432 0.984614780462075 0.993177780480680 0.955256473058929 0.879741440104462 0.939025147345531 0.939963934618185 0.914610953158321 0.994504016810673 0.913917505780136 0.891820062027726 0.646946420306272 0.986077202293310 0.949554346292742 0.999015136479037 0.804778629910955 0.987191788882639 0.949946668384419 0.900620180118301 0.872239965517043 0.995495686190679 0.824647797345363 0.944362118100568 0.781994122827541 0.995249330421569 0.940627092330763 0.986553210751971 0.895606345391544 0.839413763311823 0.721710696426580 0.897831775256494 0.929067967094475 0.938208550669446 0.861961823764060 0.696886207592241 0.971019508447038 0.989448569084288 0.965598560947786 0.981922340009845 0.701411404420612 0.104600308707135 0.983164500996082 0.998017240668145 0.982302668213245 0.935061774348980 0.846669208371132 0.988816946876684 0.886186572312611 0.891383147444920 0.985965748104140 0.961108151167829 0.327083058925475 0.917596615233765 0.984060890087786 0.217730716921630 0.508169585980581 0.804407334152152 0.941039626571956 0.889349173772447 0.920662880643609 0.989464185236220 0.997605465838400 0.979297066753547 0.957172016172363 0.932132506038552 0.949575189698423 0.946393910886845 0.854301739303652 0.324800555892071 0.583488485913683 0.793620289936204 0.957643066851486 0.515647886050300 7.587988206706671E-002 0.996867521589717 0.997314974002783 0.989598664164471 0.999803995476453 0.791306381858096 0.999556931659123 0.812664089299613 0.999670698308111 0.900955932641992 0.992430774756580 0.976684805319769 0.975935960902469 0.839419982497541 0.541881541911152 0.650753760709872 0.920590438442358 0.885607859732216 0.993861723237700 0.983788524221900 0.863800866013731 0.980691997132225 0.995615856317590 0.998035099067158 0.999811714758427 0.964988924043206 0.941495533701261 0.985448935005877 0.989091806279382 0.984726628049543 0.983865840183017 0.978314689920389 0.989713063012797 0.748690231413388 0.850392645437634 0.926729817273933 0.964055523221987 0.858174179764269 0.971942532484567 0.975564067037686 0.973059960674606 0.982890313458071 0.974544248477077 0.880302225261198 0.823633420842541 0.939346535967996 0.952335555793629 0.972133528480918 0.882069362488227 0.957244691296426 0.931996655132657 0.998759581996794 0.730520403082927 0.987445088111139 0.943077947728455 0.830796266171339 0.995962582309898 0.976397067467406 0.999842741306551 0.994396191911193 0.980866711135284 0.974783154853931 0.958741105591158 0.887673550805615 0.821573436078837 0.981655775478357 0.994525598973073 0.902253799209502 0.820031864288388 0.927527981444656 0.969506633058071 0.993067476133660 0.762049414169121 0.976744402242804 0.321074631755019 0.996577589308699 0.999892202223984 0.867305592691854 0.999769688520615 0.999590503549087 0.998317218746979 0.990283611839627 0.984615565457175 0.873629200967010 0.925085621757581 0.649935802425659 0.752761503409992 0.915204684728773 0.822061098076671 0.999993666123134 0.794484496418216 0.679678268772147 0.512279128327064 0.907667460096379 0.998334986500622 0.999989606657796 0.932594465060915 0.824912191750586 0.668096805665421 0.994350905307304 0.999882062973145 0.932293050204642 0.953093150199542 0.980705662019545 0.892601959093755 0.945217594123708 0.991556051414152 0.930916373128400 0.850512922777617 0.994452949956122 0.554705372831289 0.997552734207715 0.889705207453044 0.867636913380303 0.733054431000601 0.189343181073062 0.826890203083248 0.999990059425219 0.873347393089944 0.937402781828196 0.991024201719805 0.960198320684717 0.931895807744739 0.836099661156904 0.994896965661127 0.999555521329668 0.925705142591297 0.999705976575668 0.337357688658303 0.927201512426989 0.997233493771151 0.996180780623039 0.965115513480998 0.945214504620896 0.400652424056755 0.978910246416990 0.988197843822846 0.983488981782400 0.944786229818726 0.898731539524064 0.958107295811193 0.997020194126272 0.975042358663448 0.949058616986090 0.966457179198796 0.971509076915235 0.866937202889720 0.990404613199697 0.992862121865960 0.985910200969520 0.978506742931891 0.892033009545154 0.536045358478198 0.994294000448681 0.991893801076137 0.999776834875325 0.943669866205371 0.887873440548549 0.835155315552832 0.865672193714240 0.957628043010181 0.958717440718235 0.765411016459182 0.998796714540848 0.872204491067018 0.752159100110003 0.982845533894251 0.980718422156039 Added: trunk/Lib/sandbox/pyloess/tests/co2_results_real =================================================================== --- trunk/Lib/sandbox/pyloess/tests/co2_results_real 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/tests/co2_results_real 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,7 @@ + -0.1312545 0.5171010 1.081863 2.133283 2.733717 2.239956 0.9297554 -1.114420 -2.675813 -2.878533 -1.902167 -0.9602861 -0.1273115 0.5191532 1.098498 2.153796 2.741747 2.243891 0.9270887 -1.118383 -2.694288 -2.898298 -1.912531 -0.9604589 -0.1233273 0.5212451 1.115170 2.174344 2.749810 2.247854 0.9244474 -1.122326 -2.712748 -2.918053 -1.922890 -0.9606276 -0.1193415 0.5233380 1.131844 2.194892 2.757873 2.251818 0.9218062 -1.126269 -2.731208 -2.937807 -1.933248 -0.9607950 -0.1153538 0.5254319 1.148517 2.215437 2.765927 2.255767 0.9191428 -1.130242 -2.749705 -2.957601 -1.943650 -0.9610062 -0.1116722 0.5270622 1.165944 2.235751 2.775559 2.261016 0.9161811 -1.135213 -2.768593 -2.978176 -1.954524 -0.9614759 -0.1078705 0.5288079 1.183482 2.256165 2.785280 2.266341 0.9132813 -1.140137 -2.787447 -2.998728 -1.965384 -0.9619374 -0.1040655 0.5305554 1.201020 2.276579 2.795002 2.271666 0.9103814 -1.145061 -2.806301 -3.019279 -1.976244 -0.9624004 -0.1002634 0.5322961 1.218547 2.296975 2.804697 2.276956 0.9074391 -1.150033 -2.825208 -3.039885 -1.987159 -0.9629111 -9.6585110E-02 0.5345098 1.236650 2.317664 2.815235 2.282577 0.9041511 -1.156232 -2.844850 -3.061133 -1.998018 -0.9631324 -9.2793740E-02 0.5368271 1.254847 2.338434 2.825840 2.288252 0.9009027 -1.162404 -2.864474 -3.082371 -2.008873 -0.9633515 -8.9002162E-02 0.5391444 1.273044 2.359204 2.836445 2.293926 0.8976543 -1.168575 -2.884098 -3.103606 -2.019723 -0.9635568 -8.5187905E-02 0.5415012 1.291297 2.380054 2.847153 2.299733 0.8945679 -1.174553 -2.903498 -3.124593 -2.030300 -0.9634821 -8.3201811E-02 0.5438787 1.305556 2.400896 2.863496 2.306658 0.8878226 -1.185068 -2.920140 -3.144774 -2.038712 -0.9626333 -8.1342012E-02 0.5461245 1.319679 2.421609 2.879717 2.313476 0.8809856 -1.195659 -2.936841 -3.164999 -2.047152 -0.9618035 -7.9490878E-02 0.5483653 1.333800 2.442321 2.895938 2.320295 0.8741485 -1.206250 -2.953541 -3.185220 -2.055586 -0.9609529 -7.7605315E-02 0.5506690 1.348012 2.463167 2.912336 2.327341 0.8675922 -1.216508 -2.969857 -3.205015 -2.063553 -0.9596200 -7.7330299E-02 0.5503440 1.358636 2.482778 2.934216 2.336317 0.8568450 -1.230463 -2.981276 -3.223306 -2.070151 -0.9587819 -7.7154912E-02 0.5499091 1.369141 2.502276 2.955991 2.345202 0.8460240 -1.244474 -2.992736 -3.241627 -2.076766 -0.9579533 -7.6982312E-02 0.5494729 1.379645 2.521775 2.977765 2.354088 0.8352031 -1.258486 -3.004196 -3.259947 -2.083381 -0.9571256 -7.6811321E-02 0.5490321 1.390142 2.541260 2.999520 2.362947 0.8243483 -1.272537 -3.015701 -3.278312 -2.090042 -0.9563401 -7.6623864E-02 0.5482746 1.401835 2.560602 3.022145 2.372517 0.8129162 -1.287402 -3.027721 -3.297196 -2.096884 -0.9556683 -7.6317951E-02 0.5476279 1.413630 2.580036 3.044847 2.382150 0.8015336 -1.302230 -3.039716 -3.316063 -2.103717 -0.9549910 -7.6009966E-02 0.5469823 1.425426 2.599469 3.067550 2.391784 0.7901511 -1.317057 -3.051710 -3.334929 -2.110549 -0.9543115 -7.5698733E-02 0.5463407 1.437227 2.618907 3.090258 2.401424 0.7787760 -1.331874 -3.063692 -3.353776 -2.117358 -0.9536040 -7.6063856E-02 0.5461957 1.448669 2.638872 3.114306 2.410975 0.7667037 -1.348096 -3.076017 -3.372460 -2.123710 -0.9525445 -7.6393344E-02 0.5460796 1.460133 2.658854 3.138366 2.420532 0.7546321 -1.364318 -3.088346 -3.391149 -2.130067 -0.9514883 -7.6724812E-02 0.5459623 1.471596 2.678835 3.162424 2.430090 0.7425606 -1.380541 -3.100676 -3.409836 -2.136422 -0.9504288 -7.7051133E-02 0.5458546 1.483073 2.698837 3.186512 2.439687 0.7305394 -1.396702 -3.112931 -3.428438 -2.142681 -0.9492642 + 315.5519 315.6444 315.7370 315.8309 315.9249 316.0178 316.1107 316.2020 316.2933 316.3990 316.5046 316.6163 316.7279 316.8079 316.8878 316.9311 316.9743 317.0090 317.0437 317.0798 317.1160 317.1457 317.1753 317.2173 317.2592 317.3336 317.4079 317.5032 317.5985 317.6932 317.7880 317.8778 317.9677 318.0505 318.1334 318.2101 318.2868 318.3582 318.4297 318.4905 318.5515 318.6045 318.6576 318.7044 318.7512 318.7997 318.8482 318.8934 318.9387 318.9714 319.0042 319.0360 319.0678 319.1112 319.1547 319.2017 319.2487 319.2848 319.3208 319.3572 319.3935 319.4408 319.4881 319.5362 319.5844 319.6243 319.6643 319.7062 319.7481 319.8018 319.8554 319.9161 319.9768 320.0472 320.1175 320.1960 320.2744 320.3428 320.4112 320.4777 320.5442 320.6194 320.6946 320.7675 320.8404 320.8941 320.9478 321.0001 321.0525 321.1218 321.1912 321.2603 321.3293 321.3860 321.4426 321.4910 321.5395 321.5891 321.6387 321.6929 321.7472 321.8074 321.8677 321.9326 321.9974 322.0666 322.1357 322.2221 322.3085 322.3978 322.4871 322.5602 322.6334 322.7142 322.7951 322.9083 323.0215 323.1505 323.2796 323.4066 323.5336 323.6655 323.7974 323.9248 324.0522 324.1571 324.2621 324.3597 324.4574 324.5563 324.6551 324.7526 324.8501 324.9600 325.0699 325.1974 325.3250 325.4465 325.5681 325.6663 325.7645 325.8489 325.9333 326.0171 326.1010 326.1757 326.2505 326.3240 326.3975 326.4841 326.5707 326.6689 326.7671 326.8619 326.9567 327.0334 327.1101 327.1916 327.2731 327.3853 327.4976 327.6297 327.7618 327.9146 328.0674 328.2484 328.4293 328.6387 328.8480 329.0606 329.2731 329.4512 329.6294 329.7654 329.9015 329.9944 330.0872 330.1566 330.2260 330.2656 330.3052 330.3234 330.3416 330.3688 330.3960 330.4333 330.4705 330.4956 330.5207 330.5406 330.5605 330.5999 330.6394 330.6982 330.7570 330.8309 330.9047 330.9972 331.0897 331.2050 331.3204 331.4307 331.5411 331.6268 331.7126 331.7816 331.8506 331.9108 331.9710 332.0377 332.1044 332.1886 332.2728 332.3846 332.4964 332.6316 332.7668 332.9182 333.0696 333.2294 333.3892 333.5459 333.7026 333.8486 333.9946 334.1266 334.2587 334.3876 334.5166 334.6480 334.7794 334.9027 335.0260 335.1393 335.2527 335.3613 335.4700 335.5737 335.6774 335.7795 335.8816 335.9893 336.0971 336.2180 336.3389 336.4763 336.6138 336.7694 336.9250 337.0909 337.2568 337.4205 337.5841 337.7405 337.8969 338.0427 338.1884 338.3105 338.4326 338.5441 338.6555 338.7655 338.8755 338.9668 339.0580 339.1279 339.1978 339.2682 339.3386 339.4240 339.5094 339.5996 339.6898 339.7864 339.8830 339.9971 340.1111 340.2360 340.3608 340.4738 340.5868 340.6892 340.7917 340.9008 341.0099 341.1549 341.2999 341.4833 341.6667 341.8679 342.0690 342.2645 342.4600 342.6507 342.8414 343.0210 343.2006 343.3539 343.5072 343.6369 343.7666 343.8864 344.0062 344.1151 344.2241 344.3238 344.4236 344.5265 344.6294 344.7352 344.8410 344.9409 345.0409 345.1429 345.2449 345.3532 345.4615 345.5617 345.6619 345.7472 345.8325 345.9183 346.0041 346.1007 346.1973 346.2995 346.4017 346.5121 346.6226 346.7441 346.8656 346.9885 347.1115 347.2327 347.3539 347.4835 347.6131 347.7646 347.9162 348.1116 348.3071 348.4999 348.6928 348.8899 349.0870 349.2884 349.4897 349.7021 + 0.9473456 0.8820528 0.9981718 0.9523941 0.8169235 0.9968721 0.7275636 0.9908377 0.6374046 0.9900793 0.5952753 0.9727222 0.9657797 0.8412194 0.8863041 0.9650735 0.7412772 0.5911558 0.7918944 0.9976359 0.9126042 0.9287147 0.8981016 0.9992640 0.8516618 0.9641449 0.9999655 0.9084932 0.8229079 0.9775841 0.9999740 0.8893542 0.9814858 0.6921397 0.9997987 0.9893009 0.9868131 0.9194017 0.8840622 0.9997586 0.9944118 0.9979475 0.8869542 0.9995601 0.5853120 0.8529151 0.9910294 0.9921290 0.9993278 0.8233213 0.9964389 0.8739912 0.5036717 0.8577449 0.8799009 0.9003027 0.9457330 0.9885447 0.8570249 0.9877417 0.8345523 0.8603712 0.8764476 0.8674909 0.9248952 0.9995702 0.9426413 0.9972472 0.8482621 0.7178012 0.9944118 0.9972574 0.9405500 0.9139733 0.9851364 0.9969788 0.4954960 0.8312120 0.8113978 0.9723752 0.5457299 0.9453593 0.2643782 0.7797844 0.6239225 0.9947231 0.9904200 0.9260687 0.9922562 0.9681790 0.9866477 0.9993476 0.8408600 0.1812998 0.9994192 0.9156029 0.2818184 0.9746988 0.9856681 0.9676514 0.9889814 0.7985213 0.5947735 0.9931651 0.9261450 0.9992403 0.8309539 0.5941209 0.9845950 0.9931651 0.9551575 0.8795514 0.9389349 0.9398142 0.9144093 0.9944832 0.9138095 0.8916704 0.6464453 0.9860324 0.9495300 0.9990164 0.8044351 0.9871626 0.9498475 0.9004778 0.8719712 0.9955013 0.8243347 0.9442974 0.7816713 0.9952399 0.9405271 0.9865257 0.8954014 0.8391304 0.7213080 0.8975996 0.9288895 0.9381664 0.8617947 0.6964918 0.9709492 0.9894392 0.9655861 0.9818738 0.7010069 0.1039263 0.9831502 0.9979994 0.9821939 0.9348792 0.8464258 0.9887996 0.8859938 0.8913366 0.9858394 0.9611016 0.3264723 0.9174322 0.9840199 0.2168292 0.5075723 0.8040431 0.9408705 0.8893237 0.9207462 0.9894688 0.9976125 0.9792520 0.9570797 0.9320744 0.9494027 0.9463241 0.8543022 0.3240814 0.5827369 0.7932186 0.9575490 0.5153625 7.5613648E-02 0.9968399 0.9972875 0.9896256 0.9998081 0.7909694 0.9995499 0.8123233 0.9996711 0.9008568 0.9924324 0.9765879 0.9759859 0.8392387 0.5412561 0.6502172 0.9204307 0.8854656 0.9938530 0.9838016 0.8638172 0.9807110 0.9956102 0.9980421 0.9998107 0.9649314 0.9413726 0.9854034 0.9891018 0.9846898 0.9838746 0.9782504 0.9896938 0.7482746 0.8501588 0.9267029 0.9640011 0.8578818 0.9719143 0.9755108 0.9730045 0.9828760 0.9745318 0.8800598 0.8233213 0.9392827 0.9522703 0.9719781 0.8818638 0.9571581 0.9319032 0.9987569 0.7301404 0.9874538 0.9430911 0.8306218 0.9959595 0.9763831 0.9998436 0.9944333 0.9808433 0.9747442 0.9586537 0.8875102 0.8213251 0.9816285 0.9945189 0.9021925 0.8195850 0.9273343 0.9694217 0.9929974 0.7616304 0.9767481 0.3199174 0.9965921 0.9998900 0.8672252 0.9997818 0.9995781 0.9983168 0.9902315 0.9846542 0.8739912 0.9251511 0.6491545 0.7521552 0.9149528 0.8217025 0.9999934 0.7942597 0.6791515 0.5116771 0.9076493 0.9983443 0.9999844 0.9324158 0.8247468 0.6679452 0.9943252 0.9998839 0.9321719 0.9530309 0.9806179 0.8923972 0.9451830 0.9915662 0.9311679 0.8502639 0.9944261 0.5542958 0.9975463 0.8896603 0.8676236 0.7327968 0.1887221 0.8266525 0.9999914 0.8732761 0.9370639 0.9911562 0.9603313 0.9317075 0.8358660 0.9948754 0.9995601 0.9256614 0.9997001 0.3365756 0.9271325 0.9972321 0.9962590 0.9649491 0.9452492 0.4000554 0.9789069 0.9881831 0.9834098 0.9445416 0.8983963 0.9580159 0.9970051 0.9750311 0.9486145 0.9663744 0.9714338 0.8667263 0.9904200 0.9929007 0.9858394 0.9784330 0.8917311 0.5354862 0.9942672 0.9918803 0.9998053 0.9436064 0.8876644 0.8348811 0.8652251 0.9573147 0.9585381 0.7653055 0.9986812 0.8698055 0.7505626 0.9830258 0.9803512 + 2 + -0.1312545 0.5171010 1.081863 2.133283 2.733717 2.239956 0.9297554 -1.114420 -2.675813 -2.878533 -1.902167 -0.9602861 -0.1273115 0.5191532 1.098498 2.153796 2.741747 2.243891 0.9270887 -1.118383 -2.694288 -2.898298 -1.912531 -0.9604589 -0.1233273 0.5212451 1.115170 2.174344 2.749810 2.247854 0.9244474 -1.122326 -2.712748 -2.918053 -1.922890 -0.9606276 -0.1193415 0.5233380 1.131844 2.194892 2.757873 2.251818 0.9218062 -1.126269 -2.731208 -2.937807 -1.933248 -0.9607950 -0.1153538 0.5254319 1.148517 2.215437 2.765927 2.255767 0.9191428 -1.130242 -2.749705 -2.957601 -1.943650 -0.9610062 -0.1116722 0.5270622 1.165944 2.235751 2.775559 2.261016 0.9161811 -1.135213 -2.768593 -2.978176 -1.954524 -0.9614759 -0.1078705 0.5288079 1.183482 2.256165 2.785280 2.266341 0.9132813 -1.140137 -2.787447 -2.998728 -1.965384 -0.9619374 -0.1040655 0.5305554 1.201020 2.276579 2.795002 2.271666 0.9103814 -1.145061 -2.806301 -3.019279 -1.976244 -0.9624004 -0.1002634 0.5322961 1.218547 2.296975 2.804697 2.276956 0.9074391 -1.150033 -2.825208 -3.039885 -1.987159 -0.9629111 -9.6585110E-02 0.5345098 1.236650 2.317664 2.815235 2.282577 0.9041511 -1.156232 -2.844850 -3.061133 -1.998018 -0.9631324 -9.2793740E-02 0.5368271 1.254847 2.338434 2.825840 2.288252 0.9009027 -1.162404 -2.864474 -3.082371 -2.008873 -0.9633515 -8.9002162E-02 0.5391444 1.273044 2.359204 2.836445 2.293926 0.8976543 -1.168575 -2.884098 -3.103606 -2.019723 -0.9635568 -8.5187905E-02 0.5415012 1.291297 2.380054 2.847153 2.299733 0.8945679 -1.174553 -2.903498 -3.124593 -2.030300 -0.9634821 -8.3201811E-02 0.5438787 1.305556 2.400896 2.863496 2.306658 0.8878226 -1.185068 -2.920140 -3.144774 -2.038712 -0.9626333 -8.1342012E-02 0.5461245 1.319679 2.421609 2.879717 2.313476 0.8809856 -1.195659 -2.936841 -3.164999 -2.047152 -0.9618035 -7.9490878E-02 0.5483653 1.333800 2.442321 2.895938 2.320295 0.8741485 -1.206250 -2.953541 -3.185220 -2.055586 -0.9609529 -7.7605315E-02 0.5506690 1.348012 2.463167 2.912336 2.327341 0.8675922 -1.216508 -2.969857 -3.205015 -2.063553 -0.9596200 -7.7330299E-02 0.5503440 1.358636 2.482778 2.934216 2.336317 0.8568450 -1.230463 -2.981276 -3.223306 -2.070151 -0.9587819 -7.7154912E-02 0.5499091 1.369141 2.502276 2.955991 2.345202 0.8460240 -1.244474 -2.992736 -3.241627 -2.076766 -0.9579533 -7.6982312E-02 0.5494729 1.379645 2.521775 2.977765 2.354088 0.8352031 -1.258486 -3.004196 -3.259947 -2.083381 -0.9571256 -7.6811321E-02 0.5490321 1.390142 2.541260 2.999520 2.362947 0.8243483 -1.272537 -3.015701 -3.278312 -2.090042 -0.9563401 -7.6623864E-02 0.5482746 1.401835 2.560602 3.022145 2.372517 0.8129162 -1.287402 -3.027721 -3.297196 -2.096884 -0.9556683 -7.6317951E-02 0.5476279 1.413630 2.580036 3.044847 2.382150 0.8015336 -1.302230 -3.039716 -3.316063 -2.103717 -0.9549910 -7.6009966E-02 0.5469823 1.425426 2.599469 3.067550 2.391784 0.7901511 -1.317057 -3.051710 -3.334929 -2.110549 -0.9543115 -7.5698733E-02 0.5463407 1.437227 2.618907 3.090258 2.401424 0.7787760 -1.331874 -3.063692 -3.353776 -2.117358 -0.9536040 -7.6063856E-02 0.5461957 1.448669 2.638872 3.114306 2.410975 0.7667037 -1.348096 -3.076017 -3.372460 -2.123710 -0.9525445 -7.6393344E-02 0.5460796 1.460133 2.658854 3.138366 2.420532 0.7546321 -1.364318 -3.088346 -3.391149 -2.130067 -0.9514883 -7.6724812E-02 0.5459623 1.471596 2.678835 3.162424 2.430090 0.7425606 -1.380541 -3.100676 -3.409836 -2.136422 -0.9504288 -7.7051133E-02 0.5458546 1.483073 2.698837 3.186512 2.439687 0.7305394 -1.396702 -3.112931 -3.428438 -2.142681 -0.9492642 + 315.5519 315.6444 315.7370 315.8309 315.9249 316.0178 316.1107 316.2020 316.2933 316.3990 316.5046 316.6163 316.7279 316.8079 316.8878 316.9311 316.9743 317.0090 317.0437 317.0798 317.1160 317.1457 317.1753 317.2173 317.2592 317.3336 317.4079 317.5032 317.5985 317.6932 317.7880 317.8778 317.9677 318.0505 318.1334 318.2101 318.2868 318.3582 318.4297 318.4905 318.5515 318.6045 318.6576 318.7044 318.7512 318.7997 318.8482 318.8934 318.9387 318.9714 319.0042 319.0360 319.0678 319.1112 319.1547 319.2017 319.2487 319.2848 319.3208 319.3572 319.3935 319.4408 319.4881 319.5362 319.5844 319.6243 319.6643 319.7062 319.7481 319.8018 319.8554 319.9161 319.9768 320.0472 320.1175 320.1960 320.2744 320.3428 320.4112 320.4777 320.5442 320.6194 320.6946 320.7675 320.8404 320.8941 320.9478 321.0001 321.0525 321.1218 321.1912 321.2603 321.3293 321.3860 321.4426 321.4910 321.5395 321.5891 321.6387 321.6929 321.7472 321.8074 321.8677 321.9326 321.9974 322.0666 322.1357 322.2221 322.3085 322.3978 322.4871 322.5602 322.6334 322.7142 322.7951 322.9083 323.0215 323.1505 323.2796 323.4066 323.5336 323.6655 323.7974 323.9248 324.0522 324.1571 324.2621 324.3597 324.4574 324.5563 324.6551 324.7526 324.8501 324.9600 325.0699 325.1974 325.3250 325.4465 325.5681 325.6663 325.7645 325.8489 325.9333 326.0171 326.1010 326.1757 326.2505 326.3240 326.3975 326.4841 326.5707 326.6689 326.7671 326.8619 326.9567 327.0334 327.1101 327.1916 327.2731 327.3853 327.4976 327.6297 327.7618 327.9146 328.0674 328.2484 328.4293 328.6387 328.8480 329.0606 329.2731 329.4512 329.6294 329.7654 329.9015 329.9944 330.0872 330.1566 330.2260 330.2656 330.3052 330.3234 330.3416 330.3688 330.3960 330.4333 330.4705 330.4956 330.5207 330.5406 330.5605 330.5999 330.6394 330.6982 330.7570 330.8309 330.9047 330.9972 331.0897 331.2050 331.3204 331.4307 331.5411 331.6268 331.7126 331.7816 331.8506 331.9108 331.9710 332.0377 332.1044 332.1886 332.2728 332.3846 332.4964 332.6316 332.7668 332.9182 333.0696 333.2294 333.3892 333.5459 333.7026 333.8486 333.9946 334.1266 334.2587 334.3876 334.5166 334.6480 334.7794 334.9027 335.0260 335.1393 335.2527 335.3613 335.4700 335.5737 335.6774 335.7795 335.8816 335.9893 336.0971 336.2180 336.3389 336.4763 336.6138 336.7694 336.9250 337.0909 337.2568 337.4205 337.5841 337.7405 337.8969 338.0427 338.1884 338.3105 338.4326 338.5441 338.6555 338.7655 338.8755 338.9668 339.0580 339.1279 339.1978 339.2682 339.3386 339.4240 339.5094 339.5996 339.6898 339.7864 339.8830 339.9971 340.1111 340.2360 340.3608 340.4738 340.5868 340.6892 340.7917 340.9008 341.0099 341.1549 341.2999 341.4833 341.6667 341.8679 342.0690 342.2645 342.4600 342.6507 342.8414 343.0210 343.2006 343.3539 343.5072 343.6369 343.7666 343.8864 344.0062 344.1151 344.2241 344.3238 344.4236 344.5265 344.6294 344.7352 344.8410 344.9409 345.0409 345.1429 345.2449 345.3532 345.4615 345.5617 345.6619 345.7472 345.8325 345.9183 346.0041 346.1007 346.1973 346.2995 346.4017 346.5121 346.6226 346.7441 346.8656 346.9885 347.1115 347.2327 347.3539 347.4835 347.6131 347.7646 347.9162 348.1116 348.3071 348.4999 348.6928 348.8899 349.0870 349.2884 349.4897 349.7021 + 0.9473456 0.8820528 0.9981718 0.9523941 0.8169235 0.9968721 0.7275636 0.9908377 0.6374046 0.9900793 0.5952753 0.9727222 0.9657797 0.8412194 0.8863041 0.9650735 0.7412772 0.5911558 0.7918944 0.9976359 0.9126042 0.9287147 0.8981016 0.9992640 0.8516618 0.9641449 0.9999655 0.9084932 0.8229079 0.9775841 0.9999740 0.8893542 0.9814858 0.6921397 0.9997987 0.9893009 0.9868131 0.9194017 0.8840622 0.9997586 0.9944118 0.9979475 0.8869542 0.9995601 0.5853120 0.8529151 0.9910294 0.9921290 0.9993278 0.8233213 0.9964389 0.8739912 0.5036717 0.8577449 0.8799009 0.9003027 0.9457330 0.9885447 0.8570249 0.9877417 0.8345523 0.8603712 0.8764476 0.8674909 0.9248952 0.9995702 0.9426413 0.9972472 0.8482621 0.7178012 0.9944118 0.9972574 0.9405500 0.9139733 0.9851364 0.9969788 0.4954960 0.8312120 0.8113978 0.9723752 0.5457299 0.9453593 0.2643782 0.7797844 0.6239225 0.9947231 0.9904200 0.9260687 0.9922562 0.9681790 0.9866477 0.9993476 0.8408600 0.1812998 0.9994192 0.9156029 0.2818184 0.9746988 0.9856681 0.9676514 0.9889814 0.7985213 0.5947735 0.9931651 0.9261450 0.9992403 0.8309539 0.5941209 0.9845950 0.9931651 0.9551575 0.8795514 0.9389349 0.9398142 0.9144093 0.9944832 0.9138095 0.8916704 0.6464453 0.9860324 0.9495300 0.9990164 0.8044351 0.9871626 0.9498475 0.9004778 0.8719712 0.9955013 0.8243347 0.9442974 0.7816713 0.9952399 0.9405271 0.9865257 0.8954014 0.8391304 0.7213080 0.8975996 0.9288895 0.9381664 0.8617947 0.6964918 0.9709492 0.9894392 0.9655861 0.9818738 0.7010069 0.1039263 0.9831502 0.9979994 0.9821939 0.9348792 0.8464258 0.9887996 0.8859938 0.8913366 0.9858394 0.9611016 0.3264723 0.9174322 0.9840199 0.2168292 0.5075723 0.8040431 0.9408705 0.8893237 0.9207462 0.9894688 0.9976125 0.9792520 0.9570797 0.9320744 0.9494027 0.9463241 0.8543022 0.3240814 0.5827369 0.7932186 0.9575490 0.5153625 7.5613648E-02 0.9968399 0.9972875 0.9896256 0.9998081 0.7909694 0.9995499 0.8123233 0.9996711 0.9008568 0.9924324 0.9765879 0.9759859 0.8392387 0.5412561 0.6502172 0.9204307 0.8854656 0.9938530 0.9838016 0.8638172 0.9807110 0.9956102 0.9980421 0.9998107 0.9649314 0.9413726 0.9854034 0.9891018 0.9846898 0.9838746 0.9782504 0.9896938 0.7482746 0.8501588 0.9267029 0.9640011 0.8578818 0.9719143 0.9755108 0.9730045 0.9828760 0.9745318 0.8800598 0.8233213 0.9392827 0.9522703 0.9719781 0.8818638 0.9571581 0.9319032 0.9987569 0.7301404 0.9874538 0.9430911 0.8306218 0.9959595 0.9763831 0.9998436 0.9944333 0.9808433 0.9747442 0.9586537 0.8875102 0.8213251 0.9816285 0.9945189 0.9021925 0.8195850 0.9273343 0.9694217 0.9929974 0.7616304 0.9767481 0.3199174 0.9965921 0.9998900 0.8672252 0.9997818 0.9995781 0.9983168 0.9902315 0.9846542 0.8739912 0.9251511 0.6491545 0.7521552 0.9149528 0.8217025 0.9999934 0.7942597 0.6791515 0.5116771 0.9076493 0.9983443 0.9999844 0.9324158 0.8247468 0.6679452 0.9943252 0.9998839 0.9321719 0.9530309 0.9806179 0.8923972 0.9451830 0.9915662 0.9311679 0.8502639 0.9944261 0.5542958 0.9975463 0.8896603 0.8676236 0.7327968 0.1887221 0.8266525 0.9999914 0.8732761 0.9370639 0.9911562 0.9603313 0.9317075 0.8358660 0.9948754 0.9995601 0.9256614 0.9997001 0.3365756 0.9271325 0.9972321 0.9962590 0.9649491 0.9452492 0.4000554 0.9789069 0.9881831 0.9834098 0.9445416 0.8983963 0.9580159 0.9970051 0.9750311 0.9486145 0.9663744 0.9714338 0.8667263 0.9904200 0.9929007 0.9858394 0.9784330 0.8917311 0.5354862 0.9942672 0.9918803 0.9998053 0.9436064 0.8876644 0.8348811 0.8652251 0.9573147 0.9585381 0.7653055 0.9986812 0.8698055 0.7505626 0.9830258 0.9803512 Added: trunk/Lib/sandbox/pyloess/tests/test_pyloess.py =================================================================== --- trunk/Lib/sandbox/pyloess/tests/test_pyloess.py 2007-03-12 19:46:06 UTC (rev 2843) +++ trunk/Lib/sandbox/pyloess/tests/test_pyloess.py 2007-03-12 19:47:15 UTC (rev 2844) @@ -0,0 +1,131 @@ +""" +Wrapper to lowess and stl routines. + +:author: Pierre GF Gerard-Marchant +:contact: pierregm_at_uga_edu +:date: $Date: 2007-02-28 02:23:25 -0500 (Wed, 28 Feb 2007) $ +:version: $Id: generic.py 145 2007-02-28 07:23:25Z backtopop $ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__version__ = '1.0' +__revision__ = "$Revision: 145 $" +__date__ = '$Date: 2007-02-28 02:23:25 -0500 (Wed, 28 Feb 2007) $' + +import os + +import numpy +from numpy import bool_, complex_, float_, int_, str_, object_ +import numpy.core.numeric as numeric +from numpy.core.records import recarray + +from numpy.testing import NumpyTest, NumpyTestCase +from numpy.testing.utils import build_err_msg, \ + assert_equal, assert_almost_equal + +import pyloess +reload(pyloess) +from pyloess import lowess, stl + + +def get_co2data(): + "Reads CO2 data." + filename = os.path.join('tests','co2_data') + F = open(filename, 'r') + data = [] + for line in F.readlines(): + data.append([float(x) for x in line.rstrip().split()]) + return numpy.concatenate(data) + +def get_co2results(): + "Gets theoretical results of smoothed CO2." + filename = os.path.join('tests','co2_results_double') + F = open(filename, 'r') + result = [] + for line in F.readlines(): + result.append(numpy.fromiter((float(x) for x in line.rstrip().split()), + float_)) + return result + +def set_parameters(): + "Returns the parameters of the STL on CO2 data." + parameters = dict(np=12, ns=35, nt=19, nl=13, no=2, ni=1, + nsjump=4, ntjump=2, nljump=2, + isdeg=1, itdeg=1, ildeg=1) + return parameters +######################################################################## +class test_lowess(NumpyTestCase): + "Test class for lowess." + # + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + X = [ 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8,10,12,14,50] + Y = [18, 2,15, 6,10, 4,16,11, 7, 3,14,17,20,12, 9,13, 1, 8, 5,19] + self.data = (X, Y) + # + def test_lowess_1(self): + "Tests lowess on typical data. part #1." + (X, Y) = self.data + YS = [13.659,11.145, 8.701, 9.722,10.000,11.300,11.300,11.300, + 11.300,11.300,11.300,11.300,11.300,11.300,11.300,13.000, + 6.440, 5.596, 5.456,18.998] + Z = lowess(X, Y, f=0.25, nsteps=0, delta=0) + assert_almost_equal(Z.smooth, YS, decimal=3) + assert_almost_equal(Z.residuals+Z.smooth, Y, decimal=3) + # + def test_lowess_2(self): + "Tests lowess on typical data. part #2." + (X, Y) = self.data + YS = [13.659,12.347,11.034, 9.722,10.511,11.300,11.300,11.300, + 11.300,11.300,11.300,11.300,11.300,11.300,11.300,13.000, + 6.440, 5.596, 5.456,18.998] + Z = lowess(X, Y, f=0.25, nsteps=0, delta=3) + assert_almost_equal(Z.smooth, YS, decimal=3) + assert_almost_equal(Z.residuals+Z.smooth, Y, decimal=3) + # + def test_lowess_3(self): + "Tests lowess on typical data. part #3." + (X, Y) = self.data + YS = [14.811,12.115, 8.984, 9.676,10.000,11.346,11.346,11.346, + 11.346,11.346,11.346,11.346,11.346,11.346,11.346,13.000, + 6.734, 5.744, 5.415,18.998 ] + Z = lowess(X, Y, f=0.25, nsteps=2, delta=0) + assert_almost_equal(Z.smooth, YS, decimal=3) + assert_almost_equal(Z.residuals+Z.smooth, Y, decimal=3) + +#----------------------------------------------------------------------- +class test_stl(NumpyTestCase): + "Tests STL." + # + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + co2_data = get_co2data() + co2_results = get_co2results() + parameters = set_parameters() + self.d = (co2_data, co2_results, parameters) + # + def test_stl_1(self): + "Tests a classic STL." + (co2_data, co2_results, parameters) = self.d + co2_fitted = stl(co2_data, robust=False, **parameters) + assert_almost_equal(co2_fitted.seasonal, co2_results[0], 6) + assert_almost_equal(co2_fitted.trend, co2_results[1], 6) + assert_almost_equal(co2_fitted.weights, co2_results[2], 6) + # + def test_stl_2(self): + "Tests a robust STL." + (co2_data, co2_results, parameters) = self.d + co2_fitted = stl(co2_data, robust=True, **parameters) + assert_almost_equal(co2_fitted.seasonal, co2_results[4], 6) + assert_almost_equal(co2_fitted.trend, co2_results[5], 6) + assert_almost_equal(co2_fitted.weights, co2_results[6], 6) + +######################################################################## +if __name__ == '__main__': + NumpyTest().run() + # + co2_data = get_co2data() + co2_results = get_co2results() + parameters = set_parameters() + co2_fitted = stl(co2_data, robust=False, **parameters) + + From scipy-svn at scipy.org Wed Mar 14 04:28:19 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 14 Mar 2007 03:28:19 -0500 (CDT) Subject: [Scipy-svn] r2845 - trunk/Lib/sparse Message-ID: <20070314082819.2740839C03C@new.scipy.org> Author: wnbell Date: 2007-03-14 03:28:17 -0500 (Wed, 14 Mar 2007) New Revision: 2845 Modified: trunk/Lib/sparse/sparse.py Log: fixed typo in csc_matrix docs Modified: trunk/Lib/sparse/sparse.py =================================================================== --- trunk/Lib/sparse/sparse.py 2007-03-12 19:47:15 UTC (rev 2844) +++ trunk/Lib/sparse/sparse.py 2007-03-14 08:28:17 UTC (rev 2845) @@ -722,7 +722,7 @@ - csc_matrix((data, ij), [(M, N), nzmax]) where data, ij satisfy: - a[ij[k, 0], ij[k, 1]] = data[k] + a[ij[0, k], ij[1, k]] = data[k] - csc_matrix((data, row, ptr), [(M, N)]) standard CSC representation From scipy-svn at scipy.org Wed Mar 14 08:36:59 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 14 Mar 2007 07:36:59 -0500 (CDT) Subject: [Scipy-svn] r2846 - trunk/Lib/sandbox/pyloess/sandbox/src Message-ID: <20070314123659.9BDB039C04D@new.scipy.org> Author: pierregm Date: 2007-03-14 07:34:56 -0500 (Wed, 14 Mar 2007) New Revision: 2846 Modified: trunk/Lib/sandbox/pyloess/sandbox/src/predict.c Log: sandbox: Thanks to Francesc Altec suggestion, the loess routines now run without crashing...However, they are not yet fully tested. Modified: trunk/Lib/sandbox/pyloess/sandbox/src/predict.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/predict.c 2007-03-14 08:28:17 UTC (rev 2845) +++ trunk/Lib/sandbox/pyloess/sandbox/src/predict.c 2007-03-14 12:34:56 UTC (rev 2846) @@ -4,8 +4,7 @@ #include void -predict(double *eval, int m, loess *lo, predicted *pre, - int se) +predict(double *eval, int m, loess *lo, prediction *pre, int se) { int size_info[3]; void pred_(); @@ -159,7 +158,7 @@ } void -pred_free_mem(predicted *pre) +pred_free_mem(prediction *pre) { free(pre->fit); free(pre->se_fit); From scipy-svn at scipy.org Wed Mar 14 08:48:23 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 14 Mar 2007 07:48:23 -0500 (CDT) Subject: [Scipy-svn] r2847 - trunk/Lib/sandbox/pyloess/sandbox/src Message-ID: <20070314124823.A4F5439C04D@new.scipy.org> Author: pierregm Date: 2007-03-14 07:46:49 -0500 (Wed, 14 Mar 2007) New Revision: 2847 Modified: trunk/Lib/sandbox/pyloess/sandbox/src/c_loess.pxd trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c trunk/Lib/sandbox/pyloess/sandbox/src/cloess.h trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx trunk/Lib/sandbox/pyloess/sandbox/src/loess.c trunk/Lib/sandbox/pyloess/sandbox/src/loess.h trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c trunk/Lib/sandbox/pyloess/sandbox/src/misc.c Log: sandbox: Thanks to Francesc Altec suggestion, the loess routines now run without crashing...However, they are not yet fully tested. Modified: trunk/Lib/sandbox/pyloess/sandbox/src/c_loess.pxd =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/c_loess.pxd 2007-03-14 12:34:56 UTC (rev 2846) +++ trunk/Lib/sandbox/pyloess/sandbox/src/c_loess.pxd 2007-03-14 12:46:49 UTC (rev 2847) @@ -2,30 +2,26 @@ cdef extern from "loess.h": ctypedef struct c_loess_inputs "loess_inputs": - long n - long p - double *y - double *x - double *weights + long n + long p + double *y + double *x + double *weights ctypedef struct c_loess_model "loess_model": - double span - long degree - long normalize - long parametric[8] - long drop_square[8] - char *family + double span + int degree + int normalize + int parametric[8] + int drop_square[8] + char *family ctypedef struct c_loess_control "loess_control": - char *surface - char *statistics - double cell - char *trace_hat - long iterations + char *surface + char *statistics + double cell + char *trace_hat + int iterations ctypedef struct c_loess_kd_tree "loess_kd_tree": - long *parameter - long *a - double *xi - double *vert - double *vval + pass ctypedef struct c_loess_outputs "loess_outputs": double *fitted_values double *fitted_residuals @@ -44,44 +40,29 @@ c_loess_control control c_loess_kd_tree kd_tree c_loess_outputs outputs - #typedef struct { - # double *fit; - # double *se_fit; - # double residual_scale; - # double df; - #} predicted; - # - #struct anova_struct { - # double dfn; - # double dfd; - # double F_value; - # double Pr_F; - #}; - # - #struct ci_struct { - # double *fit; - # double *upper; - # double *lower; - #}; -cdef extern from "loess.h": + ctypedef struct c_prediction "prediction": + double *fit + double *se_fit + double residual_scale + double df + ctypedef struct c_anova "anova_struct": + double dfn + double dfd + double F_value + double Pr_F + ctypedef struct c_conf_inv "conf_inv": + double *fit + double *upper + double *lower + +cdef extern from "cloess.h": void loess_setup(double *x, double *y, long n, long p, c_loess *lo) void loess_fit(c_loess *lo) - void loess_(double *y, double *x_, int *size_info, double *weights, - double *span, int *degree, int *parametric, int *drop_square, - int *normalize, char **statistics, char **surface, double *cell, - char **trace_hat_in, int *iterations, double *fitted_values, - double *fitted_residuals, double *enp, double *s, double *one_delta, - double *two_delta, double *pseudovalues, double *trace_hat_out, - double *diagonal, double *robust, double *divisor, long *parameter, - long *a, double *xi, double *vert, double *vval) void loess_free_mem(c_loess *lo) void loess_summary(c_loess *lo) - void condition(char **surface, char *new_stat, char **trace_hat_in) - int comp(double *d1, double *d2) - - void loess_raw(double *y, double *x, double *weights, double *robust, int *d, - int*n, double *span, int *degree, int *nonparametric, - int *drop_square, int *sum_drop_sqr, double *cell, char **surf_stat, - double *surface, long *parameter, long *a, double *xi, double *vert, - double *vval, double *diagonal, double *trL, double *one_delta, - double *two_delta, int *setLf) + # + void predict(double *eval, int m, c_loess *lo, c_prediction *pre, int se) + void pred_free_mem(c_prediction *pre) + # + void anova(c_loess *one, c_loess *two, c_anova *out) + void pointwise(c_prediction *pre, int m, double coverage, c_conf_inv *ci) \ No newline at end of file Modified: trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c 2007-03-14 12:34:56 UTC (rev 2846) +++ trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c 2007-03-14 12:46:49 UTC (rev 2847) @@ -1,4 +1,4 @@ -/* Generated by Pyrex 0.9.5.1a on Mon Mar 12 15:39:59 2007 */ +/* Generated by Pyrex 0.9.5.1a on Wed Mar 14 08:14:04 2007 */ #include "Python.h" #include "structmember.h" @@ -14,6 +14,7 @@ #include "stdlib.h" #include "numpy/arrayobject.h" #include "loess.h" +#include "cloess.h" typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ @@ -25,16 +26,18 @@ static char *__pyx_filename; static char **__pyx_f; +static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/ + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ -static int __Pyx_PrintItem(PyObject *); /*proto*/ -static int __Pyx_PrintNewline(void); /*proto*/ +static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ -static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ +static int __Pyx_PrintItem(PyObject *); /*proto*/ +static int __Pyx_PrintNewline(void); /*proto*/ static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ @@ -62,66 +65,58 @@ struct __pyx_obj_6cloess_loess_inputs { PyObject_HEAD - loess_inputs _inputs; - long nobs; - long nvar; - PyArrayObject *x; - PyArrayObject *y; - PyArrayObject *weights; + loess_inputs (*_base); }; struct __pyx_obj_6cloess_loess_control { PyObject_HEAD - loess_control _control; - char (*surface); - char (*statistics); - char (*trace_hat); - double cell; - int iterations; + loess_control (*_base); }; +struct __pyx_obj_6cloess_loess_kd_tree { + PyObject_HEAD + loess_kd_tree (*_base); +}; + + +struct __pyx_obj_6cloess_loess_model { + PyObject_HEAD + loess_model (*_base); + long npar; +}; + + struct __pyx_obj_6cloess_loess_outputs { PyObject_HEAD - loess_outputs _outputs; - PyArrayObject *fitted_values; - PyArrayObject *fitted_residuals; - PyArrayObject *pseudovalues; - PyArrayObject *diagonal; - PyArrayObject *robust; - PyArrayObject *divisor; - double enp; - double s; - double one_delta; - double two_delta; - double trace_hat; + loess_outputs (*_base); + long nobs; }; -struct __pyx_obj_6cloess_loess_kd_tree { +struct __pyx_obj_6cloess_loess_anova { PyObject_HEAD - loess_kd_tree _kdtree; - PyArrayObject *parameter; - PyArrayObject *a; - PyArrayObject *xi; - PyArrayObject *vert; - PyArrayObject *vval; + anova_struct (*_base); + long nest; }; -struct __pyx_obj_6cloess_loess_model { +struct __pyx_obj_6cloess_confidence_interval { PyObject_HEAD - loess_model _model; - double span; - int degree; - int normalize; - char (*family); - PyObject *parametric_flags; - PyObject *drop_square_flags; + conf_inv (*_base); + PyObject *nest; }; +struct __pyx_obj_6cloess_loess_predicted { + PyObject_HEAD + prediction (*_base); + long nest; + struct __pyx_obj_6cloess_confidence_interval *conf_interval; +}; + + struct __pyx_obj_6cloess_loess { PyObject_HEAD loess _base; @@ -130,324 +125,900 @@ struct __pyx_obj_6cloess_loess_control *control; struct __pyx_obj_6cloess_loess_kd_tree *kd_tree; struct __pyx_obj_6cloess_loess_outputs *outputs; + struct __pyx_obj_6cloess_loess_predicted *predicted; }; static PyTypeObject *__pyx_ptype_6cloess_loess_inputs = 0; static PyTypeObject *__pyx_ptype_6cloess_loess_control = 0; -static PyTypeObject *__pyx_ptype_6cloess_loess_outputs = 0; static PyTypeObject *__pyx_ptype_6cloess_loess_kd_tree = 0; static PyTypeObject *__pyx_ptype_6cloess_loess_model = 0; +static PyTypeObject *__pyx_ptype_6cloess_loess_outputs = 0; +static PyTypeObject *__pyx_ptype_6cloess_loess_anova = 0; +static PyTypeObject *__pyx_ptype_6cloess_confidence_interval = 0; +static PyTypeObject *__pyx_ptype_6cloess_loess_predicted = 0; static PyTypeObject *__pyx_ptype_6cloess_loess = 0; -static PyObject *__pyx_k2; -static double __pyx_k3; -static int __pyx_k4; -static int __pyx_k5; -static PyObject *__pyx_k6; static PyObject *__pyx_k7; +static PyObject *__pyx_k8; static PyObject *__pyx_k9; -static PyObject *__pyx_k10; +static PyObject *(__pyx_f_6cloess_floatarray_from_data(PyObject *,PyObject *,double (*))); /*proto*/ +static PyObject *(__pyx_f_6cloess_boolarray_from_data(PyObject *,PyObject *,int (*))); /*proto*/ /* Implementation of cloess */ +static char (__pyx_k1[]) = "Weights"; +static char (__pyx_k2[]) = "Number of observations."; +static char (__pyx_k3[]) = "Number of independent variables."; +static char (__pyx_k4[]) = "Normalize the variables. Only useful if more than one variable..."; +static char (__pyx_k5[]) = "Equivalent number of parameters."; static PyObject *__pyx_n_c_python; static PyObject *__pyx_n_c_numpy; -static PyObject *__pyx_n__N; +static PyObject *__pyx_n_numpy; static PyObject *__pyx_n_c_loess; -static PyObject *__pyx_n_numpy; static PyObject *__pyx_n_False; -static PyObject *__pyx_n_gaussian; -static PyObject *__pyx_n_ndim; -static PyObject *__pyx_n_ValueError; -static PyObject *__pyx_n_len; +static PyObject *__pyx_n_empty; +static PyObject *__pyx_n_float; +static PyObject *__pyx_n_dtype; static PyObject *__pyx_n_size; +static PyObject *__pyx_n_shape; -static PyObject *__pyx_k11p; -static PyObject *__pyx_k12p; -static PyObject *__pyx_k13p; -static PyObject *__pyx_k14p; -static char (__pyx_k11[]) = "DEBUG: Initializing loess_inputs..."; -static char (__pyx_k12[]) = "Argument 'x' should be 2D at most!"; -static char (__pyx_k13[]) = "Invalid size of the 'weights' vector!"; -static char (__pyx_k14[]) = " OK."; - -static int __pyx_f_6cloess_12loess_inputs___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_6cloess_12loess_inputs___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_x = 0; - PyObject *__pyx_v_y = 0; - PyObject *__pyx_v_weights = 0; - double (*__pyx_v_w_dat); - npy_intp __pyx_v_n; - npy_intp __pyx_v_p; - npy_intp (*__pyx_v_dims); +static PyObject *__pyx_f_6cloess_floatarray_from_data(PyObject *__pyx_v_rows,PyObject *__pyx_v_cols,double (*__pyx_v_data)) { + PyArrayObject *__pyx_v_a_ndr; + double (*__pyx_v_a_dat); PyObject *__pyx_v_i; - int __pyx_r; + PyObject *__pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; - int __pyx_3; + PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; - npy_intp __pyx_5; + PyObject *__pyx_5 = 0; long __pyx_6; - static char *__pyx_argnames[] = {"x","y","weights",0}; - __pyx_v_weights = __pyx_k2; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_weights)) return -1; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_x); - Py_INCREF(__pyx_v_y); - Py_INCREF(__pyx_v_weights); + long __pyx_7; + int __pyx_8; + int __pyx_9; + Py_INCREF(__pyx_v_rows); + Py_INCREF(__pyx_v_cols); + __pyx_v_a_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_i = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":27 */ - if (__Pyx_PrintItem(__pyx_k11p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; goto __pyx_L1;} - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":28 */ - __pyx_1 = PyArray_FROMANY(__pyx_v_x,NPY_DOUBLE,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x)); - ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x = ((PyArrayObject *)__pyx_1); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":22 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":29 */ - __pyx_1 = PyArray_FROMANY(__pyx_v_y,NPY_DOUBLE,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->y)); - ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->y = ((PyArrayObject *)__pyx_1); + __pyx_1 = PyNumber_Multiply(__pyx_v_rows, __pyx_v_cols); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); + __pyx_1 = 0; + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3); + __pyx_3 = 0; + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_float); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_dtype, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_a_ndr)); + __pyx_v_a_ndr = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":31 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x), __pyx_n_ndim); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} - __pyx_3 = __pyx_3 > 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":23 */ + __pyx_v_a_dat = ((double (*))__pyx_v_a_ndr->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":24 */ + __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} + __pyx_7 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + for (__pyx_6 = 0; __pyx_6 < __pyx_7; ++__pyx_6) { + __pyx_2 = PyInt_FromLong(__pyx_6); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} + Py_DECREF(__pyx_v_i); + __pyx_v_i = __pyx_2; + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":25 */ + __pyx_8 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} + __pyx_9 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} + (__pyx_v_a_dat[__pyx_9]) = (__pyx_v_data[__pyx_8]); + } + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":26 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_cols, __pyx_1, &__pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + __pyx_8 = __pyx_8 > 0; Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__pyx_3) { + if (__pyx_8) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":32 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} - __Pyx_Raise(__pyx_1, __pyx_k12p, 0); - Py_DECREF(__pyx_1); __pyx_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} - goto __pyx_L2; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":27 */ + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; goto __pyx_L1;} + Py_INCREF(__pyx_v_rows); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_rows); + Py_INCREF(__pyx_v_cols); + PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_cols); + if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + goto __pyx_L4; } - __pyx_L2:; + __pyx_L4:; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":28 */ + Py_INCREF(((PyObject *)__pyx_v_a_ndr)); + __pyx_r = ((PyObject *)__pyx_v_a_ndr); + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("cloess.floatarray_from_data"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_a_ndr); + Py_DECREF(__pyx_v_i); + Py_DECREF(__pyx_v_rows); + Py_DECREF(__pyx_v_cols); + return __pyx_r; +} + +static PyObject *__pyx_n_int; +static PyObject *__pyx_n_astype; +static PyObject *__pyx_n_bool; + + +static PyObject *__pyx_f_6cloess_boolarray_from_data(PyObject *__pyx_v_rows,PyObject *__pyx_v_cols,int (*__pyx_v_data)) { + PyArrayObject *__pyx_v_a_ndr; + int (*__pyx_v_a_dat); + PyObject *__pyx_v_i; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + long __pyx_6; + long __pyx_7; + int __pyx_8; + int __pyx_9; + Py_INCREF(__pyx_v_rows); + Py_INCREF(__pyx_v_cols); + __pyx_v_a_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + __pyx_v_i = Py_None; Py_INCREF(Py_None); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":33 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyNumber_Multiply(__pyx_v_rows, __pyx_v_cols); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); + __pyx_1 = 0; __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} - Py_INCREF(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x)); - PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x)); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3); + __pyx_3 = 0; + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_int); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_dtype, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_5 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_v_n = __pyx_5; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_a_ndr)); + __pyx_v_a_ndr = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":34 */ - __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x), __pyx_n_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} - __pyx_1 = PyInt_FromLong(__pyx_v_n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} - __pyx_4 = PyNumber_Divide(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_v_a_dat = ((int (*))__pyx_v_a_ndr->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":35 */ + __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + __pyx_7 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + for (__pyx_6 = 0; __pyx_6 < __pyx_7; ++__pyx_6) { + __pyx_2 = PyInt_FromLong(__pyx_6); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + Py_DECREF(__pyx_v_i); + __pyx_v_i = __pyx_2; + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":36 */ + __pyx_8 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + __pyx_9 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + (__pyx_v_a_dat[__pyx_9]) = (__pyx_v_data[__pyx_8]); + } + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":37 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_cols, __pyx_1, &__pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} + __pyx_8 = __pyx_8 > 0; Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_5 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} + if (__pyx_8) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":38 */ + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} + Py_INCREF(__pyx_v_rows); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_rows); + Py_INCREF(__pyx_v_cols); + PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_cols); + if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + goto __pyx_L4; + } + __pyx_L4:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":39 */ + __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_astype); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_bool); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); + __pyx_2 = 0; + __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_v_p = __pyx_5; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":36 */ - ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->nobs = ((long )__pyx_v_n); + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("cloess.boolarray_from_data"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_a_ndr); + Py_DECREF(__pyx_v_i); + Py_DECREF(__pyx_v_rows); + Py_DECREF(__pyx_v_cols); + return __pyx_r; +} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":37 */ - ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->nvar = ((long )__pyx_v_p); +static PyObject *__pyx_f_6cloess_12loess_inputs_1x___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_12loess_inputs_1x___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":38 */ - (__pyx_v_dims[0]) = __pyx_v_n; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":50 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->x); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":40 */ - __pyx_3 = __pyx_v_weights == Py_None; - if (__pyx_3) { + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_inputs.x.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":41 */ - __pyx_2 = PyArray_EMPTY(1,__pyx_v_dims,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights)); - ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights = ((PyArrayObject *)__pyx_2); - Py_DECREF(__pyx_2); __pyx_2 = 0; +static PyObject *__pyx_f_6cloess_12loess_inputs_1y___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_12loess_inputs_1y___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":42 */ - __pyx_v_w_dat = ((double (*))((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights->data); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":54 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->y); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":43 */ - __pyx_5 = (__pyx_v_dims[0]); - for (__pyx_6 = 0; __pyx_6 < __pyx_5; ++__pyx_6) { - __pyx_1 = PyInt_FromLong(__pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; goto __pyx_L1;} - Py_DECREF(__pyx_v_i); - __pyx_v_i = __pyx_1; - __pyx_1 = 0; + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_inputs.y.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":44 */ - __pyx_3 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} - (__pyx_v_w_dat[__pyx_3]) = 1; - } - goto __pyx_L3; - } - /*else*/ { +static PyObject *__pyx_f_6cloess_12loess_inputs_7weights___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_12loess_inputs_7weights___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":46 */ - __pyx_4 = PyArray_FROMANY(__pyx_v_weights,NPY_DOUBLE,1,1,NPY_OWNDATA); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights)); - ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights = ((PyArrayObject *)__pyx_4); - Py_DECREF(__pyx_4); __pyx_4 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":59 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->weights); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":47 */ - __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights), __pyx_n_ndim); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} - __pyx_3 = __pyx_3 > 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - if (!__pyx_3) { - __pyx_4 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights), __pyx_n_size); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_n); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_4, __pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} - __pyx_3 = __pyx_3 != 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - } - if (__pyx_3) { + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_inputs.weights.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":48 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} - __Pyx_Raise(__pyx_1, __pyx_k13p, 0); - Py_DECREF(__pyx_1); __pyx_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;} - goto __pyx_L6; - } - __pyx_L6:; +static PyObject *__pyx_n_ndim; +static PyObject *__pyx_n_ValueError; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":49 */ - __pyx_v_w_dat = ((double (*))((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights->data); +static PyObject *__pyx_k12p; + +static char (__pyx_k12[]) = "Invalid size of the 'weights' vector!"; + +static int __pyx_f_6cloess_12loess_inputs_7weights___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_w); /*proto*/ +static int __pyx_f_6cloess_12loess_inputs_7weights___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_w) { + PyArrayObject *__pyx_v_w_ndr; + int __pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_w); + __pyx_v_w_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":64 */ + __pyx_1 = PyArray_FROMANY(__pyx_v_w,NPY_DOUBLE,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)__pyx_v_w_ndr)); + __pyx_v_w_ndr = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":65 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_ndim); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;} + __pyx_2 = __pyx_2 > 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__pyx_2) { + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;} + __pyx_2 = __pyx_2 != 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; } - __pyx_L3:; + if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":51 */ - ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_inputs.n = ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->nobs; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":66 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;} + __Pyx_Raise(__pyx_1, __pyx_k12p, 0); + Py_DECREF(__pyx_1); __pyx_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":52 */ - ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_inputs.p = ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->nvar; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":67 */ + ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->weights = ((double (*))__pyx_v_w_ndr->data); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":53 */ - ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_inputs.x = ((double (*))((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->x->data); + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_inputs.weights.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_w_ndr); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_w); + return __pyx_r; +} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":54 */ - ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_inputs.y = ((double (*))((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->y->data); +static PyObject *__pyx_f_6cloess_12loess_inputs_4nobs___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_12loess_inputs_4nobs___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":55 */ - ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_inputs.weights = ((double (*))((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->weights->data); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":72 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":62 */ - if (__Pyx_PrintItem(__pyx_k14p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;} - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;} + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_inputs.nobs.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":63 */ +static PyObject *__pyx_f_6cloess_12loess_inputs_4nvar___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_12loess_inputs_4nvar___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":77 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_inputs.nvar.__get__"); __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_13loess_control_7surface___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_control_7surface___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":87 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_control.surface.__get__"); __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static int __pyx_f_6cloess_13loess_control_7surface___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_surface); /*proto*/ +static int __pyx_f_6cloess_13loess_control_7surface___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_surface) { + int __pyx_r; + char (*__pyx_1); + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_surface); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":89 */ + __pyx_1 = PyString_AsString(__pyx_v_surface); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->surface = __pyx_1; + + __pyx_r = 0; goto __pyx_L0; __pyx_L1:; + __Pyx_AddTraceback("cloess.loess_control.surface.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_surface); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_13loess_control_10statistics___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_control_10statistics___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":93 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("cloess.loess_inputs.__init__"); + __Pyx_AddTraceback("cloess.loess_control.statistics.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static int __pyx_f_6cloess_13loess_control_10statistics___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_statistics); /*proto*/ +static int __pyx_f_6cloess_13loess_control_10statistics___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_statistics) { + int __pyx_r; + char (*__pyx_1); + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_statistics); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":95 */ + __pyx_1 = PyString_AsString(__pyx_v_statistics); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->statistics = __pyx_1; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + __Pyx_AddTraceback("cloess.loess_control.statistics.__set__"); __pyx_r = -1; __pyx_L0:; - Py_DECREF(__pyx_v_i); Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_x); - Py_DECREF(__pyx_v_y); - Py_DECREF(__pyx_v_weights); + Py_DECREF(__pyx_v_statistics); return __pyx_r; } -static PyObject *__pyx_k15p; -static PyObject *__pyx_k19p; +static PyObject *__pyx_f_6cloess_13loess_control_9trace_hat___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_control_9trace_hat___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); -static char (__pyx_k15[]) = "DEBUG: Initializing loess_control..."; -static char (__pyx_k16[]) = "interpolate"; -static char (__pyx_k17[]) = "approximate"; -static char (__pyx_k18[]) = "wait.to.decide"; -static char (__pyx_k19[]) = "OK."; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":99 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; -static int __pyx_f_6cloess_13loess_control___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_6cloess_13loess_control___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_control.trace_hat.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static int __pyx_f_6cloess_13loess_control_9trace_hat___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_trace_hat); /*proto*/ +static int __pyx_f_6cloess_13loess_control_9trace_hat___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_trace_hat) { int __pyx_r; - static char *__pyx_argnames[] = {0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1; + char (*__pyx_1); Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_trace_hat); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":76 */ - if (__Pyx_PrintItem(__pyx_k15p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":101 */ + __pyx_1 = PyString_AsString(__pyx_v_trace_hat); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->trace_hat = __pyx_1; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":77 */ - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->surface = __pyx_k16; - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_control.surface = __pyx_k16; + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + __Pyx_AddTraceback("cloess.loess_control.trace_hat.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_trace_hat); + return __pyx_r; +} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":78 */ - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->statistics = __pyx_k17; - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_control.statistics = __pyx_k17; +static PyObject *__pyx_f_6cloess_13loess_control_10iterations___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_control_10iterations___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":79 */ - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->cell = 0.2; - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_control.cell = 0.2; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":105 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":80 */ - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->trace_hat = __pyx_k18; - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_control.trace_hat = __pyx_k18; + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_control.iterations.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":81 */ - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->iterations = 4; - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_control.iterations = 4; +static int __pyx_f_6cloess_13loess_control_10iterations___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_iterations); /*proto*/ +static int __pyx_f_6cloess_13loess_control_10iterations___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_iterations) { + int __pyx_r; + int __pyx_1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_iterations); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":82 */ - if (__Pyx_PrintItem(__pyx_k19p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;} - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":107 */ + __pyx_1 = PyInt_AsLong(__pyx_v_iterations); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->iterations = __pyx_1; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":83 */ __pyx_r = 0; goto __pyx_L0; + __pyx_L1:; + __Pyx_AddTraceback("cloess.loess_control.iterations.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_iterations); + return __pyx_r; +} +static PyObject *__pyx_f_6cloess_13loess_control_4cell___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_control_4cell___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":111 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_control.cell.__get__"); __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static int __pyx_f_6cloess_13loess_control_4cell___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_cell); /*proto*/ +static int __pyx_f_6cloess_13loess_control_4cell___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_cell) { + int __pyx_r; + double __pyx_1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_cell); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":113 */ + __pyx_1 = PyFloat_AsDouble(__pyx_v_cell); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->cell = __pyx_1; + + __pyx_r = 0; goto __pyx_L0; __pyx_L1:; - __Pyx_AddTraceback("cloess.loess_control.__init__"); + __Pyx_AddTraceback("cloess.loess_control.cell.__set__"); __pyx_r = -1; __pyx_L0:; Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_cell); return __pyx_r; } +static PyObject *__pyx_n_get; +static PyObject *__pyx_n_surface; +static PyObject *__pyx_n_statistics; +static PyObject *__pyx_n_trace_hat; +static PyObject *__pyx_n_iterations; +static PyObject *__pyx_n_cell; +static PyObject *__pyx_n_parametric_flags; + + +static PyObject *__pyx_f_6cloess_13loess_control_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_control_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_cellargs = 0; + PyObject *__pyx_v_surface; + PyObject *__pyx_v_statistics; + PyObject *__pyx_v_trace_hat; + PyObject *__pyx_v_iterations; + PyObject *__pyx_v_cell; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + int __pyx_4; + static char *__pyx_argnames[] = {0}; + if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, 0, &__pyx_v_cellargs) < 0) return 0; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) { + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + Py_XDECREF(__pyx_v_cellargs); + return 0; + } + Py_INCREF(__pyx_v_self); + __pyx_v_surface = Py_None; Py_INCREF(Py_None); + __pyx_v_statistics = Py_None; Py_INCREF(Py_None); + __pyx_v_trace_hat = Py_None; Py_INCREF(Py_None); + __pyx_v_iterations = Py_None; Py_INCREF(Py_None); + __pyx_v_cell = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":116 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;} + Py_INCREF(__pyx_n_surface); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_surface); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_surface); + __pyx_v_surface = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":117 */ + __pyx_4 = __pyx_v_surface != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":118 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_surface, __pyx_v_surface) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":120 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} + Py_INCREF(__pyx_n_statistics); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_statistics); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_statistics); + __pyx_v_statistics = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":121 */ + __pyx_4 = __pyx_v_statistics != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":122 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_statistics, __pyx_v_statistics) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":124 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;} + Py_INCREF(__pyx_n_trace_hat); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_trace_hat); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_trace_hat); + __pyx_v_trace_hat = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":125 */ + __pyx_4 = __pyx_v_trace_hat != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":126 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_trace_hat, __pyx_v_trace_hat) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;} + goto __pyx_L4; + } + __pyx_L4:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":128 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; goto __pyx_L1;} + Py_INCREF(__pyx_n_iterations); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_iterations); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_iterations); + __pyx_v_iterations = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":129 */ + __pyx_4 = __pyx_v_iterations != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":130 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_iterations, __pyx_v_iterations) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":132 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;} + Py_INCREF(__pyx_n_cell); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_cell); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_cell); + __pyx_v_cell = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":133 */ + __pyx_4 = __pyx_v_cell != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":134 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; goto __pyx_L1;} + goto __pyx_L6; + } + __pyx_L6:; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_control.update"); + __pyx_r = 0; + __pyx_L0:; + Py_XDECREF(__pyx_v_cellargs); + Py_DECREF(__pyx_v_surface); + Py_DECREF(__pyx_v_statistics); + Py_DECREF(__pyx_v_trace_hat); + Py_DECREF(__pyx_v_iterations); + Py_DECREF(__pyx_v_cell); + Py_DECREF(__pyx_v_self); + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + return __pyx_r; +} + static PyObject *__pyx_n_join; +static PyObject *__pyx_k18p; +static PyObject *__pyx_k19p; static PyObject *__pyx_k20p; static PyObject *__pyx_k21p; static PyObject *__pyx_k22p; static PyObject *__pyx_k23p; static PyObject *__pyx_k24p; -static PyObject *__pyx_k25p; -static PyObject *__pyx_k26p; -static char (__pyx_k20[]) = "Control :"; -static char (__pyx_k21[]) = "Surface type : %s"; -static char (__pyx_k22[]) = "Statistics : %s"; -static char (__pyx_k23[]) = "Trace estimation : %s"; -static char (__pyx_k24[]) = "Cell size : %s"; -static char (__pyx_k25[]) = "Nb iterations : %s"; -static char (__pyx_k26[]) = "\n"; +static char (__pyx_k18[]) = "Control :"; +static char (__pyx_k19[]) = "Surface type : %s"; +static char (__pyx_k20[]) = "Statistics : %s"; +static char (__pyx_k21[]) = "Trace estimation : %s"; +static char (__pyx_k22[]) = "Cell size : %s"; +static char (__pyx_k23[]) = "Nb iterations : %s"; +static char (__pyx_k24[]) = "\n"; static PyObject *__pyx_f_6cloess_13loess_control___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_13loess_control___str__(PyObject *__pyx_v_self) { @@ -462,25 +1033,25 @@ Py_INCREF(__pyx_v_self); __pyx_v_strg = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":86 */ - __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k21p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":138 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k19p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} - __pyx_3 = PyNumber_Remainder(__pyx_k22p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k20p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} - __pyx_4 = PyNumber_Remainder(__pyx_k23p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k21p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} - __pyx_5 = PyNumber_Remainder(__pyx_k24p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k22p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} - __pyx_6 = PyNumber_Remainder(__pyx_k25p, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; goto __pyx_L1;} + __pyx_6 = PyNumber_Remainder(__pyx_k23p, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyList_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; goto __pyx_L1;} - Py_INCREF(__pyx_k20p); - PyList_SET_ITEM(__pyx_1, 0, __pyx_k20p); + __pyx_1 = PyList_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;} + Py_INCREF(__pyx_k18p); + PyList_SET_ITEM(__pyx_1, 0, __pyx_k18p); PyList_SET_ITEM(__pyx_1, 1, __pyx_2); PyList_SET_ITEM(__pyx_1, 2, __pyx_3); PyList_SET_ITEM(__pyx_1, 3, __pyx_4); @@ -495,12 +1066,12 @@ __pyx_v_strg = __pyx_1; __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":92 */ - __pyx_2 = PyObject_GetAttr(__pyx_k26p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":144 */ + __pyx_2 = PyObject_GetAttr(__pyx_k24p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;} Py_INCREF(__pyx_v_strg); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -524,525 +1095,608 @@ return __pyx_r; } -static PyObject *__pyx_n_pesudovalues; +static PyObject *__pyx_f_6cloess_11loess_model_4span___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_model_4span___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); -static PyObject *__pyx_k27p; -static PyObject *__pyx_k28p; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":183 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; -static char (__pyx_k27[]) = "DEBUG: Initializing loess_outputs..."; -static char (__pyx_k28[]) = "OK."; + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_model.span.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} -static int __pyx_f_6cloess_13loess_outputs___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_6cloess_13loess_outputs___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_n = 0; - PyObject *__pyx_v_p = 0; - npy_intp (*__pyx_v_rows); - npy_intp (*__pyx_v_cols); +static int __pyx_f_6cloess_11loess_model_4span___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_span); /*proto*/ +static int __pyx_f_6cloess_11loess_model_4span___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_span) { int __pyx_r; + double __pyx_1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_span); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":185 */ + __pyx_1 = PyFloat_AsDouble(__pyx_v_span); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->span = __pyx_1; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + __Pyx_AddTraceback("cloess.loess_model.span.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_span); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_11loess_model_6degree___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_model_6degree___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; PyObject *__pyx_1 = 0; - static char *__pyx_argnames[] = {"n","p",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_n, &__pyx_v_p)) return -1; Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_n); - Py_INCREF(__pyx_v_p); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":106 */ - (__pyx_v_rows[0]) = ((int )__pyx_v_n); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":189 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":107 */ - (__pyx_v_cols[0]) = ((int )__pyx_v_p); + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_model.degree.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":108 */ - if (__Pyx_PrintItem(__pyx_k27p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;} +static PyObject *__pyx_f_6cloess_11loess_model_9normalize___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_model_9normalize___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":110 */ - __pyx_1 = PyArray_EMPTY(1,__pyx_v_rows,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->fitted_values)); - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->fitted_values = ((PyArrayObject *)__pyx_1); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":194 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_bool); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->normalize); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); + __pyx_2 = 0; + __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_2; + __pyx_2 = 0; + goto __pyx_L0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":111 */ - __pyx_1 = PyArray_EMPTY(1,__pyx_v_rows,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->fitted_residuals)); - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->fitted_residuals = ((PyArrayObject *)__pyx_1); - Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_model.normalize.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":112 */ - __pyx_1 = PyArray_EMPTY(1,__pyx_v_rows,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;} - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_pesudovalues, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; +static int __pyx_f_6cloess_11loess_model_9normalize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_normalize); /*proto*/ +static int __pyx_f_6cloess_11loess_model_9normalize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_normalize) { + int __pyx_r; + int __pyx_1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_normalize); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":113 */ - __pyx_1 = PyArray_EMPTY(1,__pyx_v_rows,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->diagonal)); - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->diagonal = ((PyArrayObject *)__pyx_1); - Py_DECREF(__pyx_1); __pyx_1 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":196 */ + __pyx_1 = PyInt_AsLong(__pyx_v_normalize); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->normalize = __pyx_1; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":114 */ - __pyx_1 = PyArray_EMPTY(1,__pyx_v_rows,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->robust)); - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->robust = ((PyArrayObject *)__pyx_1); - Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + __Pyx_AddTraceback("cloess.loess_model.normalize.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_normalize); + return __pyx_r; +} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":115 */ - __pyx_1 = PyArray_EMPTY(1,__pyx_v_cols,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->divisor)); - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->divisor = ((PyArrayObject *)__pyx_1); - Py_DECREF(__pyx_1); __pyx_1 = 0; +static PyObject *__pyx_f_6cloess_11loess_model_6family___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_model_6family___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":117 */ - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.fitted_values = ((double (*))((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->fitted_values->data); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":200 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":118 */ - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.fitted_residuals = ((double (*))((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->fitted_residuals->data); + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_model.family.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":119 */ - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.pseudovalues = ((double (*))((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->pseudovalues->data); +static PyObject *__pyx_f_6cloess_11loess_model_16parametric_flags___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_model_16parametric_flags___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":120 */ - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.diagonal = ((double (*))((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->diagonal->data); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":204 */ + __pyx_1 = PyInt_FromLong(8); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_boolarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->parametric); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":121 */ - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.robust = ((double (*))((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->robust->data); + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_model.parametric_flags.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":122 */ - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.divisor = ((double (*))((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->divisor->data); +static PyObject *__pyx_n_NPY_LONG; +static PyObject *__pyx_n_max; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":124 */ - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->enp = 0; - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.enp = 0; +static int __pyx_f_6cloess_11loess_model_16parametric_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_paramf); /*proto*/ +static int __pyx_f_6cloess_11loess_model_16parametric_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_paramf) { + PyArrayObject *__pyx_v_p_ndr; + long (*__pyx_v_p_dat); + int __pyx_v_i; + int __pyx_r; + PyObject *__pyx_1 = 0; + enum NPY_TYPES __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + PyObject *__pyx_7 = 0; + int __pyx_8; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_paramf); + __pyx_v_p_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":125 */ - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->s = 0; - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.s = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":209 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_NPY_LONG); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;} + __pyx_2 = ((enum NPY_TYPES )PyInt_AsLong(__pyx_1)); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyArray_FROMANY(__pyx_v_paramf,__pyx_2,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)__pyx_v_p_ndr)); + __pyx_v_p_ndr = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":126 */ - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->one_delta = 0; - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.one_delta = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":210 */ + __pyx_v_p_dat = ((long (*))__pyx_v_p_ndr->data); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":127 */ - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->two_delta = 0; - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.two_delta = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":211 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + __pyx_8 = __pyx_8 <= 0; + if (__pyx_8) { + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_max); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + __pyx_5 = PyInt_FromLong(8); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_7, 0, __pyx_5); + PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6); + __pyx_5 = 0; + __pyx_6 = 0; + __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_7); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_7); __pyx_7 = 0; + if (PyObject_Cmp(__pyx_3, __pyx_5, &__pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + __pyx_8 = __pyx_8 < 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + } + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_6 = PyInt_FromLong(__pyx_8); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + __pyx_4 = PyObject_GetIter(__pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + for (;;) { + __pyx_7 = PyIter_Next(__pyx_4); + if (!__pyx_7) { + if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + break; + } + __pyx_8 = PyInt_AsLong(__pyx_7); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + Py_DECREF(__pyx_7); __pyx_7 = 0; + __pyx_v_i = __pyx_8; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":128 */ - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->trace_hat = 0; - ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_outputs.trace_hat = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":212 */ + (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->parametric[__pyx_v_i]) = (__pyx_v_p_dat[__pyx_v_i]); + } + Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":129 */ - if (__Pyx_PrintItem(__pyx_k28p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;} - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;} - __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("cloess.loess_outputs.__init__"); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + Py_XDECREF(__pyx_7); + __Pyx_AddTraceback("cloess.loess_model.parametric_flags.__set__"); __pyx_r = -1; __pyx_L0:; + Py_DECREF(__pyx_v_p_ndr); Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_n); - Py_DECREF(__pyx_v_p); + Py_DECREF(__pyx_v_paramf); return __pyx_r; } -static PyObject *__pyx_n_max; -static PyObject *__pyx_n_NPY_LONG; +static PyObject *__pyx_f_6cloess_11loess_model_17drop_square_flags___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_model_17drop_square_flags___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); -static PyObject *__pyx_k29p; -static PyObject *__pyx_k30p; -static PyObject *__pyx_k31p; -static PyObject *__pyx_k32p; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":216 */ + __pyx_1 = PyInt_FromLong(8); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_boolarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->drop_square); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; -static char (__pyx_k29[]) = "DEBUG: Initializing loess_kdtree..."; -static char (__pyx_k30[]) = "(python side)"; -static char (__pyx_k31[]) = "(C side)"; -static char (__pyx_k32[]) = "OK."; + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_model.drop_square_flags.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} -static int __pyx_f_6cloess_13loess_kd_tree___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_6cloess_13loess_kd_tree___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - long __pyx_v_n; - long __pyx_v_p; - long __pyx_v_maxkd; - long __pyx_v_nval; - long __pyx_v_nvert; - npy_intp (*__pyx_v_nmaxkd); - npy_intp (*__pyx_v_nnval); - npy_intp (*__pyx_v_nnvert); - npy_intp (*__pyx_v_npars); +static int __pyx_f_6cloess_11loess_model_17drop_square_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_drop_sq); /*proto*/ +static int __pyx_f_6cloess_11loess_model_17drop_square_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_drop_sq) { + PyArrayObject *__pyx_v_d_ndr; + long (*__pyx_v_d_dat); + int __pyx_v_i; int __pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; + enum NPY_TYPES __pyx_2; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; - long __pyx_5; - enum NPY_TYPES __pyx_6; - static char *__pyx_argnames[] = {"n","p",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ll", __pyx_argnames, &__pyx_v_n, &__pyx_v_p)) return -1; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + PyObject *__pyx_7 = 0; + int __pyx_8; Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_drop_sq); + __pyx_v_d_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":150 */ - if (__Pyx_PrintItem(__pyx_k29p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":151 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_max); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_n); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(200); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;} - __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2); - PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3); - __pyx_2 = 0; - __pyx_3 = 0; - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":221 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_NPY_LONG); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; goto __pyx_L1;} + __pyx_2 = ((enum NPY_TYPES )PyInt_AsLong(__pyx_1)); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_5 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_v_maxkd = __pyx_5; - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":152 */ - __pyx_v_nvert = (__pyx_v_p * 2); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":153 */ - __pyx_v_nval = ((__pyx_v_p + 1) * __pyx_v_maxkd); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":155 */ - if (__Pyx_PrintItem(__pyx_k30p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; goto __pyx_L1;} - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":156 */ - (__pyx_v_nmaxkd[0]) = ((int )__pyx_v_maxkd); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":157 */ - (__pyx_v_nnvert[0]) = ((int )__pyx_v_nvert); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":158 */ - (__pyx_v_nnval[0]) = ((int )__pyx_v_nval); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":159 */ - (__pyx_v_npars[0]) = ((int )8); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":160 */ - __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_NPY_LONG); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L1;} - __pyx_6 = ((enum NPY_TYPES )PyInt_AsLong(__pyx_3)); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_1 = PyArray_EMPTY(1,__pyx_v_npars,__pyx_6,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L1;} + __pyx_1 = PyArray_FROMANY(__pyx_v_drop_sq,__pyx_2,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; goto __pyx_L1;} Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->parameter)); - ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->parameter = ((PyArrayObject *)__pyx_1); + Py_DECREF(((PyObject *)__pyx_v_d_ndr)); + __pyx_v_d_ndr = ((PyArrayObject *)__pyx_1); Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":161 */ - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_NPY_LONG); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; goto __pyx_L1;} - __pyx_6 = ((enum NPY_TYPES )PyInt_AsLong(__pyx_4)); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_2 = PyArray_EMPTY(1,__pyx_v_nmaxkd,__pyx_6,NPY_ALIGNED); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_2))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->a)); - ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->a = ((PyArrayObject *)__pyx_2); - Py_DECREF(__pyx_2); __pyx_2 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":222 */ + __pyx_v_d_dat = ((long (*))__pyx_v_d_ndr->data); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":162 */ - __pyx_3 = PyArray_EMPTY(1,__pyx_v_nmaxkd,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_3))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->xi)); - ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->xi = ((PyArrayObject *)__pyx_3); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":223 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + __pyx_8 = __pyx_8 <= 0; + if (__pyx_8) { + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_max); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + __pyx_5 = PyInt_FromLong(8); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(((PyObject *)__pyx_v_d_ndr), __pyx_n_size); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_7, 0, __pyx_5); + PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6); + __pyx_5 = 0; + __pyx_6 = 0; + __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_7); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_7); __pyx_7 = 0; + if (PyObject_Cmp(__pyx_3, __pyx_5, &__pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + __pyx_8 = __pyx_8 < 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + } + Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_6 = PyInt_FromLong(__pyx_8); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + __pyx_4 = PyObject_GetIter(__pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + for (;;) { + __pyx_7 = PyIter_Next(__pyx_4); + if (!__pyx_7) { + if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + break; + } + __pyx_8 = PyInt_AsLong(__pyx_7); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + Py_DECREF(__pyx_7); __pyx_7 = 0; + __pyx_v_i = __pyx_8; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":163 */ - __pyx_1 = PyArray_EMPTY(1,__pyx_v_nnvert,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->vert)); - ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->vert = ((PyArrayObject *)__pyx_1); - Py_DECREF(__pyx_1); __pyx_1 = 0; - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":164 */ - __pyx_4 = PyArray_EMPTY(1,__pyx_v_nnval,NPY_DOUBLE,NPY_ALIGNED); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_4))); - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->vval)); - ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->vval = ((PyArrayObject *)__pyx_4); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":224 */ + (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->drop_square[__pyx_v_i]) = (__pyx_v_d_dat[__pyx_v_i]); + } Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":171 */ - if (__Pyx_PrintItem(__pyx_k31p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;} - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":172 */ - ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->_kdtree.parameter = ((long (*))((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->parameter->data); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":173 */ - ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->_kdtree.a = ((long (*))((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->a->data); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":174 */ - ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->_kdtree.xi = ((double (*))((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->xi->data); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":175 */ - ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->_kdtree.vert = ((double (*))((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->vert->data); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":176 */ - ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->_kdtree.vval = ((double (*))((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_v_self)->vval->data); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":187 */ - if (__Pyx_PrintItem(__pyx_k32p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;} - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;} - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":188 */ __pyx_r = 0; goto __pyx_L0; - - __pyx_r = 0; - goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("cloess.loess_kd_tree.__init__"); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + Py_XDECREF(__pyx_7); + __Pyx_AddTraceback("cloess.loess_model.drop_square_flags.__set__"); __pyx_r = -1; __pyx_L0:; + Py_DECREF(__pyx_v_d_ndr); Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_drop_sq); return __pyx_r; } -static PyObject *__pyx_n_hasattr; -static PyObject *__pyx_n___len__; +static PyObject *__pyx_n_family; +static PyObject *__pyx_n_span; +static PyObject *__pyx_n_degree; +static PyObject *__pyx_n_normalize; +static PyObject *__pyx_n_parametric; +static PyObject *__pyx_n_drop_square; +static PyObject *__pyx_n_drop_square_flags; -static PyObject *__pyx_k33p; -static PyObject *__pyx_k36p; -static char (__pyx_k33[]) = "DEBUG: Initializing loess_model..."; -static char (__pyx_k36[]) = "OK."; - -static int __pyx_f_6cloess_11loess_model___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_6cloess_11loess_model___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - double __pyx_v_span; - int __pyx_v_degree; - int __pyx_v_normalize; - PyObject *__pyx_v_parametric_in = 0; - PyObject *__pyx_v_drop_square_in = 0; - PyObject *__pyx_v_family = 0; - int __pyx_v_i; - int __pyx_r; - char (*__pyx_1); +static PyObject *__pyx_f_6cloess_11loess_model_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_model_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_modelargs = 0; + PyObject *__pyx_v_family; + PyObject *__pyx_v_span; + PyObject *__pyx_v_degree; + PyObject *__pyx_v_normalize; + PyObject *__pyx_v_parametric; + PyObject *__pyx_v_drop_square; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - int __pyx_5; - long __pyx_6; - long __pyx_7; - static char *__pyx_argnames[] = {"span","degree","normalize","parametric_in","drop_square_in","family",0}; - __pyx_v_span = __pyx_k3; - __pyx_v_degree = __pyx_k4; - __pyx_v_normalize = __pyx_k5; - __pyx_v_parametric_in = __pyx_k6; - __pyx_v_drop_square_in = __pyx_k7; - __pyx_v_family = __pyx_k9; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|diiOOO", __pyx_argnames, &__pyx_v_span, &__pyx_v_degree, &__pyx_v_normalize, &__pyx_v_parametric_in, &__pyx_v_drop_square_in, &__pyx_v_family)) return -1; + int __pyx_4; + static char *__pyx_argnames[] = {0}; + if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, 0, &__pyx_v_modelargs) < 0) return 0; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) { + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + Py_XDECREF(__pyx_v_modelargs); + return 0; + } Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_parametric_in); - Py_INCREF(__pyx_v_drop_square_in); - Py_INCREF(__pyx_v_family); + __pyx_v_family = Py_None; Py_INCREF(Py_None); + __pyx_v_span = Py_None; Py_INCREF(Py_None); + __pyx_v_degree = Py_None; Py_INCREF(Py_None); + __pyx_v_normalize = Py_None; Py_INCREF(Py_None); + __pyx_v_parametric = Py_None; Py_INCREF(Py_None); + __pyx_v_drop_square = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":208 */ - if (__Pyx_PrintItem(__pyx_k33p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":227 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} + Py_INCREF(__pyx_n_family); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_family); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_family); + __pyx_v_family = __pyx_3; + __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":209 */ - ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->span = __pyx_v_span; - ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.span = __pyx_v_span; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":228 */ + __pyx_4 = __pyx_v_family != Py_None; + if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":210 */ - ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->degree = __pyx_v_degree; - ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.degree = __pyx_v_degree; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":229 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_family, __pyx_v_family) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":211 */ - ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->normalize = __pyx_v_normalize; - ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.normalize = __pyx_v_normalize; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":231 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} + Py_INCREF(__pyx_n_span); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_span); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_span); + __pyx_v_span = __pyx_3; + __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":212 */ - __pyx_1 = PyString_AsString(__pyx_v_family); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; goto __pyx_L1;} - ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->family = __pyx_1; - __pyx_1 = PyString_AsString(__pyx_v_family); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; goto __pyx_L1;} - ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.family = __pyx_1; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":232 */ + __pyx_4 = __pyx_v_span != Py_None; + if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":214 */ - __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":233 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_span, __pyx_v_span) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":235 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;} + Py_INCREF(__pyx_n_degree); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_degree); Py_INCREF(Py_None); - PyList_SET_ITEM(__pyx_2, 0, Py_None); - __pyx_3 = PyInt_FromLong(8); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;} - __pyx_4 = PyNumber_Multiply(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->parametric_flags); - ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->parametric_flags = __pyx_4; - __pyx_4 = 0; + Py_DECREF(__pyx_v_degree); + __pyx_v_degree = __pyx_3; + __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":215 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_hasattr); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;} - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;} - Py_INCREF(__pyx_v_parametric_in); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_parametric_in); - Py_INCREF(__pyx_n___len__); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_n___len__); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (__pyx_5) { + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":236 */ + __pyx_4 = __pyx_v_degree != Py_None; + if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":216 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} - Py_INCREF(__pyx_v_parametric_in); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_parametric_in); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_6 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_6; ++__pyx_v_i) { - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":217 */ - __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;} - __pyx_3 = PyObject_GetItem(__pyx_v_parametric_in, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;} - if (PyObject_SetItem(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->parametric_flags, __pyx_4, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":218 */ - __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;} - __pyx_3 = PyObject_GetItem(__pyx_v_parametric_in, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_7 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.parametric[__pyx_v_i]) = __pyx_7; - } - goto __pyx_L2; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":237 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_degree, __pyx_v_degree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; goto __pyx_L1;} + goto __pyx_L4; } - /*else*/ { + __pyx_L4:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":220 */ - for (__pyx_v_i = 0; __pyx_v_i <= 7; ++__pyx_v_i) { + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":239 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; goto __pyx_L1;} + Py_INCREF(__pyx_n_normalize); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_normalize); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_normalize); + __pyx_v_normalize = __pyx_3; + __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":221 */ - __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; goto __pyx_L1;} - if (PyObject_SetItem(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->parametric_flags, __pyx_4, __pyx_v_parametric_in) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":240 */ + __pyx_4 = __pyx_v_normalize != Py_None; + if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":222 */ - __pyx_7 = PyInt_AsLong(__pyx_v_parametric_in); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; goto __pyx_L1;} - (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.parametric[__pyx_v_i]) = __pyx_7; - } + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":241 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_normalize, __pyx_v_normalize) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; goto __pyx_L1;} + goto __pyx_L5; } - __pyx_L2:; + __pyx_L5:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":224 */ - __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":243 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} + Py_INCREF(__pyx_n_parametric); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_parametric); Py_INCREF(Py_None); - PyList_SET_ITEM(__pyx_2, 0, Py_None); - __pyx_3 = PyInt_FromLong(8); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;} - __pyx_4 = PyNumber_Multiply(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->drop_square_flags); - ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->drop_square_flags = __pyx_4; - __pyx_4 = 0; + Py_DECREF(__pyx_v_parametric); + __pyx_v_parametric = __pyx_3; + __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":225 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_hasattr); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} - Py_INCREF(__pyx_v_drop_square_in); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_drop_square_in); - Py_INCREF(__pyx_n___len__); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_n___len__); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (__pyx_5) { + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":244 */ + __pyx_4 = __pyx_v_parametric != Py_None; + if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":226 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} - Py_INCREF(__pyx_v_drop_square_in); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_drop_square_in); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_6 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_6; ++__pyx_v_i) { - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":227 */ - __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} - __pyx_3 = PyObject_GetItem(__pyx_v_drop_square_in, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} - if (PyObject_SetItem(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->drop_square_flags, __pyx_4, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":228 */ - __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;} - __pyx_3 = PyObject_GetItem(__pyx_v_drop_square_in, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_7 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.drop_square[__pyx_v_i]) = __pyx_7; - } - goto __pyx_L7; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":245 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_parametric) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;} + goto __pyx_L6; } - /*else*/ { + __pyx_L6:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":230 */ - for (__pyx_v_i = 0; __pyx_v_i < 8; ++__pyx_v_i) { + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":247 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;} + Py_INCREF(__pyx_n_drop_square); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_drop_square); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_drop_square); + __pyx_v_drop_square = __pyx_3; + __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":231 */ - __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} - if (PyObject_SetItem(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->drop_square_flags, __pyx_4, __pyx_v_drop_square_in) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":248 */ + __pyx_4 = __pyx_v_drop_square != Py_None; + if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":232 */ - __pyx_7 = PyInt_AsLong(__pyx_v_drop_square_in); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;} - (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.drop_square[__pyx_v_i]) = __pyx_7; - } + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":249 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_drop_square_flags, __pyx_v_drop_square) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} + goto __pyx_L7; } __pyx_L7:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":233 */ - if (__Pyx_PrintItem(__pyx_k36p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;} - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;} - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":246 */ - __pyx_r = 0; + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; - - __pyx_r = 0; - goto __pyx_L0; __pyx_L1:; + Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("cloess.loess_model.__init__"); - __pyx_r = -1; + __Pyx_AddTraceback("cloess.loess_model.update"); + __pyx_r = 0; __pyx_L0:; + Py_XDECREF(__pyx_v_modelargs); + Py_DECREF(__pyx_v_family); + Py_DECREF(__pyx_v_span); + Py_DECREF(__pyx_v_degree); + Py_DECREF(__pyx_v_normalize); + Py_DECREF(__pyx_v_parametric); + Py_DECREF(__pyx_v_drop_square); Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_parametric_in); - Py_DECREF(__pyx_v_drop_square_in); - Py_DECREF(__pyx_v_family); + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); return __pyx_r; } static PyObject *__pyx_n_id; -static PyObject *__pyx_k37p; +static PyObject *__pyx_k31p; -static char (__pyx_k37[]) = "loess model parameters @%s"; +static char (__pyx_k31[]) = "loess model parameters @%s"; static PyObject *__pyx_f_6cloess_11loess_model___repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_11loess_model___repr__(PyObject *__pyx_v_self) { @@ -1052,15 +1706,15 @@ PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":249 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":252 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} Py_INCREF(__pyx_v_self); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyNumber_Remainder(__pyx_k37p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k31p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_1; __pyx_1 = 0; @@ -1079,27 +1733,23 @@ return __pyx_r; } -static PyObject *__pyx_n___name__; -static PyObject *__pyx_n_parametric; -static PyObject *__pyx_n_drop_square; - +static PyObject *__pyx_k32p; +static PyObject *__pyx_k33p; +static PyObject *__pyx_k34p; +static PyObject *__pyx_k35p; +static PyObject *__pyx_k36p; +static PyObject *__pyx_k37p; static PyObject *__pyx_k38p; static PyObject *__pyx_k39p; -static PyObject *__pyx_k40p; -static PyObject *__pyx_k41p; -static PyObject *__pyx_k42p; -static PyObject *__pyx_k43p; -static PyObject *__pyx_k44p; -static PyObject *__pyx_k45p; -static char (__pyx_k38[]) = "Object : %s"; -static char (__pyx_k39[]) = "family : %s"; -static char (__pyx_k40[]) = "span : %s"; -static char (__pyx_k41[]) = "degree : %s"; -static char (__pyx_k42[]) = "normalized : %s"; -static char (__pyx_k43[]) = "parametric : %s"; -static char (__pyx_k44[]) = "drop_square : %s"; -static char (__pyx_k45[]) = "\n"; +static char (__pyx_k32[]) = "Model parameters....."; +static char (__pyx_k33[]) = "family : %s"; +static char (__pyx_k34[]) = "span : %s"; +static char (__pyx_k35[]) = "degree : %s"; +static char (__pyx_k36[]) = "normalized : %s"; +static char (__pyx_k37[]) = "parametric : %s"; +static char (__pyx_k38[]) = "drop_square : %s"; +static char (__pyx_k39[]) = "\n"; static PyObject *__pyx_f_6cloess_11loess_model___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_11loess_model___str__(PyObject *__pyx_v_self) { @@ -1112,57 +1762,57 @@ PyObject *__pyx_5 = 0; PyObject *__pyx_6 = 0; PyObject *__pyx_7 = 0; - PyObject *__pyx_8 = 0; Py_INCREF(__pyx_v_self); __pyx_v_strg = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":251 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___name__); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k38p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":255 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k33p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} - __pyx_3 = PyNumber_Remainder(__pyx_k39p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k34p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;} - __pyx_4 = PyNumber_Remainder(__pyx_k40p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k35p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;} - __pyx_5 = PyNumber_Remainder(__pyx_k41p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_normalize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k36p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_model.normalize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;} - __pyx_6 = PyNumber_Remainder(__pyx_k42p, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_parametric_flags); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;} + __pyx_6 = PySequence_GetSlice(__pyx_1, 0, ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_parametric); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;} - __pyx_7 = PyNumber_Remainder(__pyx_k43p, __pyx_1); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_drop_square); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;} - __pyx_8 = PyNumber_Remainder(__pyx_k44p, __pyx_1); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyList_New(7); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} - PyList_SET_ITEM(__pyx_1, 0, __pyx_2); - PyList_SET_ITEM(__pyx_1, 1, __pyx_3); - PyList_SET_ITEM(__pyx_1, 2, __pyx_4); - PyList_SET_ITEM(__pyx_1, 3, __pyx_5); - PyList_SET_ITEM(__pyx_1, 4, __pyx_6); - PyList_SET_ITEM(__pyx_1, 5, __pyx_7); - PyList_SET_ITEM(__pyx_1, 6, __pyx_8); + __pyx_1 = PyNumber_Remainder(__pyx_k37p, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_drop_square_flags); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;} + __pyx_7 = PySequence_GetSlice(__pyx_6, 0, ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_6 = PyNumber_Remainder(__pyx_k38p, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;} + Py_DECREF(__pyx_7); __pyx_7 = 0; + __pyx_7 = PyList_New(7); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;} + Py_INCREF(__pyx_k32p); + PyList_SET_ITEM(__pyx_7, 0, __pyx_k32p); + PyList_SET_ITEM(__pyx_7, 1, __pyx_2); + PyList_SET_ITEM(__pyx_7, 2, __pyx_3); + PyList_SET_ITEM(__pyx_7, 3, __pyx_4); + PyList_SET_ITEM(__pyx_7, 4, __pyx_5); + PyList_SET_ITEM(__pyx_7, 5, __pyx_1); + PyList_SET_ITEM(__pyx_7, 6, __pyx_6); __pyx_2 = 0; __pyx_3 = 0; __pyx_4 = 0; __pyx_5 = 0; + __pyx_1 = 0; __pyx_6 = 0; + Py_DECREF(__pyx_v_strg); + __pyx_v_strg = __pyx_7; __pyx_7 = 0; - __pyx_8 = 0; - Py_DECREF(__pyx_v_strg); - __pyx_v_strg = __pyx_1; - __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":258 */ - __pyx_2 = PyObject_GetAttr(__pyx_k45p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":263 */ + __pyx_2 = PyObject_GetAttr(__pyx_k39p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; goto __pyx_L1;} Py_INCREF(__pyx_v_strg); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -1179,7 +1829,6 @@ Py_XDECREF(__pyx_5); Py_XDECREF(__pyx_6); Py_XDECREF(__pyx_7); - Py_XDECREF(__pyx_8); __Pyx_AddTraceback("cloess.loess_model.__str__"); __pyx_r = 0; __pyx_L0:; @@ -1188,113 +1837,808 @@ return __pyx_r; } -static PyObject *__pyx_k46p; +static PyObject *__pyx_f_6cloess_13loess_outputs_13fitted_values___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_outputs_13fitted_values___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); -static char (__pyx_k46[]) = "DEBUG:Initializing loess_cside"; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":274 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->fitted_values); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_outputs.fitted_values.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_13loess_outputs_16fitted_residuals___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_outputs_16fitted_residuals___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":278 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->fitted_residuals); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_outputs.fitted_residuals.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_13loess_outputs_12pseudovalues___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_outputs_12pseudovalues___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":282 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->pseudovalues); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_outputs.pseudovalues.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_13loess_outputs_8diagonal___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_outputs_8diagonal___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":286 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->diagonal); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_outputs.diagonal.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_13loess_outputs_6robust___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_outputs_6robust___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":290 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->robust); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_outputs.robust.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_13loess_outputs_7divisor___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_outputs_7divisor___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":294 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->divisor); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_outputs.divisor.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_13loess_outputs_3enp___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_outputs_3enp___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":299 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_outputs.enp.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_13loess_outputs_1s___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_outputs_1s___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":304 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_outputs.s.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_13loess_outputs_9one_delta___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_outputs_9one_delta___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":309 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_outputs.one_delta.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_13loess_outputs_9two_delta___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_outputs_9two_delta___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":314 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->two_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_outputs.two_delta.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_13loess_outputs_9trace_hat___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_outputs_9trace_hat___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":319 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_outputs.trace_hat.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_11loess_anova_3dfn___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_anova_3dfn___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":339 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->dfn); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_anova.dfn.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_11loess_anova_3dfd___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_anova_3dfd___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":343 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->dfd); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_anova.dfd.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_11loess_anova_7F_value___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_anova_7F_value___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":347 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->F_value); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_anova.F_value.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_11loess_anova_4Pr_F___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_anova_4Pr_F___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":351 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->Pr_F); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_anova.Pr_F.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_pw_free_mem; + +static void __pyx_f_6cloess_19confidence_interval___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_f_6cloess_19confidence_interval___dealloc__(PyObject *__pyx_v_self) { + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":361 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_c_loess); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_pw_free_mem); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;} + Py_INCREF(__pyx_v_self); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self); + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.confidence_interval.__dealloc__"); + __pyx_L0:; + Py_DECREF(__pyx_v_self); +} + +static PyObject *__pyx_n_nest; + +static PyObject *__pyx_f_6cloess_19confidence_interval_3fit___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_19confidence_interval_3fit___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":365 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_confidence_interval *)__pyx_v_self)->_base->fit); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.confidence_interval.fit.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_19confidence_interval_5upper___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_19confidence_interval_5upper___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":369 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_confidence_interval *)__pyx_v_self)->_base->upper); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.confidence_interval.upper.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_19confidence_interval_5lower___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_19confidence_interval_5lower___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":373 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_confidence_interval *)__pyx_v_self)->_base->lower); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.confidence_interval.lower.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static void __pyx_f_6cloess_15loess_predicted___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_f_6cloess_15loess_predicted___dealloc__(PyObject *__pyx_v_self) { + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":384 */ + pred_free_mem(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base); + + Py_DECREF(__pyx_v_self); +} + +static PyObject *__pyx_f_6cloess_15loess_predicted_9predicted___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_15loess_predicted_9predicted___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":388 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base->fit); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_predicted.predicted.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_15loess_predicted_16predicted_stderr___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_15loess_predicted_16predicted_stderr___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":392 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;} + __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base->se_fit); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_predicted.predicted_stderr.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_residual_scale; + +static PyObject *__pyx_f_6cloess_15loess_predicted_14residual_scale___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_15loess_predicted_14residual_scale___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":396 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_predicted.residual_scale.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_df; + +static PyObject *__pyx_f_6cloess_15loess_predicted_2df___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_15loess_predicted_2df___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":400 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess_predicted.df.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_15loess_predicted_confidence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6cloess_15loess_predicted_confidence[] = "\n coverage : float\n Confidence level of the confidence intervals limits as a fraction.\n "; +static PyObject *__pyx_f_6cloess_15loess_predicted_confidence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_coverage = 0; + PyObject *__pyx_r; + double __pyx_1; + static char *__pyx_argnames[] = {"coverage",0}; + __pyx_v_coverage = __pyx_k7; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_coverage)) return 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_coverage); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":407 */ + __pyx_1 = PyFloat_AsDouble(__pyx_v_coverage); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;} + pointwise(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest,__pyx_1,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->conf_interval->_base); + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + __Pyx_AddTraceback("cloess.loess_predicted.confidence"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_coverage); + return __pyx_r; +} + +static PyObject *__pyx_n_len; + static int __pyx_f_6cloess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_f_6cloess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_x = 0; PyObject *__pyx_v_y = 0; PyObject *__pyx_v_weights = 0; - long __pyx_v_n; - long __pyx_v_p; + PyArrayObject *__pyx_v_x_ndr; + PyArrayObject *__pyx_v_y_ndr; + double (*__pyx_v_x_dat); + double (*__pyx_v_y_dat); + PyObject *__pyx_v_n; + PyObject *__pyx_v_p; int __pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; + long __pyx_4; + long __pyx_5; static char *__pyx_argnames[] = {"x","y","weights",0}; - __pyx_v_weights = __pyx_k10; + __pyx_v_weights = __pyx_k8; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_weights)) return -1; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_x); Py_INCREF(__pyx_v_y); Py_INCREF(__pyx_v_weights); + __pyx_v_x_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + __pyx_v_y_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + __pyx_v_n = Py_None; Py_INCREF(Py_None); + __pyx_v_p = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":285 */ - __pyx_1 = PyTuple_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; goto __pyx_L1;} - Py_INCREF(__pyx_v_x); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_x); - Py_INCREF(__pyx_v_y); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_y); - Py_INCREF(__pyx_v_weights); - PyTuple_SET_ITEM(__pyx_1, 2, __pyx_v_weights); - __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_inputs), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":429 */ + __pyx_1 = PyArray_FROMANY(__pyx_v_x,NPY_DOUBLE,1,1,NPY_FORTRAN); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)__pyx_v_x_ndr)); + __pyx_v_x_ndr = ((PyArrayObject *)__pyx_1); Py_DECREF(__pyx_1); __pyx_1 = 0; - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_inputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; goto __pyx_L1;} - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs)); - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs = ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_2); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":430 */ + __pyx_1 = PyArray_FROMANY(__pyx_v_y,NPY_DOUBLE,1,1,NPY_FORTRAN); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)__pyx_v_y_ndr)); + __pyx_v_y_ndr = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":431 */ + __pyx_v_x_dat = ((double (*))__pyx_v_x_ndr->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":432 */ + __pyx_v_y_dat = ((double (*))__pyx_v_y_ndr->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":433 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_v_x_ndr)); + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_x_ndr)); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_n); + __pyx_v_n = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":434 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_x_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; goto __pyx_L1;} + __pyx_2 = PyNumber_Divide(__pyx_1, __pyx_v_n); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_v_p); + __pyx_v_p = __pyx_2; __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":286 */ - __pyx_v_n = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs->nobs; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":435 */ + __pyx_4 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} + __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} + loess_setup(__pyx_v_x_dat,__pyx_v_y_dat,__pyx_4,__pyx_5,(&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base)); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":287 */ - __pyx_v_p = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs->nvar; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":437 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_inputs), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6cloess_loess_inputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs)); + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs = ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_3); + __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":288 */ - __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_model), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_6cloess_loess_model)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":438 */ + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.inputs); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":440 */ + __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_model), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_6cloess_loess_model)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model)); ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model = ((struct __pyx_obj_6cloess_loess_model *)__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":289 */ - __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_control), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_control)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":441 */ + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.model); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":442 */ + __pyx_4 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model->npar = __pyx_4; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":444 */ + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_control), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_control)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control)); ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control = ((struct __pyx_obj_6cloess_loess_control *)__pyx_2); __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":290 */ - __pyx_1 = PyInt_FromLong(__pyx_v_n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); - __pyx_1 = 0; - __pyx_2 = 0; - __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_outputs), __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_6cloess_loess_outputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs)); - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs = ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_1); - __pyx_1 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":445 */ + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.control); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":291 */ - __pyx_2 = PyInt_FromLong(__pyx_v_n); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(__pyx_v_p); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;} - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3); - __pyx_2 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":447 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_kd_tree), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6cloess_loess_kd_tree)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree)); + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree = ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_3); __pyx_3 = 0; - __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_kd_tree), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_kd_tree)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;} - Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree)); - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree = ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_2); - __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":293 */ - if (__Pyx_PrintItem(__pyx_k46p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;} - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":448 */ + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.kd_tree); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":294 */ - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.inputs = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs->_inputs; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":450 */ + __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_outputs), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_6cloess_loess_outputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs)); + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs = ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_1); + __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":295 */ - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.model = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model->_model; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":451 */ + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.outputs); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":296 */ - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.control = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control->_control; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":452 */ + __pyx_5 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->nobs = __pyx_5; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":297 */ - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.kd_tree = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree->_kdtree; - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":298 */ - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.outputs = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->_outputs; - __pyx_r = 0; goto __pyx_L0; __pyx_L1:; @@ -1304,6 +2648,10 @@ __Pyx_AddTraceback("cloess.loess.__init__"); __pyx_r = -1; __pyx_L0:; + Py_DECREF(__pyx_v_x_ndr); + Py_DECREF(__pyx_v_y_ndr); + Py_DECREF(__pyx_v_n); + Py_DECREF(__pyx_v_p); Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_x); Py_DECREF(__pyx_v_y); @@ -1311,19 +2659,41 @@ return __pyx_r; } -static PyObject *__pyx_n_n; +static PyObject *__pyx_f_6cloess_5loess_fit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6cloess_5loess_fit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_r; + static char *__pyx_argnames[] = {0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; + Py_INCREF(__pyx_v_self); -static PyObject *__pyx_k47p; -static PyObject *__pyx_k48p; -static PyObject *__pyx_k50p; -static PyObject *__pyx_k51p; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":455 */ + loess_fit((&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base)); -static char (__pyx_k47[]) = "Number of Observations : %d"; -static char (__pyx_k48[]) = "Equivalent Number of Parameters: %.1f"; -static char (__pyx_k49[]) = "gaussian"; -static char (__pyx_k50[]) = "Residual Standard Error : %.4f"; -static char (__pyx_k51[]) = "Residual Scale Estimate : %.4f"; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":456 */ + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_nobs; +static PyObject *__pyx_n_enp; +static PyObject *__pyx_n_gaussian; +static PyObject *__pyx_n_s; + +static PyObject *__pyx_k40p; +static PyObject *__pyx_k41p; +static PyObject *__pyx_k43p; +static PyObject *__pyx_k44p; + +static char (__pyx_k40[]) = "Number of Observations : %d"; +static char (__pyx_k41[]) = "Equivalent Number of Parameters: %.1f"; +static char (__pyx_k43[]) = "Residual Standard Error : %.4f"; +static char (__pyx_k44[]) = "Residual Scale Estimate : %.4f"; + static PyObject *__pyx_f_6cloess_5loess_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6cloess_5loess_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_r; @@ -1334,44 +2704,47 @@ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":310 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs), __pyx_n_n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k47p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":459 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs), __pyx_n_nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k40p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":311 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k48p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":460 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k41p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; goto __pyx_L1;} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":312 */ - __pyx_3 = (((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model->family == __pyx_k49); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":461 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model), __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_n_gaussian, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; goto __pyx_L1;} + __pyx_3 = __pyx_3 == 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_3) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":313 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k50p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":462 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k43p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} goto __pyx_L2; } /*else*/ { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":315 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k51p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":464 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k44p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; goto __pyx_L1;} } __pyx_L2:; @@ -1387,124 +2760,206 @@ return __pyx_r; } +static PyObject *__pyx_n_nvar; + +static PyObject *__pyx_f_6cloess_5loess_predict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6cloess_5loess_predict[] = "\n newdata: ndarray\n A (m,p) ndarray specifying the values of the predictors at which the \n evaluation is to be carried out.\n stderr: Boolean\n Logical flag for computing standard errors at newdata.\n "; +static PyObject *__pyx_f_6cloess_5loess_predict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_newdata = 0; + PyObject *__pyx_v_stderr = 0; + PyArrayObject *__pyx_v_p_ndr; + double (*__pyx_v_p_dat); + int __pyx_v_m; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + static char *__pyx_argnames[] = {"newdata","stderr",0}; + __pyx_v_stderr = __pyx_k9; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_newdata, &__pyx_v_stderr)) return 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_newdata); + Py_INCREF(__pyx_v_stderr); + __pyx_v_p_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":478 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_nvar); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} + __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyArray_FROMANY(__pyx_v_newdata,NPY_DOUBLE,1,__pyx_2,NPY_FORTRAN); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)__pyx_v_p_ndr)); + __pyx_v_p_ndr = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":479 */ + __pyx_v_p_dat = ((double (*))__pyx_v_p_ndr->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":480 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_v_p_ndr)); + PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_p_ndr)); + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_2 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_v_m = __pyx_2; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":481 */ + __pyx_2 = PyInt_AsLong(__pyx_v_stderr); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; goto __pyx_L1;} + predict(__pyx_v_p_dat,__pyx_v_m,(&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base),((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted->_base,__pyx_2); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":482 */ + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted->nest = __pyx_v_m; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("cloess.loess.predict"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_p_ndr); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_newdata); + Py_DECREF(__pyx_v_stderr); + return __pyx_r; +} + static __Pyx_InternTabEntry __pyx_intern_tab[] = { {&__pyx_n_False, "False"}, {&__pyx_n_NPY_LONG, "NPY_LONG"}, {&__pyx_n_ValueError, "ValueError"}, - {&__pyx_n__N, "_N"}, - {&__pyx_n___len__, "__len__"}, - {&__pyx_n___name__, "__name__"}, + {&__pyx_n_astype, "astype"}, + {&__pyx_n_bool, "bool"}, {&__pyx_n_c_loess, "c_loess"}, {&__pyx_n_c_numpy, "c_numpy"}, {&__pyx_n_c_python, "c_python"}, + {&__pyx_n_cell, "cell"}, + {&__pyx_n_degree, "degree"}, + {&__pyx_n_df, "df"}, {&__pyx_n_drop_square, "drop_square"}, + {&__pyx_n_drop_square_flags, "drop_square_flags"}, + {&__pyx_n_dtype, "dtype"}, + {&__pyx_n_empty, "empty"}, + {&__pyx_n_enp, "enp"}, + {&__pyx_n_family, "family"}, + {&__pyx_n_float, "float"}, {&__pyx_n_gaussian, "gaussian"}, - {&__pyx_n_hasattr, "hasattr"}, + {&__pyx_n_get, "get"}, {&__pyx_n_id, "id"}, + {&__pyx_n_int, "int"}, + {&__pyx_n_iterations, "iterations"}, {&__pyx_n_join, "join"}, {&__pyx_n_len, "len"}, {&__pyx_n_max, "max"}, - {&__pyx_n_n, "n"}, {&__pyx_n_ndim, "ndim"}, + {&__pyx_n_nest, "nest"}, + {&__pyx_n_nobs, "nobs"}, + {&__pyx_n_normalize, "normalize"}, {&__pyx_n_numpy, "numpy"}, + {&__pyx_n_nvar, "nvar"}, {&__pyx_n_parametric, "parametric"}, - {&__pyx_n_pesudovalues, "pesudovalues"}, + {&__pyx_n_parametric_flags, "parametric_flags"}, + {&__pyx_n_pw_free_mem, "pw_free_mem"}, + {&__pyx_n_residual_scale, "residual_scale"}, + {&__pyx_n_s, "s"}, + {&__pyx_n_shape, "shape"}, {&__pyx_n_size, "size"}, + {&__pyx_n_span, "span"}, + {&__pyx_n_statistics, "statistics"}, + {&__pyx_n_surface, "surface"}, + {&__pyx_n_trace_hat, "trace_hat"}, {0, 0} }; static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_k11p, __pyx_k11, sizeof(__pyx_k11)}, {&__pyx_k12p, __pyx_k12, sizeof(__pyx_k12)}, - {&__pyx_k13p, __pyx_k13, sizeof(__pyx_k13)}, - {&__pyx_k14p, __pyx_k14, sizeof(__pyx_k14)}, - {&__pyx_k15p, __pyx_k15, sizeof(__pyx_k15)}, + {&__pyx_k18p, __pyx_k18, sizeof(__pyx_k18)}, {&__pyx_k19p, __pyx_k19, sizeof(__pyx_k19)}, {&__pyx_k20p, __pyx_k20, sizeof(__pyx_k20)}, {&__pyx_k21p, __pyx_k21, sizeof(__pyx_k21)}, {&__pyx_k22p, __pyx_k22, sizeof(__pyx_k22)}, {&__pyx_k23p, __pyx_k23, sizeof(__pyx_k23)}, {&__pyx_k24p, __pyx_k24, sizeof(__pyx_k24)}, - {&__pyx_k25p, __pyx_k25, sizeof(__pyx_k25)}, - {&__pyx_k26p, __pyx_k26, sizeof(__pyx_k26)}, - {&__pyx_k27p, __pyx_k27, sizeof(__pyx_k27)}, - {&__pyx_k28p, __pyx_k28, sizeof(__pyx_k28)}, - {&__pyx_k29p, __pyx_k29, sizeof(__pyx_k29)}, - {&__pyx_k30p, __pyx_k30, sizeof(__pyx_k30)}, {&__pyx_k31p, __pyx_k31, sizeof(__pyx_k31)}, {&__pyx_k32p, __pyx_k32, sizeof(__pyx_k32)}, {&__pyx_k33p, __pyx_k33, sizeof(__pyx_k33)}, + {&__pyx_k34p, __pyx_k34, sizeof(__pyx_k34)}, + {&__pyx_k35p, __pyx_k35, sizeof(__pyx_k35)}, {&__pyx_k36p, __pyx_k36, sizeof(__pyx_k36)}, {&__pyx_k37p, __pyx_k37, sizeof(__pyx_k37)}, {&__pyx_k38p, __pyx_k38, sizeof(__pyx_k38)}, {&__pyx_k39p, __pyx_k39, sizeof(__pyx_k39)}, {&__pyx_k40p, __pyx_k40, sizeof(__pyx_k40)}, {&__pyx_k41p, __pyx_k41, sizeof(__pyx_k41)}, - {&__pyx_k42p, __pyx_k42, sizeof(__pyx_k42)}, {&__pyx_k43p, __pyx_k43, sizeof(__pyx_k43)}, {&__pyx_k44p, __pyx_k44, sizeof(__pyx_k44)}, - {&__pyx_k45p, __pyx_k45, sizeof(__pyx_k45)}, - {&__pyx_k46p, __pyx_k46, sizeof(__pyx_k46)}, - {&__pyx_k47p, __pyx_k47, sizeof(__pyx_k47)}, - {&__pyx_k48p, __pyx_k48, sizeof(__pyx_k48)}, - {&__pyx_k50p, __pyx_k50, sizeof(__pyx_k50)}, - {&__pyx_k51p, __pyx_k51, sizeof(__pyx_k51)}, {0, 0, 0} }; static PyObject *__pyx_tp_new_6cloess_loess_inputs(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); - struct __pyx_obj_6cloess_loess_inputs *p = (struct __pyx_obj_6cloess_loess_inputs *)o; - p->x = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - p->y = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - p->weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6cloess_loess_inputs(PyObject *o) { - struct __pyx_obj_6cloess_loess_inputs *p = (struct __pyx_obj_6cloess_loess_inputs *)o; - Py_XDECREF(((PyObject *)p->x)); - Py_XDECREF(((PyObject *)p->y)); - Py_XDECREF(((PyObject *)p->weights)); (*o->ob_type->tp_free)(o); } static int __pyx_tp_traverse_6cloess_loess_inputs(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_6cloess_loess_inputs *p = (struct __pyx_obj_6cloess_loess_inputs *)o; - if (p->x) { - e = (*v)(((PyObject*)p->x), a); if (e) return e; - } - if (p->y) { - e = (*v)(((PyObject*)p->y), a); if (e) return e; - } - if (p->weights) { - e = (*v)(((PyObject*)p->weights), a); if (e) return e; - } return 0; } static int __pyx_tp_clear_6cloess_loess_inputs(PyObject *o) { - struct __pyx_obj_6cloess_loess_inputs *p = (struct __pyx_obj_6cloess_loess_inputs *)o; - Py_XDECREF(((PyObject *)p->x)); - p->x = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(((PyObject *)p->y)); - p->y = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(((PyObject *)p->weights)); - p->weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); return 0; } +static PyObject *__pyx_getprop_6cloess_12loess_inputs_x(PyObject *o, void *x) { + return __pyx_f_6cloess_12loess_inputs_1x___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_12loess_inputs_y(PyObject *o, void *x) { + return __pyx_f_6cloess_12loess_inputs_1y___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_12loess_inputs_weights(PyObject *o, void *x) { + return __pyx_f_6cloess_12loess_inputs_7weights___get__(o); +} + +static int __pyx_setprop_6cloess_12loess_inputs_weights(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6cloess_12loess_inputs_7weights___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6cloess_12loess_inputs_nobs(PyObject *o, void *x) { + return __pyx_f_6cloess_12loess_inputs_4nobs___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_12loess_inputs_nvar(PyObject *o, void *x) { + return __pyx_f_6cloess_12loess_inputs_4nvar___get__(o); +} + static struct PyMethodDef __pyx_methods_6cloess_loess_inputs[] = { {0, 0, 0, 0} }; -static struct PyMemberDef __pyx_members_6cloess_loess_inputs[] = { - {"nobs", T_LONG, offsetof(struct __pyx_obj_6cloess_loess_inputs, nobs), 0, 0}, - {"nvar", T_LONG, offsetof(struct __pyx_obj_6cloess_loess_inputs, nvar), 0, 0}, - {"x", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess_inputs, x), READONLY, 0}, - {"y", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess_inputs, y), READONLY, 0}, - {"weights", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess_inputs, weights), READONLY, 0}, +static struct PyGetSetDef __pyx_getsets_6cloess_loess_inputs[] = { + {"x", __pyx_getprop_6cloess_12loess_inputs_x, 0, 0, 0}, + {"y", __pyx_getprop_6cloess_12loess_inputs_y, 0, 0, 0}, + {"weights", __pyx_getprop_6cloess_12loess_inputs_weights, __pyx_setprop_6cloess_12loess_inputs_weights, __pyx_k1, 0}, + {"nobs", __pyx_getprop_6cloess_12loess_inputs_nobs, 0, __pyx_k2, 0}, + {"nvar", __pyx_getprop_6cloess_12loess_inputs_nvar, 0, __pyx_k3, 0}, {0, 0, 0, 0, 0} }; @@ -1605,14 +3060,14 @@ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6cloess_loess_inputs, /*tp_methods*/ - __pyx_members_6cloess_loess_inputs, /*tp_members*/ - 0, /*tp_getset*/ + 0, /*tp_members*/ + __pyx_getsets_6cloess_loess_inputs, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - __pyx_f_6cloess_12loess_inputs___init__, /*tp_init*/ + 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6cloess_loess_inputs, /*tp_new*/ 0, /*tp_free*/ @@ -1641,16 +3096,87 @@ return 0; } +static PyObject *__pyx_getprop_6cloess_13loess_control_surface(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_control_7surface___get__(o); +} + +static int __pyx_setprop_6cloess_13loess_control_surface(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6cloess_13loess_control_7surface___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6cloess_13loess_control_statistics(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_control_10statistics___get__(o); +} + +static int __pyx_setprop_6cloess_13loess_control_statistics(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6cloess_13loess_control_10statistics___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6cloess_13loess_control_trace_hat(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_control_9trace_hat___get__(o); +} + +static int __pyx_setprop_6cloess_13loess_control_trace_hat(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6cloess_13loess_control_9trace_hat___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6cloess_13loess_control_iterations(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_control_10iterations___get__(o); +} + +static int __pyx_setprop_6cloess_13loess_control_iterations(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6cloess_13loess_control_10iterations___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6cloess_13loess_control_cell(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_control_4cell___get__(o); +} + +static int __pyx_setprop_6cloess_13loess_control_cell(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6cloess_13loess_control_4cell___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + static struct PyMethodDef __pyx_methods_6cloess_loess_control[] = { + {"update", (PyCFunction)__pyx_f_6cloess_13loess_control_update, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; -static struct PyMemberDef __pyx_members_6cloess_loess_control[] = { - {"surface", T_STRING, offsetof(struct __pyx_obj_6cloess_loess_control, surface), 0, 0}, - {"statistics", T_STRING, offsetof(struct __pyx_obj_6cloess_loess_control, statistics), 0, 0}, - {"trace_hat", T_STRING, offsetof(struct __pyx_obj_6cloess_loess_control, trace_hat), 0, 0}, - {"cell", T_DOUBLE, offsetof(struct __pyx_obj_6cloess_loess_control, cell), 0, 0}, - {"iterations", T_INT, offsetof(struct __pyx_obj_6cloess_loess_control, iterations), 0, 0}, +static struct PyGetSetDef __pyx_getsets_6cloess_loess_control[] = { + {"surface", __pyx_getprop_6cloess_13loess_control_surface, __pyx_setprop_6cloess_13loess_control_surface, 0, 0}, + {"statistics", __pyx_getprop_6cloess_13loess_control_statistics, __pyx_setprop_6cloess_13loess_control_statistics, 0, 0}, + {"trace_hat", __pyx_getprop_6cloess_13loess_control_trace_hat, __pyx_setprop_6cloess_13loess_control_trace_hat, 0, 0}, + {"iterations", __pyx_getprop_6cloess_13loess_control_iterations, __pyx_setprop_6cloess_13loess_control_iterations, 0, 0}, + {"cell", __pyx_getprop_6cloess_13loess_control_cell, __pyx_setprop_6cloess_13loess_control_cell, 0, 0}, {0, 0, 0, 0, 0} }; @@ -1751,14 +3277,14 @@ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6cloess_loess_control, /*tp_methods*/ - __pyx_members_6cloess_loess_control, /*tp_members*/ - 0, /*tp_getset*/ + 0, /*tp_members*/ + __pyx_getsets_6cloess_loess_control, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - __pyx_f_6cloess_13loess_control___init__, /*tp_init*/ + 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6cloess_loess_control, /*tp_new*/ 0, /*tp_free*/ @@ -1770,74 +3296,435 @@ 0, /*tp_weaklist*/ }; -static PyObject *__pyx_tp_new_6cloess_loess_outputs(PyTypeObject *t, PyObject *a, PyObject *k) { +static PyObject *__pyx_tp_new_6cloess_loess_kd_tree(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); - struct __pyx_obj_6cloess_loess_outputs *p = (struct __pyx_obj_6cloess_loess_outputs *)o; - p->fitted_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - p->fitted_residuals = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - p->pseudovalues = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - p->diagonal = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - p->robust = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - p->divisor = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); return o; } -static void __pyx_tp_dealloc_6cloess_loess_outputs(PyObject *o) { - struct __pyx_obj_6cloess_loess_outputs *p = (struct __pyx_obj_6cloess_loess_outputs *)o; - Py_XDECREF(((PyObject *)p->fitted_values)); - Py_XDECREF(((PyObject *)p->fitted_residuals)); - Py_XDECREF(((PyObject *)p->pseudovalues)); - Py_XDECREF(((PyObject *)p->diagonal)); - Py_XDECREF(((PyObject *)p->robust)); - Py_XDECREF(((PyObject *)p->divisor)); +static void __pyx_tp_dealloc_6cloess_loess_kd_tree(PyObject *o) { (*o->ob_type->tp_free)(o); } -static int __pyx_tp_traverse_6cloess_loess_outputs(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_6cloess_loess_outputs *p = (struct __pyx_obj_6cloess_loess_outputs *)o; - if (p->fitted_values) { - e = (*v)(((PyObject*)p->fitted_values), a); if (e) return e; +static int __pyx_tp_traverse_6cloess_loess_kd_tree(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_6cloess_loess_kd_tree(PyObject *o) { + return 0; +} + +static struct PyMethodDef __pyx_methods_6cloess_loess_kd_tree[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_kd_tree = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_kd_tree = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_kd_tree = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_kd_tree = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6cloess_loess_kd_tree = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "cloess.loess_kd_tree", /*tp_name*/ + sizeof(struct __pyx_obj_6cloess_loess_kd_tree), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6cloess_loess_kd_tree, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_kd_tree, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_kd_tree, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_kd_tree, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_kd_tree, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6cloess_loess_kd_tree, /*tp_traverse*/ + __pyx_tp_clear_6cloess_loess_kd_tree, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6cloess_loess_kd_tree, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6cloess_loess_kd_tree, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_6cloess_loess_model(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + return o; +} + +static void __pyx_tp_dealloc_6cloess_loess_model(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6cloess_loess_model(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_6cloess_loess_model(PyObject *o) { + return 0; +} + +static PyObject *__pyx_getprop_6cloess_11loess_model_span(PyObject *o, void *x) { + return __pyx_f_6cloess_11loess_model_4span___get__(o); +} + +static int __pyx_setprop_6cloess_11loess_model_span(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6cloess_11loess_model_4span___set__(o, v); } - if (p->fitted_residuals) { - e = (*v)(((PyObject*)p->fitted_residuals), a); if (e) return e; + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; } - if (p->pseudovalues) { - e = (*v)(((PyObject*)p->pseudovalues), a); if (e) return e; +} + +static PyObject *__pyx_getprop_6cloess_11loess_model_degree(PyObject *o, void *x) { + return __pyx_f_6cloess_11loess_model_6degree___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_11loess_model_normalize(PyObject *o, void *x) { + return __pyx_f_6cloess_11loess_model_9normalize___get__(o); +} + +static int __pyx_setprop_6cloess_11loess_model_normalize(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6cloess_11loess_model_9normalize___set__(o, v); } - if (p->diagonal) { - e = (*v)(((PyObject*)p->diagonal), a); if (e) return e; + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; } - if (p->robust) { - e = (*v)(((PyObject*)p->robust), a); if (e) return e; +} + +static PyObject *__pyx_getprop_6cloess_11loess_model_family(PyObject *o, void *x) { + return __pyx_f_6cloess_11loess_model_6family___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_11loess_model_parametric_flags(PyObject *o, void *x) { + return __pyx_f_6cloess_11loess_model_16parametric_flags___get__(o); +} + +static int __pyx_setprop_6cloess_11loess_model_parametric_flags(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6cloess_11loess_model_16parametric_flags___set__(o, v); } - if (p->divisor) { - e = (*v)(((PyObject*)p->divisor), a); if (e) return e; + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; } +} + +static PyObject *__pyx_getprop_6cloess_11loess_model_drop_square_flags(PyObject *o, void *x) { + return __pyx_f_6cloess_11loess_model_17drop_square_flags___get__(o); +} + +static int __pyx_setprop_6cloess_11loess_model_drop_square_flags(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6cloess_11loess_model_17drop_square_flags___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static struct PyMethodDef __pyx_methods_6cloess_loess_model[] = { + {"update", (PyCFunction)__pyx_f_6cloess_11loess_model_update, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6cloess_loess_model[] = { + {"span", __pyx_getprop_6cloess_11loess_model_span, __pyx_setprop_6cloess_11loess_model_span, 0, 0}, + {"degree", __pyx_getprop_6cloess_11loess_model_degree, 0, 0, 0}, + {"normalize", __pyx_getprop_6cloess_11loess_model_normalize, __pyx_setprop_6cloess_11loess_model_normalize, __pyx_k4, 0}, + {"family", __pyx_getprop_6cloess_11loess_model_family, 0, 0, 0}, + {"parametric_flags", __pyx_getprop_6cloess_11loess_model_parametric_flags, __pyx_setprop_6cloess_11loess_model_parametric_flags, 0, 0}, + {"drop_square_flags", __pyx_getprop_6cloess_11loess_model_drop_square_flags, __pyx_setprop_6cloess_11loess_model_drop_square_flags, 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_model = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_model = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_model = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_model = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6cloess_loess_model = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "cloess.loess_model", /*tp_name*/ + sizeof(struct __pyx_obj_6cloess_loess_model), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6cloess_loess_model, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + __pyx_f_6cloess_11loess_model___repr__, /*tp_repr*/ + &__pyx_tp_as_number_loess_model, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_model, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_model, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_f_6cloess_11loess_model___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_model, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6cloess_loess_model, /*tp_traverse*/ + __pyx_tp_clear_6cloess_loess_model, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6cloess_loess_model, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6cloess_loess_model, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6cloess_loess_model, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_6cloess_loess_outputs(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + return o; +} + +static void __pyx_tp_dealloc_6cloess_loess_outputs(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6cloess_loess_outputs(PyObject *o, visitproc v, void *a) { return 0; } static int __pyx_tp_clear_6cloess_loess_outputs(PyObject *o) { - struct __pyx_obj_6cloess_loess_outputs *p = (struct __pyx_obj_6cloess_loess_outputs *)o; - Py_XDECREF(((PyObject *)p->fitted_values)); - p->fitted_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(((PyObject *)p->fitted_residuals)); - p->fitted_residuals = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(((PyObject *)p->pseudovalues)); - p->pseudovalues = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(((PyObject *)p->diagonal)); - p->diagonal = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(((PyObject *)p->robust)); - p->robust = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(((PyObject *)p->divisor)); - p->divisor = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); return 0; } +static PyObject *__pyx_getprop_6cloess_13loess_outputs_fitted_values(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_outputs_13fitted_values___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_13loess_outputs_fitted_residuals(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_outputs_16fitted_residuals___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_13loess_outputs_pseudovalues(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_outputs_12pseudovalues___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_13loess_outputs_diagonal(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_outputs_8diagonal___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_13loess_outputs_robust(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_outputs_6robust___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_13loess_outputs_divisor(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_outputs_7divisor___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_13loess_outputs_enp(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_outputs_3enp___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_13loess_outputs_s(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_outputs_1s___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_13loess_outputs_one_delta(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_outputs_9one_delta___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_13loess_outputs_two_delta(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_outputs_9two_delta___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_13loess_outputs_trace_hat(PyObject *o, void *x) { + return __pyx_f_6cloess_13loess_outputs_9trace_hat___get__(o); +} + static struct PyMethodDef __pyx_methods_6cloess_loess_outputs[] = { {0, 0, 0, 0} }; +static struct PyGetSetDef __pyx_getsets_6cloess_loess_outputs[] = { + {"fitted_values", __pyx_getprop_6cloess_13loess_outputs_fitted_values, 0, 0, 0}, + {"fitted_residuals", __pyx_getprop_6cloess_13loess_outputs_fitted_residuals, 0, 0, 0}, + {"pseudovalues", __pyx_getprop_6cloess_13loess_outputs_pseudovalues, 0, 0, 0}, + {"diagonal", __pyx_getprop_6cloess_13loess_outputs_diagonal, 0, 0, 0}, + {"robust", __pyx_getprop_6cloess_13loess_outputs_robust, 0, 0, 0}, + {"divisor", __pyx_getprop_6cloess_13loess_outputs_divisor, 0, 0, 0}, + {"enp", __pyx_getprop_6cloess_13loess_outputs_enp, 0, __pyx_k5, 0}, + {"s", __pyx_getprop_6cloess_13loess_outputs_s, 0, 0, 0}, + {"one_delta", __pyx_getprop_6cloess_13loess_outputs_one_delta, 0, 0, 0}, + {"two_delta", __pyx_getprop_6cloess_13loess_outputs_two_delta, 0, 0, 0}, + {"trace_hat", __pyx_getprop_6cloess_13loess_outputs_trace_hat, 0, 0, 0}, + {0, 0, 0, 0, 0} +}; + static PyNumberMethods __pyx_tp_as_number_loess_outputs = { 0, /*nb_add*/ 0, /*nb_subtract*/ @@ -1936,13 +3823,13 @@ 0, /*tp_iternext*/ __pyx_methods_6cloess_loess_outputs, /*tp_methods*/ 0, /*tp_members*/ - 0, /*tp_getset*/ + __pyx_getsets_6cloess_loess_outputs, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - __pyx_f_6cloess_13loess_outputs___init__, /*tp_init*/ + 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6cloess_loess_outputs, /*tp_new*/ 0, /*tp_free*/ @@ -1954,68 +3841,229 @@ 0, /*tp_weaklist*/ }; -static PyObject *__pyx_tp_new_6cloess_loess_kd_tree(PyTypeObject *t, PyObject *a, PyObject *k) { +static PyObject *__pyx_tp_new_6cloess_loess_anova(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); - struct __pyx_obj_6cloess_loess_kd_tree *p = (struct __pyx_obj_6cloess_loess_kd_tree *)o; - p->parameter = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - p->a = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - p->xi = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - p->vert = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - p->vval = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); return o; } -static void __pyx_tp_dealloc_6cloess_loess_kd_tree(PyObject *o) { - struct __pyx_obj_6cloess_loess_kd_tree *p = (struct __pyx_obj_6cloess_loess_kd_tree *)o; - Py_XDECREF(((PyObject *)p->parameter)); - Py_XDECREF(((PyObject *)p->a)); - Py_XDECREF(((PyObject *)p->xi)); - Py_XDECREF(((PyObject *)p->vert)); - Py_XDECREF(((PyObject *)p->vval)); +static void __pyx_tp_dealloc_6cloess_loess_anova(PyObject *o) { (*o->ob_type->tp_free)(o); } -static int __pyx_tp_traverse_6cloess_loess_kd_tree(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_6cloess_loess_anova(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_6cloess_loess_anova(PyObject *o) { + return 0; +} + +static PyObject *__pyx_getprop_6cloess_11loess_anova_dfn(PyObject *o, void *x) { + return __pyx_f_6cloess_11loess_anova_3dfn___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_11loess_anova_dfd(PyObject *o, void *x) { + return __pyx_f_6cloess_11loess_anova_3dfd___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_11loess_anova_F_value(PyObject *o, void *x) { + return __pyx_f_6cloess_11loess_anova_7F_value___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_11loess_anova_Pr_F(PyObject *o, void *x) { + return __pyx_f_6cloess_11loess_anova_4Pr_F___get__(o); +} + +static struct PyMethodDef __pyx_methods_6cloess_loess_anova[] = { + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6cloess_loess_anova[] = { + {"dfn", __pyx_getprop_6cloess_11loess_anova_dfn, 0, 0, 0}, + {"dfd", __pyx_getprop_6cloess_11loess_anova_dfd, 0, 0, 0}, + {"F_value", __pyx_getprop_6cloess_11loess_anova_F_value, 0, 0, 0}, + {"Pr_F", __pyx_getprop_6cloess_11loess_anova_Pr_F, 0, 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_anova = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_anova = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_anova = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_anova = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6cloess_loess_anova = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "cloess.loess_anova", /*tp_name*/ + sizeof(struct __pyx_obj_6cloess_loess_anova), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6cloess_loess_anova, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_anova, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_anova, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_anova, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_anova, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6cloess_loess_anova, /*tp_traverse*/ + __pyx_tp_clear_6cloess_loess_anova, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6cloess_loess_anova, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6cloess_loess_anova, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6cloess_loess_anova, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_6cloess_confidence_interval(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_6cloess_confidence_interval *p = (struct __pyx_obj_6cloess_confidence_interval *)o; + p->nest = Py_None; Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6cloess_confidence_interval(PyObject *o) { + struct __pyx_obj_6cloess_confidence_interval *p = (struct __pyx_obj_6cloess_confidence_interval *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++o->ob_refcnt; + __pyx_f_6cloess_19confidence_interval___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --o->ob_refcnt; + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(p->nest); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6cloess_confidence_interval(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_6cloess_loess_kd_tree *p = (struct __pyx_obj_6cloess_loess_kd_tree *)o; - if (p->parameter) { - e = (*v)(((PyObject*)p->parameter), a); if (e) return e; + struct __pyx_obj_6cloess_confidence_interval *p = (struct __pyx_obj_6cloess_confidence_interval *)o; + if (p->nest) { + e = (*v)(p->nest, a); if (e) return e; } - if (p->a) { - e = (*v)(((PyObject*)p->a), a); if (e) return e; - } - if (p->xi) { - e = (*v)(((PyObject*)p->xi), a); if (e) return e; - } - if (p->vert) { - e = (*v)(((PyObject*)p->vert), a); if (e) return e; - } - if (p->vval) { - e = (*v)(((PyObject*)p->vval), a); if (e) return e; - } return 0; } -static int __pyx_tp_clear_6cloess_loess_kd_tree(PyObject *o) { - struct __pyx_obj_6cloess_loess_kd_tree *p = (struct __pyx_obj_6cloess_loess_kd_tree *)o; - Py_XDECREF(((PyObject *)p->parameter)); - p->parameter = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(((PyObject *)p->a)); - p->a = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(((PyObject *)p->xi)); - p->xi = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(((PyObject *)p->vert)); - p->vert = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(((PyObject *)p->vval)); - p->vval = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); +static int __pyx_tp_clear_6cloess_confidence_interval(PyObject *o) { + struct __pyx_obj_6cloess_confidence_interval *p = (struct __pyx_obj_6cloess_confidence_interval *)o; + Py_XDECREF(p->nest); + p->nest = Py_None; Py_INCREF(Py_None); return 0; } -static struct PyMethodDef __pyx_methods_6cloess_loess_kd_tree[] = { +static PyObject *__pyx_getprop_6cloess_19confidence_interval_fit(PyObject *o, void *x) { + return __pyx_f_6cloess_19confidence_interval_3fit___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_19confidence_interval_upper(PyObject *o, void *x) { + return __pyx_f_6cloess_19confidence_interval_5upper___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_19confidence_interval_lower(PyObject *o, void *x) { + return __pyx_f_6cloess_19confidence_interval_5lower___get__(o); +} + +static struct PyMethodDef __pyx_methods_6cloess_confidence_interval[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_loess_kd_tree = { +static struct PyGetSetDef __pyx_getsets_6cloess_confidence_interval[] = { + {"fit", __pyx_getprop_6cloess_19confidence_interval_fit, 0, 0, 0}, + {"upper", __pyx_getprop_6cloess_19confidence_interval_upper, 0, 0, 0}, + {"lower", __pyx_getprop_6cloess_19confidence_interval_lower, 0, 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_confidence_interval = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -2056,7 +4104,7 @@ 0, /*nb_inplace_true_divide*/ }; -static PySequenceMethods __pyx_tp_as_sequence_loess_kd_tree = { +static PySequenceMethods __pyx_tp_as_sequence_confidence_interval = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -2069,59 +4117,59 @@ 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_loess_kd_tree = { +static PyMappingMethods __pyx_tp_as_mapping_confidence_interval = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_loess_kd_tree = { +static PyBufferProcs __pyx_tp_as_buffer_confidence_interval = { 0, /*bf_getreadbuffer*/ 0, /*bf_getwritebuffer*/ 0, /*bf_getsegcount*/ 0, /*bf_getcharbuffer*/ }; -PyTypeObject __pyx_type_6cloess_loess_kd_tree = { +PyTypeObject __pyx_type_6cloess_confidence_interval = { PyObject_HEAD_INIT(0) 0, /*ob_size*/ - "cloess.loess_kd_tree", /*tp_name*/ - sizeof(struct __pyx_obj_6cloess_loess_kd_tree), /*tp_basicsize*/ + "cloess.confidence_interval", /*tp_name*/ + sizeof(struct __pyx_obj_6cloess_confidence_interval), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6cloess_loess_kd_tree, /*tp_dealloc*/ + __pyx_tp_dealloc_6cloess_confidence_interval, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ - &__pyx_tp_as_number_loess_kd_tree, /*tp_as_number*/ - &__pyx_tp_as_sequence_loess_kd_tree, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_loess_kd_tree, /*tp_as_mapping*/ + &__pyx_tp_as_number_confidence_interval, /*tp_as_number*/ + &__pyx_tp_as_sequence_confidence_interval, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_confidence_interval, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_loess_kd_tree, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_confidence_interval, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_6cloess_loess_kd_tree, /*tp_traverse*/ - __pyx_tp_clear_6cloess_loess_kd_tree, /*tp_clear*/ + __pyx_tp_traverse_6cloess_confidence_interval, /*tp_traverse*/ + __pyx_tp_clear_6cloess_confidence_interval, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6cloess_loess_kd_tree, /*tp_methods*/ + __pyx_methods_6cloess_confidence_interval, /*tp_methods*/ 0, /*tp_members*/ - 0, /*tp_getset*/ + __pyx_getsets_6cloess_confidence_interval, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - __pyx_f_6cloess_13loess_kd_tree___init__, /*tp_init*/ + 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6cloess_loess_kd_tree, /*tp_new*/ + __pyx_tp_new_6cloess_confidence_interval, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -2131,47 +4179,74 @@ 0, /*tp_weaklist*/ }; -static PyObject *__pyx_tp_new_6cloess_loess_model(PyTypeObject *t, PyObject *a, PyObject *k) { +static PyObject *__pyx_tp_new_6cloess_loess_predicted(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); - struct __pyx_obj_6cloess_loess_model *p = (struct __pyx_obj_6cloess_loess_model *)o; - p->parametric_flags = Py_None; Py_INCREF(Py_None); - p->drop_square_flags = Py_None; Py_INCREF(Py_None); + struct __pyx_obj_6cloess_loess_predicted *p = (struct __pyx_obj_6cloess_loess_predicted *)o; + p->conf_interval = ((struct __pyx_obj_6cloess_confidence_interval *)Py_None); Py_INCREF(Py_None); return o; } -static void __pyx_tp_dealloc_6cloess_loess_model(PyObject *o) { - struct __pyx_obj_6cloess_loess_model *p = (struct __pyx_obj_6cloess_loess_model *)o; - Py_XDECREF(p->parametric_flags); - Py_XDECREF(p->drop_square_flags); +static void __pyx_tp_dealloc_6cloess_loess_predicted(PyObject *o) { + struct __pyx_obj_6cloess_loess_predicted *p = (struct __pyx_obj_6cloess_loess_predicted *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++o->ob_refcnt; + __pyx_f_6cloess_15loess_predicted___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --o->ob_refcnt; + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(((PyObject *)p->conf_interval)); (*o->ob_type->tp_free)(o); } -static int __pyx_tp_traverse_6cloess_loess_model(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_6cloess_loess_predicted(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_6cloess_loess_model *p = (struct __pyx_obj_6cloess_loess_model *)o; - if (p->parametric_flags) { - e = (*v)(p->parametric_flags, a); if (e) return e; + struct __pyx_obj_6cloess_loess_predicted *p = (struct __pyx_obj_6cloess_loess_predicted *)o; + if (p->conf_interval) { + e = (*v)(((PyObject*)p->conf_interval), a); if (e) return e; } - if (p->drop_square_flags) { - e = (*v)(p->drop_square_flags, a); if (e) return e; - } return 0; } -static int __pyx_tp_clear_6cloess_loess_model(PyObject *o) { - struct __pyx_obj_6cloess_loess_model *p = (struct __pyx_obj_6cloess_loess_model *)o; - Py_XDECREF(p->parametric_flags); - p->parametric_flags = Py_None; Py_INCREF(Py_None); - Py_XDECREF(p->drop_square_flags); - p->drop_square_flags = Py_None; Py_INCREF(Py_None); +static int __pyx_tp_clear_6cloess_loess_predicted(PyObject *o) { + struct __pyx_obj_6cloess_loess_predicted *p = (struct __pyx_obj_6cloess_loess_predicted *)o; + Py_XDECREF(((PyObject *)p->conf_interval)); + p->conf_interval = ((struct __pyx_obj_6cloess_confidence_interval *)Py_None); Py_INCREF(Py_None); return 0; } -static struct PyMethodDef __pyx_methods_6cloess_loess_model[] = { +static PyObject *__pyx_getprop_6cloess_15loess_predicted_predicted(PyObject *o, void *x) { + return __pyx_f_6cloess_15loess_predicted_9predicted___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_15loess_predicted_predicted_stderr(PyObject *o, void *x) { + return __pyx_f_6cloess_15loess_predicted_16predicted_stderr___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_15loess_predicted_residual_scale(PyObject *o, void *x) { + return __pyx_f_6cloess_15loess_predicted_14residual_scale___get__(o); +} + +static PyObject *__pyx_getprop_6cloess_15loess_predicted_df(PyObject *o, void *x) { + return __pyx_f_6cloess_15loess_predicted_2df___get__(o); +} + +static struct PyMethodDef __pyx_methods_6cloess_loess_predicted[] = { + {"confidence", (PyCFunction)__pyx_f_6cloess_15loess_predicted_confidence, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cloess_15loess_predicted_confidence}, {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_loess_model = { +static struct PyGetSetDef __pyx_getsets_6cloess_loess_predicted[] = { + {"predicted", __pyx_getprop_6cloess_15loess_predicted_predicted, 0, 0, 0}, + {"predicted_stderr", __pyx_getprop_6cloess_15loess_predicted_predicted_stderr, 0, 0, 0}, + {"residual_scale", __pyx_getprop_6cloess_15loess_predicted_residual_scale, 0, 0, 0}, + {"df", __pyx_getprop_6cloess_15loess_predicted_df, 0, 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_predicted = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -2212,7 +4287,7 @@ 0, /*nb_inplace_true_divide*/ }; -static PySequenceMethods __pyx_tp_as_sequence_loess_model = { +static PySequenceMethods __pyx_tp_as_sequence_loess_predicted = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -2225,59 +4300,59 @@ 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_loess_model = { +static PyMappingMethods __pyx_tp_as_mapping_loess_predicted = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_loess_model = { +static PyBufferProcs __pyx_tp_as_buffer_loess_predicted = { 0, /*bf_getreadbuffer*/ 0, /*bf_getwritebuffer*/ 0, /*bf_getsegcount*/ 0, /*bf_getcharbuffer*/ }; -PyTypeObject __pyx_type_6cloess_loess_model = { +PyTypeObject __pyx_type_6cloess_loess_predicted = { PyObject_HEAD_INIT(0) 0, /*ob_size*/ - "cloess.loess_model", /*tp_name*/ - sizeof(struct __pyx_obj_6cloess_loess_model), /*tp_basicsize*/ + "cloess.loess_predicted", /*tp_name*/ + sizeof(struct __pyx_obj_6cloess_loess_predicted), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6cloess_loess_model, /*tp_dealloc*/ + __pyx_tp_dealloc_6cloess_loess_predicted, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ - __pyx_f_6cloess_11loess_model___repr__, /*tp_repr*/ - &__pyx_tp_as_number_loess_model, /*tp_as_number*/ - &__pyx_tp_as_sequence_loess_model, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_loess_model, /*tp_as_mapping*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_predicted, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_predicted, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_predicted, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ - __pyx_f_6cloess_11loess_model___str__, /*tp_str*/ + 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_loess_model, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_loess_predicted, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_6cloess_loess_model, /*tp_traverse*/ - __pyx_tp_clear_6cloess_loess_model, /*tp_clear*/ + __pyx_tp_traverse_6cloess_loess_predicted, /*tp_traverse*/ + __pyx_tp_clear_6cloess_loess_predicted, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6cloess_loess_model, /*tp_methods*/ + __pyx_methods_6cloess_loess_predicted, /*tp_methods*/ 0, /*tp_members*/ - 0, /*tp_getset*/ + __pyx_getsets_6cloess_loess_predicted, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - __pyx_f_6cloess_11loess_model___init__, /*tp_init*/ + 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6cloess_loess_model, /*tp_new*/ + __pyx_tp_new_6cloess_loess_predicted, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -2295,6 +4370,7 @@ p->control = ((struct __pyx_obj_6cloess_loess_control *)Py_None); Py_INCREF(Py_None); p->kd_tree = ((struct __pyx_obj_6cloess_loess_kd_tree *)Py_None); Py_INCREF(Py_None); p->outputs = ((struct __pyx_obj_6cloess_loess_outputs *)Py_None); Py_INCREF(Py_None); + p->predicted = ((struct __pyx_obj_6cloess_loess_predicted *)Py_None); Py_INCREF(Py_None); return o; } @@ -2305,6 +4381,7 @@ Py_XDECREF(((PyObject *)p->control)); Py_XDECREF(((PyObject *)p->kd_tree)); Py_XDECREF(((PyObject *)p->outputs)); + Py_XDECREF(((PyObject *)p->predicted)); (*o->ob_type->tp_free)(o); } @@ -2326,6 +4403,9 @@ if (p->outputs) { e = (*v)(((PyObject*)p->outputs), a); if (e) return e; } + if (p->predicted) { + e = (*v)(((PyObject*)p->predicted), a); if (e) return e; + } return 0; } @@ -2341,14 +4421,28 @@ p->kd_tree = ((struct __pyx_obj_6cloess_loess_kd_tree *)Py_None); Py_INCREF(Py_None); Py_XDECREF(((PyObject *)p->outputs)); p->outputs = ((struct __pyx_obj_6cloess_loess_outputs *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->predicted)); + p->predicted = ((struct __pyx_obj_6cloess_loess_predicted *)Py_None); Py_INCREF(Py_None); return 0; } static struct PyMethodDef __pyx_methods_6cloess_loess[] = { + {"fit", (PyCFunction)__pyx_f_6cloess_5loess_fit, METH_VARARGS|METH_KEYWORDS, 0}, {"summary", (PyCFunction)__pyx_f_6cloess_5loess_summary, METH_VARARGS|METH_KEYWORDS, 0}, + {"predict", (PyCFunction)__pyx_f_6cloess_5loess_predict, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cloess_5loess_predict}, {0, 0, 0, 0} }; +static struct PyMemberDef __pyx_members_6cloess_loess[] = { + {"inputs", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess, inputs), READONLY, 0}, + {"model", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess, model), READONLY, 0}, + {"control", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess, control), READONLY, 0}, + {"kd_tree", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess, kd_tree), READONLY, 0}, + {"outputs", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess, outputs), READONLY, 0}, + {"predicted", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess, predicted), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + static PyNumberMethods __pyx_tp_as_number_loess = { 0, /*nb_add*/ 0, /*nb_subtract*/ @@ -2446,7 +4540,7 @@ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6cloess_loess, /*tp_methods*/ - 0, /*tp_members*/ + __pyx_members_6cloess_loess, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ @@ -2483,28 +4577,35 @@ if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; - __pyx_type_6cloess_loess_inputs.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_inputs", (PyObject *)&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_inputs", (PyObject *)&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} __pyx_ptype_6cloess_loess_inputs = &__pyx_type_6cloess_loess_inputs; - if (PyType_Ready(&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_control", (PyObject *)&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_control", (PyObject *)&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;} __pyx_ptype_6cloess_loess_control = &__pyx_type_6cloess_loess_control; - __pyx_type_6cloess_loess_outputs.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_outputs", (PyObject *)&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;} - __pyx_ptype_6cloess_loess_outputs = &__pyx_type_6cloess_loess_outputs; - __pyx_type_6cloess_loess_kd_tree.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_kd_tree", (PyObject *)&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_kd_tree", (PyObject *)&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} __pyx_ptype_6cloess_loess_kd_tree = &__pyx_type_6cloess_loess_kd_tree; - __pyx_type_6cloess_loess_model.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_model", (PyObject *)&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_model", (PyObject *)&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} __pyx_ptype_6cloess_loess_model = &__pyx_type_6cloess_loess_model; + if (PyType_Ready(&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_outputs", (PyObject *)&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + __pyx_ptype_6cloess_loess_outputs = &__pyx_type_6cloess_loess_outputs; + if (PyType_Ready(&__pyx_type_6cloess_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_anova", (PyObject *)&__pyx_type_6cloess_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;} + __pyx_ptype_6cloess_loess_anova = &__pyx_type_6cloess_loess_anova; + __pyx_type_6cloess_confidence_interval.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_6cloess_confidence_interval) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "confidence_interval", (PyObject *)&__pyx_type_6cloess_confidence_interval) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; goto __pyx_L1;} + __pyx_ptype_6cloess_confidence_interval = &__pyx_type_6cloess_confidence_interval; + __pyx_type_6cloess_loess_predicted.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_6cloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_predicted", (PyObject *)&__pyx_type_6cloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;} + __pyx_ptype_6cloess_loess_predicted = &__pyx_type_6cloess_loess_predicted; __pyx_type_6cloess_loess.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess", (PyObject *)&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess", (PyObject *)&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; goto __pyx_L1;} __pyx_ptype_6cloess_loess = &__pyx_type_6cloess_loess; __pyx_ptype_7c_numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (!__pyx_ptype_7c_numpy_dtype) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; goto __pyx_L1;} __pyx_ptype_7c_numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (!__pyx_ptype_7c_numpy_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 81; goto __pyx_L1;} @@ -2513,34 +4614,25 @@ /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":7 */ __pyx_1 = __Pyx_Import(__pyx_n_numpy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} - if (PyObject_SetAttr(__pyx_m, __pyx_n__N, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_numpy, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":9 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":14 */ import_array(); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":22 */ - Py_INCREF(Py_None); - __pyx_k2 = Py_None; - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":202 */ - __pyx_k3 = 0.75; - __pyx_k4 = 2; - __pyx_k5 = 1; - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;} - __pyx_k6 = __pyx_1; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":402 */ + __pyx_1 = PyFloat_FromDouble(0.95); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; goto __pyx_L1;} + __pyx_k7 = __pyx_1; __pyx_1 = 0; - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; goto __pyx_L1;} - __pyx_k7 = __pyx_2; - __pyx_2 = 0; - Py_INCREF(__pyx_n_gaussian); - __pyx_k9 = __pyx_n_gaussian; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":273 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":423 */ Py_INCREF(Py_None); - __pyx_k10 = Py_None; + __pyx_k8 = Py_None; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":309 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":466 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; goto __pyx_L1;} + __pyx_k9 = __pyx_2; + __pyx_2 = 0; return; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -2559,6 +4651,79 @@ __pyx_f = __pyx_filenames; } +static int __Pyx_GetStarArgs( + PyObject **args, + PyObject **kwds, + char *kwd_list[], + int nargs, + PyObject **args2, + PyObject **kwds2) +{ + PyObject *x = 0, *args1 = 0, *kwds1 = 0; + + if (args2) + *args2 = 0; + if (kwds2) + *kwds2 = 0; + + if (args2) { + args1 = PyTuple_GetSlice(*args, 0, nargs); + if (!args1) + goto bad; + *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_Size(*args)); + if (!*args2) + goto bad; + } + else { + args1 = *args; + Py_INCREF(args1); + } + + if (kwds2) { + if (*kwds) { + char **p; + kwds1 = PyDict_New(); + if (!kwds) + goto bad; + *kwds2 = PyDict_Copy(*kwds); + if (!*kwds2) + goto bad; + for (p = kwd_list; *p; p++) { + x = PyDict_GetItemString(*kwds, *p); + if (x) { + if (PyDict_SetItemString(kwds1, *p, x) < 0) + goto bad; + if (PyDict_DelItemString(*kwds2, *p) < 0) + goto bad; + } + } + } + else { + *kwds2 = PyDict_New(); + if (!*kwds2) + goto bad; + } + } + else { + kwds1 = *kwds; + Py_XINCREF(kwds1); + } + + *args = args1; + *kwds = kwds1; + return 0; +bad: + Py_XDECREF(args1); + Py_XDECREF(kwds1); + if (*args2) { + Py_XDECREF(*args2); + } + if (*kwds2) { + Py_XDECREF(*kwds2); + } + return -1; +} + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) { PyObject *__import__ = 0; PyObject *empty_list = 0; @@ -2600,47 +4765,18 @@ return result; } -static PyObject *__Pyx_GetStdout(void) { - PyObject *f = PySys_GetObject("stdout"); - if (!f) { - PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); +static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; } - return f; -} - -static int __Pyx_PrintItem(PyObject *v) { - PyObject *f; - - if (!(f = __Pyx_GetStdout())) - return -1; - if (PyFile_SoftSpace(f, 1)) { - if (PyFile_WriteString(" ", f) < 0) - return -1; - } - if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) - return -1; - if (PyString_Check(v)) { - char *s = PyString_AsString(v); - int len = PyString_Size(v); - if (len > 0 && - isspace(Py_CHARMASK(s[len-1])) && - s[len-1] != ' ') - PyFile_SoftSpace(f, 0); - } + if (obj == Py_None || PyObject_TypeCheck(obj, type)) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s", + obj->ob_type->tp_name, type->tp_name); return 0; } -static int __Pyx_PrintNewline(void) { - PyObject *f; - - if (!(f = __Pyx_GetStdout())) - return -1; - if (PyFile_WriteString("\n", f) < 0) - return -1; - PyFile_SoftSpace(f, 0); - return 0; -} - static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { Py_XINCREF(type); Py_XINCREF(value); @@ -2699,18 +4835,47 @@ return; } -static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { - if (!type) { - PyErr_Format(PyExc_SystemError, "Missing type object"); - return 0; +static PyObject *__Pyx_GetStdout(void) { + PyObject *f = PySys_GetObject("stdout"); + if (!f) { + PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); } - if (obj == Py_None || PyObject_TypeCheck(obj, type)) - return 1; - PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s", - obj->ob_type->tp_name, type->tp_name); + return f; +} + +static int __Pyx_PrintItem(PyObject *v) { + PyObject *f; + + if (!(f = __Pyx_GetStdout())) + return -1; + if (PyFile_SoftSpace(f, 1)) { + if (PyFile_WriteString(" ", f) < 0) + return -1; + } + if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) + return -1; + if (PyString_Check(v)) { + char *s = PyString_AsString(v); + int len = PyString_Size(v); + if (len > 0 && + isspace(Py_CHARMASK(s[len-1])) && + s[len-1] != ' ') + PyFile_SoftSpace(f, 0); + } return 0; } +static int __Pyx_PrintNewline(void) { + PyObject *f; + + if (!(f = __Pyx_GetStdout())) + return -1; + if (PyFile_WriteString("\n", f) < 0) + return -1; + PyFile_SoftSpace(f, 0); + return 0; +} + static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) { while (t->p) { *t->p = PyString_InternFromString(t->s); Modified: trunk/Lib/sandbox/pyloess/sandbox/src/cloess.h =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/cloess.h 2007-03-14 12:34:56 UTC (rev 2846) +++ trunk/Lib/sandbox/pyloess/sandbox/src/cloess.h 2007-03-14 12:46:49 UTC (rev 2847) @@ -1,87 +1,18 @@ #include #include -#include "loess.h" -/* -loess.c -*/ + + +// from loess.c void loess_setup(double *x, double *y, int n, int p, loess *lo); void loess_fit(loess *lo); -void -loess_(double *y, double *x_, int *size_info, double *weights, double *span, - int *degree, int *parametric, int *drop_square, int *normalize, - char **statistics, char **surface, double *cell, char **trace_hat_in, - int *iterations, double *fitted_values, double *fitted_residuals, - double *enp, double *s, double *one_delta, double *two_delta, - double *pseudovalues, double *trace_hat_out, double *diagonal, - double *robust, double *divisor, int *parameter, int *a, double *xi, - double *vert, double *vval); void loess_free_mem(loess *lo); void loess_summary(loess *lo); -void condition(char **surface, char *new_stat, char **trace_hat_in); -int comp(double *d1, double *d2); - -/* -loessc.c -*/ -void -loess_raw(double *y, double *x, double *weights, double *robust, int *d, - int*n, double *span, int *degree, int *nonparametric, - int *drop_square, int *sum_drop_sqr, double *cell, char **surf_stat, - double *surface, int *parameter, int *a, double *xi, double *vert, - double *vval, double *diagonal, double *trL, double *one_delta, - double *two_delta, int *setLf); -void -loess_dfit(double *y, double *x, double *x_evaluate, double *weights, - double *span, int *degree, int *nonparametric, - int *drop_square, int *sum_drop_sqr, int *d, int *n, int *m, - double *fit); -void -loess_dfitse(double *y, double *x, double *x_evaluate, double *weights, - double *robust, int *family, double *span, int *degree, - int *nonparametric, int *drop_square, int *sum_drop_sqr, - int *d, int *n, int *m, double *fit, double *L); -void -loess_ifit(int *parameter, int *a, double *xi, double *vert, double *vval, - int *m, double *x_evaluate, double *fit); -void -loess_ise(double *y, double *x, double *x_evaluate, double *weights, - double *span, int *degree, int *nonparametric, int *drop_square, - int *sum_drop_sqr, double *cell, int *d, int *n, int *m, - double *fit, double *L); -void -loess_workspace(int *d, int *n, double *span, int *degree, - int *nonparametric, int *drop_square, int *sum_drop_sqr, - int *setLf); -void -loess_prune(int *parameter, int *a, double *xi, double *vert, double *vval); -void -loess_grow(int *parameter, int *a, double *xi, double *vert, double *vval); -void -F77_SUB(lowesw)(double *res, int *n, double *rw, int *pi); -void -F77_SUB(lowesp)(int *n, double *y, double *yhat, double *pwgts, - double *rwgts, int *pi, double *ytilde); - -// -///* -//misc.c -//*/ -//void -//anova(struct loess_struct *one, struct loess_struct *two, -// struct anova_struct *out); -// -///* -//predict.c -//*/ -//void -//predict(double *eval, int m, struct loess_struct *lo, struct pred_struct *pre, -// int se); -//void -//pred_(double *y, double *x_, double *new_x, int *size_info, double *s, -// double *weights, double *robust, double *span, int *degree, -// int *normalize, int *parametric, int *drop_square, char **surface, -// double *cell, char **family, int *parameter, int *a, double *xi, -// double *vert, double *vval, double *divisor, int *se, double *fit, -// double *se_fit); -//void -//pred_free_mem(struct pred_struct *pre); + +// from misc.c +void anova(loess *one, loess *two, anova_struct *out); +void pointwise(prediction *pre, int m, double coverage, conf_inv *ci); +void pw_free_mem(conf_inv *ci); +//// +// from predict.c +void predict(double *eval, int m, loess *lo, prediction *pre, int se); +void pred_free_mem(prediction *pre); Modified: trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx 2007-03-14 12:34:56 UTC (rev 2846) +++ trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx 2007-03-14 12:46:49 UTC (rev 2847) @@ -3,85 +3,137 @@ cimport c_numpy from c_numpy cimport ndarray, npy_intp, \ PyArray_SIZE, PyArray_EMPTY, PyArray_FROMANY, \ - NPY_INT, NPY_DOUBLE, NPY_OWNDATA, NPY_ALIGNED -import numpy as _N + NPY_INT, NPY_DOUBLE, NPY_OWNDATA, NPY_ALIGNED, NPY_FORTRAN +import numpy + +#narray = _N.array +#ndouble = _N.float +#nbool = _N.bool + # NumPy must be initialized c_numpy.import_array() cimport c_loess + + +cdef floatarray_from_data(rows, cols, double *data): + cdef ndarray a_ndr + cdef double *a_dat + a_ndr = numpy.empty((rows*cols,), dtype=numpy.float) + a_dat = a_ndr.data + for i from 0 <= i < a_ndr.size: + a_dat[i] = data[i] + if cols > 1: + a_ndr.shape = (rows, cols) + return a_ndr + +cdef boolarray_from_data(rows, cols, int *data): + cdef ndarray a_ndr + cdef int *a_dat + a_ndr = numpy.empty((rows*cols,), dtype=numpy.int) + a_dat = a_ndr.data + for i from 0 <= i < a_ndr.size: + a_dat[i] = data[i] + if cols > 1: + a_ndr.shape = (rows, cols) + return a_ndr.astype(numpy.bool) + #####--------------------------------------------------------------------------- #---- ---- loess model --- #####--------------------------------------------------------------------------- - cdef class loess_inputs: - cdef c_loess.c_loess_inputs _inputs - cdef public long nobs, nvar - cdef readonly ndarray x, y, weights - - def __init__(self, object x, object y, object weights=None): - cdef ndarray x_ndr, y_ndr - cdef double *x_dat, *y_in_dat, *w_dat - cdef npy_intp n, p - cdef npy_intp *dims - print "DEBUG: Initializing loess_inputs...", - self.x = PyArray_FROMANY(x, NPY_DOUBLE, 1, 1, NPY_OWNDATA) - self.y = PyArray_FROMANY(y, NPY_DOUBLE, 1, 1, NPY_OWNDATA) - # - if self.x.ndim > 2: - raise ValueError,"Argument 'x' should be 2D at most!" - n = len(self.x) - p = self.x.size / n - # Initialize the python side ............ - self.nobs = n - self.nvar = p - dims[0] = n - # ... input weights ... - if weights is None: - self.weights = PyArray_EMPTY(1, dims, NPY_DOUBLE, NPY_ALIGNED) - w_dat = self.weights.data - for i from 0 <= i < dims[0]: - w_dat[i] = 1 - else: - self.weights = PyArray_FROMANY(weights, NPY_DOUBLE, 1, 1, NPY_OWNDATA) - if self.weights.ndim > 1 or self.weights.size != n: + cdef c_loess.c_loess_inputs *_base + #......... + property x: + def __get__(self): + return floatarray_from_data(self._base.n, self._base.p, self._base.x) + #......... + property y: + def __get__(self): + return floatarray_from_data(self._base.n, 1, self._base.y) + #......... + property weights: + "Weights" + def __get__(self): + return floatarray_from_data(self._base.n, 1, self._base.weights) + + def __set__(self, w): + cdef npy_intp *dims + cdef ndarray w_ndr + w_ndr = PyArray_FROMANY(w, NPY_DOUBLE, 1, 1, NPY_OWNDATA) + if w_ndr.ndim > 1 or w_ndr.size != self._base.n: raise ValueError, "Invalid size of the 'weights' vector!" - w_dat = self.weights.data - # Initialize the underlying C object .... - self._inputs.n = self.nobs - self._inputs.p = self.nvar - self._inputs.x = self.x.data - self._inputs.y = self.y.data - self._inputs.weights = self.weights.data - -# for i from 0 <= i < (self.nobs*self.nvar): -# self._inputs.x[i] = self.x.data[i] -# for i from 0 <= i < self.nobs: -# self._inputs.y[i] = self.y.data[i] -# self._inputs.weights[i] = w_dat[i] - print " OK." - return - - -#####--------------------------------------------------------------------------- -#---- ---- loess control --- -#####--------------------------------------------------------------------------- + self._base.weights = w_ndr.data + #......... + property nobs: + "Number of observations." + def __get__(self): + return self._base.n + #......... + property nvar: + "Number of independent variables." + def __get__(self): + return self._base.p +# +######--------------------------------------------------------------------------- +##---- ---- loess control --- +######--------------------------------------------------------------------------- cdef class loess_control: - cdef c_loess.c_loess_control _control - cdef public char *surface, *statistics, *trace_hat - cdef public double cell - cdef public int iterations - - def __init__(self): - print "DEBUG: Initializing loess_control...", - self.surface = self._control.surface = "interpolate" - self.statistics = self._control.statistics = "approximate" - self.cell = self._control.cell = 0.2 - self.trace_hat = self._control.trace_hat = "wait.to.decide" - self.iterations = self._control.iterations = 4 - print "OK." - return - + cdef c_loess.c_loess_control *_base + #......... + property surface: + def __get__(self): + return self._base.surface + def __set__(self, surface): + self._base.surface = surface + #......... + property statistics: + def __get__(self): + return self._base.statistics + def __set__(self, statistics): + self._base.statistics = statistics + #......... + property trace_hat: + def __get__(self): + return self._base.trace_hat + def __set__(self, trace_hat): + self._base.trace_hat = trace_hat + #......... + property iterations: + def __get__(self): + return self._base.iterations + def __set__(self, iterations): + self._base.iterations = iterations + #......... + property cell: + def __get__(self): + return self._base.cell + def __set__(self, cell): + self._base.cell = cell + #......... + def update(self, **cellargs): + surface = cellargs.get('surface', None) + if surface is not None: + self.surface = surface + # + statistics = cellargs.get('statistics', None) + if statistics is not None: + self.statistics = statistics + # + trace_hat = cellargs.get('trace_hat', None) + if trace_hat is not None: + self.trace_hat = trace_hat + # + iterations = cellargs.get('iterations', None) + if iterations is not None: + self.iterations = iterations + # + cell = cellargs.get('cell', None) + if cell is not None: + self.parametric_flags = cell + # + #......... def __str__(self): strg = ["Control :", "Surface type : %s" % self.surface, @@ -91,43 +143,181 @@ "Nb iterations : %s" % self.iterations,] return '\n'.join(strg) - +# +######--------------------------------------------------------------------------- +##---- ---- loess kd_tree --- +######--------------------------------------------------------------------------- +cdef class loess_kd_tree: + cdef c_loess.c_loess_kd_tree *_base +# #......... +# property parameter: +# def __get__(self): +# return self._base.parameter +# #......... +# property a: +# def __get__(self): +# return self._base.a +# #......... +# property vval: +# def __get__(self): +# return self._base.vert +# #......... +# property xi: +# def __get__(self): +# return self._base.xi +# #......... +# property vert: +# def __get__(self): +# return self._base.vert +# return +# +######--------------------------------------------------------------------------- +##---- ---- loess model --- +######--------------------------------------------------------------------------- +cdef class loess_model: + cdef c_loess.c_loess_model *_base + cdef long npar + #......... + property span: + def __get__(self): + return self._base.span + def __set__(self, span): + self._base.span = span + #......... + property degree: + def __get__(self): + return self._base.degree + #......... + property normalize: + "Normalize the variables. Only useful if more than one variable..." + def __get__(self): + return bool(self._base.normalize) + def __set__(self, normalize): + self._base.normalize = normalize + #......... + property family: + def __get__(self): + return self._base.family + #......... + property parametric_flags: + def __get__(self): + return boolarray_from_data(8, 1, self._base.parametric) + def __set__(self, paramf): + cdef ndarray p_ndr + cdef long *p_dat + cdef int i + p_ndr = PyArray_FROMANY(paramf, NPY_LONG, 1, 1, NPY_OWNDATA) + p_dat = p_ndr.data + for i in 0 <= i < max(8, p_ndr.size): + self._base.parametric[i] = p_dat[i] + #......... + property drop_square_flags: + def __get__(self): + return boolarray_from_data(8, 1, self._base.drop_square) + def __set__(self, drop_sq): + cdef ndarray d_ndr + cdef long *d_dat + cdef int i + d_ndr = PyArray_FROMANY(drop_sq, NPY_LONG, 1, 1, NPY_OWNDATA) + d_dat = d_ndr.data + for i in 0 <= i < max(8, d_ndr.size): + self._base.drop_square[i] = d_dat[i] + #........ + def update(self, **modelargs): + family = modelargs.get('family', None) + if family is not None: + self.family = family + # + span = modelargs.get('span', None) + if span is not None: + self.span = span + # + degree = modelargs.get('degree', None) + if degree is not None: + self.degree = degree + # + normalize = modelargs.get('normalize', None) + if normalize is not None: + self.normalize = normalize + # + parametric = modelargs.get('parametric', None) + if parametric is not None: + self.parametric_flags = parametric + # + drop_square = modelargs.get('drop_square', None) + if drop_square is not None: + self.drop_square_flags = drop_square + #......... + def __repr__(self): + return "loess model parameters @%s" % id(self) + #......... + def __str__(self): + strg = ["Model parameters.....", + "family : %s" % self.family, + "span : %s" % self.span, + "degree : %s" % self.degree, + "normalized : %s" % self.normalize, + "parametric : %s" % self.parametric_flags[:self.npar], + "drop_square : %s" % self.drop_square_flags[:self.npar] + ] + return '\n'.join(strg) + #####--------------------------------------------------------------------------- #---- ---- loess outputs --- #####--------------------------------------------------------------------------- cdef class loess_outputs: - cdef c_loess.c_loess_outputs _outputs - cdef ndarray fitted_values, fitted_residuals, pseudovalues, diagonal, robust, divisor - cdef double enp, s, one_delta, two_delta, trace_hat - - def __init__(self, n, p): - cdef npy_intp *rows, *cols - #cdef double *fv_dat, *fr_dat, *pv_dat, *diag_dat, *rw_dat, *div_dat - rows[0] = n - cols[0] = p - print "DEBUG: Initializing loess_outputs...", - # Initialize the python side ............ - self.fitted_values = PyArray_EMPTY(1, rows, NPY_DOUBLE, NPY_ALIGNED) - self.fitted_residuals = PyArray_EMPTY(1, rows, NPY_DOUBLE, NPY_ALIGNED) - self.pesudovalues = PyArray_EMPTY(1, rows, NPY_DOUBLE, NPY_ALIGNED) - self.diagonal = PyArray_EMPTY(1, rows, NPY_DOUBLE, NPY_ALIGNED) - self.robust = PyArray_EMPTY(1, rows, NPY_DOUBLE, NPY_ALIGNED) - self.divisor = PyArray_EMPTY(1, cols, NPY_DOUBLE, NPY_ALIGNED) - # Initialize the C side ................. - self._outputs.fitted_values = self.fitted_values.data - self._outputs.fitted_residuals = self.fitted_residuals.data - self._outputs.pseudovalues = self.pseudovalues.data - self._outputs.diagonal = self.diagonal.data - self._outputs.robust = self.robust.data - self._outputs.divisor = self.divisor.data - # Common initialization ................. - self.enp = self._outputs.enp = 0 - self.s = self._outputs.s = 0 - self.one_delta = self._outputs.one_delta = 0 - self.two_delta = self._outputs.two_delta = 0 - self.trace_hat = self._outputs.trace_hat = 0 - print "OK." - + cdef c_loess.c_loess_outputs *_base + cdef long nobs + #........ + property fitted_values: + def __get__(self): + return floatarray_from_data(self.nobs, 1, self._base.fitted_values) + #......... + property fitted_residuals: + def __get__(self): + return floatarray_from_data(self.nobs, 1, self._base.fitted_residuals) + #......... + property pseudovalues: + def __get__(self): + return floatarray_from_data(self.nobs, 1, self._base.pseudovalues) + #......... + property diagonal: + def __get__(self): + return floatarray_from_data(self.nobs, 1, self._base.diagonal) + #......... + property robust: + def __get__(self): + return floatarray_from_data(self.nobs, 1, self._base.robust) + #......... + property divisor: + def __get__(self): + return floatarray_from_data(self.nobs, 1, self._base.divisor) + #......... + property enp: + "Equivalent number of parameters." + def __get__(self): + return self._base.enp + #......... + property s: +# "" + def __get__(self): + return self._base.s + #......... + property one_delta: +# "" + def __get__(self): + return self._base.one_delta + #......... + property two_delta: +# "" + def __get__(self): + return self._base.two_delta + #......... + property trace_hat: +# "" + def __get__(self): + return self._base.trace_hat +# #......... # def __str__(self): # strg = ["Outputs :", # "enp : %s" % self.enp, @@ -135,181 +325,170 @@ # "Deltas : %s/%s" % (self.one_delta, self.two_delta), # "Divisor : %s" % self.divisor,] # return '\n'.join(strg) - + + #####--------------------------------------------------------------------------- -#---- ---- loess kd_tree --- +#---- ---- loess anova --- #####--------------------------------------------------------------------------- -cdef class loess_kd_tree: - cdef c_loess.c_loess_kd_tree _kdtree - cdef ndarray parameter, a, xi, vert, vval - - def __init__(self, long n, long p): - cdef long maxkd, nval, nvert - cdef npy_intp *nmaxkd, *nnval, *nnvert, *npars - # - print "DEBUG: Initializing loess_kdtree...", - maxkd = max(n, 200) - nvert = p * 2 - nval = (p+1) * maxkd - # Initialize the python side ............ - print "(python side)", - nmaxkd[0] = maxkd - nnvert[0] = nvert - nnval[0] = nval - npars[0] = 8 - self.parameter = PyArray_EMPTY(1, npars, NPY_LONG, NPY_ALIGNED) - self.a = PyArray_EMPTY(1, nmaxkd, NPY_LONG, NPY_ALIGNED) - self.xi = PyArray_EMPTY(1, nmaxkd, NPY_DOUBLE, NPY_ALIGNED) - self.vert = PyArray_EMPTY(1, nnvert, NPY_DOUBLE, NPY_ALIGNED) - self.vval = PyArray_EMPTY(1, nnval, NPY_DOUBLE, NPY_ALIGNED) -# self.parameter = _N.empty((8,), _N.long, order='F') -# self.a = _N.empty((maxkd,), _N.long, order='F') -# self.xi = _N.empty((maxkd,), _N.float, order='F') -# self.vert = _N.empty((p*2,), _N.float, order='F') -# self.vval = _N.empty((nnval,), _N.float, order='F') - # Initialize the C side ................. - print "(C side)", - self._kdtree.parameter = self.parameter.data - self._kdtree.a = self.a.data - self._kdtree.xi = self.xi.data - self._kdtree.vert = self.vert.data - self._kdtree.vval = self.vval.data -# # FIXME : Do we need to fill the arrays ? -# for i from 0 <= i < 8: -# self._kdtree.parameter[i] = 0 -# for i from 0 <= i < len(self.a): -# self._kdtree.a[i] = 0 -# self._kdtree.xi[i] = 0 -# for i from 0 <= i < (p*2): -# self._kdtree.vert[i] = 0 -# for i from 0 <= i < nnval: -# self._kdtree.vval[i] = 0 - print "OK." - return - +cdef class loess_anova: + cdef c_loess.c_anova *_base + cdef long nest + #......... + property dfn: + def __get__(self): + return self._base.dfn + #......... + property dfd: + def __get__(self): + return self._base.dfd + #......... + property F_value: + def __get__(self): + return self._base.F_value + #......... + property Pr_F: + def __get__(self): + return self._base.Pr_F + #####--------------------------------------------------------------------------- -#---- ---- loess model --- +#---- ---- loess confidence --- #####--------------------------------------------------------------------------- +cdef class confidence_interval: + cdef c_loess.c_conf_inv *_base + cdef nest + #......... + def __dealloc__(self): + c_loess.pw_free_mem(self) + #......... + property fit: + def __get__(self): + return floatarray_from_data(nest, 1, self._base.fit) + #......... + property upper: + def __get__(self): + return floatarray_from_data(nest, 1, self._base.upper) + #......... + property lower: + def __get__(self): + return floatarray_from_data(nest, 1, self._base.lower) -cdef class loess_model: - cdef c_loess.c_loess_model _model - cdef double span - cdef int degree, normalize - cdef char *family -# cdef ndarray parametric_flags, drop_square_flags - cdef object parametric_flags, drop_square_flags - # - def __init__(self, double span=0.75, int degree=2, int normalize=1, - object parametric_in=False, object drop_square_in=False, - object family="gaussian"): - cdef int i - cdef int *parmf_dat, *dropsq_dat - cdef npy_intp *npars - print "DEBUG: Initializing loess_model...", - self.span = self._model.span = span - self.degree = self._model.degree = degree - self.normalize = self._model.normalize = normalize - self.family = self._model.family = family - # FIXME : trying to use a ndarray crashes around here.... - self.parametric_flags = [None]*8 - if hasattr(parametric_in, '__len__'): - for i from 0 <= i < len(parametric_in): - self.parametric_flags[i] = parametric_in[i] - self._model.parametric[i] = parametric_in[i] - else: - for i from 0 <= i <=7: - self.parametric_flags[i] = parametric_in - self._model.parametric[i] = parametric_in - #.... - self.drop_square_flags = [None]*8 - if hasattr(drop_square_in, '__len__'): - for i from 0 <= i < len(drop_square_in): - self.drop_square_flags[i] = drop_square_in[i] - self._model.drop_square[i] = drop_square_in[i] - else: - for i from 0 <= i < 8: - self.drop_square_flags[i] = drop_square_in - self._model.drop_square[i] = drop_square_in - print "OK." -# npars[0] = 8 -# self.parametric = PyArray_EMPTY(1, npars, NPY_INT, NPY_ALIGNED) -# self.drop_square = PyArray_EMPTY(1, npars, NPY_INT, NPY_ALIGNED) -# parmf_dat = self.parametric_flags.data -# dropsq_dat = self.drop_square_flags.data -# for i from 0 <= i < 8: -# print "i:%i" % i -# parmf_dat[i] = 0 -# self._model.parametric[i] = parmf_dat[i] -# dropsq_dat[i] = 0 -# self._model.drop_square[i] = dropsq_dat[i] -# print "DEBUG: loess_model: initialized" - return - # - def __repr__(self): - return "loess model parameters @%s" % id(self) - def __str__(self): - strg = ["Object : %s" % self.__name__, - "family : %s" % self._model.family, - "span : %s" % self._model.span, - "degree : %s" % self._model.degree, - "normalized : %s" % self._model.normalize, - "parametric : %s" % self.parametric, - "drop_square : %s" % self.drop_square] - return '\n'.join(strg) +#####--------------------------------------------------------------------------- +#---- ---- loess predictions --- +#####--------------------------------------------------------------------------- +cdef class loess_predicted: + cdef c_loess.c_prediction *_base + cdef long nest + cdef confidence_interval conf_interval + #......... + def __dealloc__(self): + c_loess.pred_free_mem(self._base) + #......... + property predicted: + def __get__(self): + return floatarray_from_data(nest, 1, self._base.fit) + #......... + property predicted_stderr: + def __get__(self): + return floatarray_from_data(nest, 1, self._base.se_fit) + #......... + property residual_scale: + def __get__(self): + return self.residual_scale + #......... + property df: + def __get__(self): + return self.df + #......... + def confidence(self, coverage=0.95): + """ + coverage : float + Confidence level of the confidence intervals limits as a fraction. + """ + c_loess.pointwise(self._base, self.nest, coverage, + self.conf_interval._base) + #####--------------------------------------------------------------------------- #---- ---- loess base class --- #####--------------------------------------------------------------------------- - cdef class loess: -# cdef c_loess.c_loess *_base # If we try the pure C way cdef c_loess.c_loess _base - cdef loess_inputs inputs - cdef loess_model model - cdef loess_control control - cdef loess_kd_tree kd_tree - cdef loess_outputs outputs + cdef readonly loess_inputs inputs + cdef readonly loess_model model + cdef readonly loess_control control + cdef readonly loess_kd_tree kd_tree + cdef readonly loess_outputs outputs + cdef readonly loess_predicted predicted def __init__(self, object x, object y, object weights=None): # cdef ndarray x_ndr, y_ndr cdef double *x_dat, *y_dat - cdef long n, p cdef int i # -# print "Try setup" -# # CHECK : The following function segfaults :( -# c_loess.loess_setup(x_dat, y_dat, n, d, self._base) -# # CHECK : So we gonna try the hard way - # Initialize the python side ............ - self.inputs = loess_inputs(x, y, weights) - n = self.inputs.nobs - p = self.inputs.nvar + x_ndr = PyArray_FROMANY(x, NPY_DOUBLE, 1, 1, NPY_FORTRAN) + y_ndr = PyArray_FROMANY(y, NPY_DOUBLE, 1, 1, NPY_FORTRAN) + x_dat = x_ndr.data + y_dat = y_ndr.data + n = len(x_ndr) + p = x_ndr.size / n + c_loess.loess_setup(x_dat, y_dat, n, p, &self._base) + # + self.inputs = loess_inputs() + self.inputs._base = &self._base.inputs + # self.model = loess_model() + self.model._base = &self._base.model + self.model.npar = p + # self.control = loess_control() - self.outputs = loess_outputs(n,p) - self.kd_tree = loess_kd_tree(n,p) - # Initialize the C side ................. - print "DEBUG:Initializing loess_cside" - self._base.inputs = self.inputs._inputs - self._base.model = self.model._model - self._base.control = self.control._control - self._base.kd_tree = self.kd_tree._kdtree - self._base.outputs = self.outputs._outputs - - - -# self.inputs = base.in -# self.model = base.model -# self.kd_tree = base.kd_tree -# self.outputs = base.out - - + self.control._base = &self._base.control + # + self.kd_tree = loess_kd_tree() + self.kd_tree._base = &self._base.kd_tree + # + self.outputs = loess_outputs() + self.outputs._base = &self._base.outputs + self.outputs.nobs = n #...................................................... + def fit(self): + c_loess.loess_fit(&self._base) + return + #...................................................... def summary(self): - print "Number of Observations : %d" % self.inputs.n + print "Number of Observations : %d" % self.inputs.nobs print "Equivalent Number of Parameters: %.1f" % self.outputs.enp if self.model.family == "gaussian": print "Residual Standard Error : %.4f" % self.outputs.s else: - print "Residual Scale Estimate : %.4f" % self.outputs.s \ No newline at end of file + print "Residual Scale Estimate : %.4f" % self.outputs.s + #...................................................... + def predict(self, newdata, stderr=False): + """ + newdata: ndarray + A (m,p) ndarray specifying the values of the predictors at which the + evaluation is to be carried out. + stderr: Boolean + Logical flag for computing standard errors at newdata. + """ + cdef ndarray p_ndr + cdef double *p_dat + cdef int i, m + # + p_ndr = PyArray_FROMANY(newdata, NPY_DOUBLE, 1, self.nvar, NPY_FORTRAN) + p_dat = p_ndr.data + m = len(p_ndr) + c_loess.predict(p_dat, m, &self._base, self.predicted._base, stderr) + self.predicted.nest = m + #...................................................... +# def pointwisevoid(predicted *pre, int m, double coverage, +# struct ci_struct *ci) +# c_loess.pointwise(predicted *pre, int m, double coverage, +# struct ci_struct *ci) +# +#def anova(loess_one, loess_two): +# cdef c_loess.c_anova result +# +# c_loess.anova(loess_one._base, loess_two._base, &result) +# + \ No newline at end of file Modified: trunk/Lib/sandbox/pyloess/sandbox/src/loess.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/loess.c 2007-03-14 12:34:56 UTC (rev 2846) +++ trunk/Lib/sandbox/pyloess/sandbox/src/loess.c 2007-03-14 12:46:49 UTC (rev 2847) @@ -3,10 +3,12 @@ #include #include +#include + static char *surf_stat; void -loess_setup(double *x, double *y, int n, int p, loess *lo) +loess_setup(double *x, double *y, long n, long p, loess *lo) { int i, max_kd; @@ -43,8 +45,8 @@ lo->outputs.robust = (double *) malloc(n * sizeof(double)); lo->outputs.divisor = (double *) malloc(p * sizeof(double)); - lo->kd_tree.parameter = (int *) malloc(7 * sizeof(int)); - lo->kd_tree.a = (int *) malloc(max_kd * sizeof(int)); + lo->kd_tree.parameter = (long *) malloc(7 * sizeof(long)); + lo->kd_tree.a = (long *) malloc(max_kd * sizeof(long)); lo->kd_tree.xi = (double *) malloc(max_kd * sizeof(double)); lo->kd_tree.vert = (double *) malloc(p * 2 * sizeof(double)); lo->kd_tree.vval = (double *) malloc((p + 1) * max_kd * sizeof(double)); @@ -116,6 +118,12 @@ int cut, comp(); char *new_stat; void condition(); + char timestr[30]; + size_t timestri; + struct tm tim; + time_t now; + now = time(NULL); + tim = *(localtime(&now)); D = size_info[0]; N = size_info[1]; @@ -212,8 +220,10 @@ *one_delta = delta1; *two_delta = delta2; } + strftime(timestr,30,"%b %d, %Y; %H:%M:%S\n",&tim); + printf("%s", timestr); for(i = 0; i < N; i++) - printf("i:%i y:%.3f f:%.3f\n", i, y[i], fitted_values[i]); + printf("%.6f\n", fitted_values[i]); fitted_residuals[i] = y[i] - fitted_values[i]; if(j < (*iterations)) F77_SUB(lowesw)(fitted_residuals, &N, robust, temp); Modified: trunk/Lib/sandbox/pyloess/sandbox/src/loess.h =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/loess.h 2007-03-14 12:34:56 UTC (rev 2846) +++ trunk/Lib/sandbox/pyloess/sandbox/src/loess.h 2007-03-14 12:46:49 UTC (rev 2847) @@ -30,8 +30,8 @@ } loess_control; typedef struct { - int *parameter; - int *a; + long *parameter; + long *a; double *xi; double *vert; double *vval; @@ -64,18 +64,18 @@ double *se_fit; double residual_scale; double df; -} predicted; + } prediction; -struct anova_struct { +typedef struct { double dfn; double dfd; double F_value; double Pr_F; -}; + } anova_struct; -struct ci_struct { +typedef struct { double *fit; double *upper; double *lower; -}; + } conf_inv; Modified: trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c 2007-03-14 12:34:56 UTC (rev 2846) +++ trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c 2007-03-14 12:46:49 UTC (rev 2847) @@ -13,7 +13,7 @@ loess_raw(double *y, double *x, double *weights, double *robust, int *d, int*n, double *span, int *degree, int *nonparametric, int *drop_square, int *sum_drop_sqr, double *cell, char **surf_stat, - double *surface, int *parameter, int *a, double *xi, double *vert, + double *surface, long *parameter, long *a, double *xi, double *vert, double *vval, double *diagonal, double *trL, double *one_delta, double *two_delta, int *setLf) { @@ -116,7 +116,7 @@ loess_free(); } -loess_ifit(int *parameter, int *a, double *xi, double *vert, double *vval, +loess_ifit(long *parameter, long *a, double *xi, double *vert, double *vval, int *m, double *x_evaluate, double *fit) { loess_grow(parameter, a, xi, vert, vval); @@ -165,7 +165,7 @@ iv[i + 40] = drop_square[i]; } -loess_prune(int *parameter, int *a, double *xi, double *vert, double *vval) +loess_prune(long *parameter, long *a, double *xi, double *vert, double *vval) { int d, vc, a1, v1, xi1, vv1, nc, nv, nvmax, i, j, k; @@ -198,7 +198,7 @@ vval[i] = v[vv1 + i]; } -loess_grow(int *parameter, int *a, double *xi, double *vert, double *vval) +loess_grow(long *parameter, long *a, double *xi, double *vert, double *vval) { int d, vc, nc, nv, a1, v1, xi1, vv1, i, j, k; Modified: trunk/Lib/sandbox/pyloess/sandbox/src/misc.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/misc.c 2007-03-14 12:34:56 UTC (rev 2846) +++ trunk/Lib/sandbox/pyloess/sandbox/src/misc.c 2007-03-14 12:46:49 UTC (rev 2847) @@ -3,24 +3,18 @@ #include #include -static double -fmin(double a, double b) +static double fmin(double a, double b) { return(a < b ? a : b); } -static double -fmax(double a, double b) +static double fmax(double a, double b) { return(a > b ? a : b); } - - -void -anova(loess *one, loess *two, - struct anova_struct *out) +void anova(loess *one, loess *two, anova_struct *out) { double one_d1, one_d2, one_s, two_d1, two_d2, two_s, rssdiff, d1diff, tmp, pf(); @@ -44,9 +38,7 @@ out->Pr_F = 1 - pf(out->F_value, out->dfn, out->dfd); } -void -pointwise(predicted *pre, int m, double coverage, - struct ci_struct *ci) +void pointwise(prediction *pre, int m, double coverage, conf_inv *ci) { double t_dist, limit, fit, qt(); int i; @@ -64,23 +56,20 @@ } } -void -pw_free_mem(struct ci_struct *ci) +void pw_free_mem(conf_inv *ci) { free(ci->fit); free(ci->upper); free(ci->lower); } -double -pf(double q, double df1, double df2) +double pf(double q, double df1, double df2) { double ibeta(); return(ibeta(q*df1/(df2+q*df1), df1/2, df2/2)); } -double -qt(double p, double df) +double qt(double p, double df) { double t, invibeta(); t = invibeta(fabs(2*p-1), 0.5, df/2); @@ -97,8 +86,7 @@ #define IBETA_LARGE 1.0e30 #define IBETA_SMALL 1.0e-30 -double -ibeta(double x, double a, double b) +double ibeta(double x, double a, double b) { int flipped = 0, i, k, count; double I, temp, pn[6], ak, bk, next, prev, factor, val; @@ -169,8 +157,7 @@ 0.001308 }; -double -invigauss_quick(double p) +double invigauss_quick(double p) { int lower; double t, n, d, q; @@ -191,8 +178,7 @@ * Assumption: 0 <= p <= 1, a,b > 0. */ -double -invibeta(double p, double a, double b) +double invibeta(double p, double a, double b) { int i; double ql, qr, qm, qdiff; @@ -280,8 +266,7 @@ * Assumption: 0 < p < 1, a,b > 0. */ -double -invibeta_quick(double p, double a, double b) +double invibeta_quick(double p, double a, double b) { double x, m, s, fmax(), fmin(), invigauss_quick(); @@ -291,8 +276,7 @@ return(fmax(0.0, fmin(1.0, invigauss_quick(p)*s + m))); } -int -max(int a, int b) +int max(int a, int b) { return(a > b ? a : b); } @@ -300,15 +284,13 @@ typedef double doublereal; typedef int integer; -void -Recover(char *a, int *b) +void Recover(char *a, int *b) { printf(a); exit(1); } -void -Warning(char *a, int *b) +void Warning(char *a, int *b) { printf(a); } From scipy-svn at scipy.org Wed Mar 14 12:53:04 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 14 Mar 2007 11:53:04 -0500 (CDT) Subject: [Scipy-svn] r2848 - in trunk/Lib/stsci/convolve: . lib src Message-ID: <20070314165304.8BFEA39C00F@new.scipy.org> Author: chanley Date: 2007-03-14 11:52:59 -0500 (Wed, 14 Mar 2007) New Revision: 2848 Added: trunk/Lib/stsci/convolve/lib/lineshape.py trunk/Lib/stsci/convolve/src/_lineshapemodule.c Modified: trunk/Lib/stsci/convolve/setup.py Log: Adding numpy version of numarray's lineshape module from the convolve package. Added: trunk/Lib/stsci/convolve/lib/lineshape.py =================================================================== --- trunk/Lib/stsci/convolve/lib/lineshape.py 2007-03-14 12:46:49 UTC (rev 2847) +++ trunk/Lib/stsci/convolve/lib/lineshape.py 2007-03-14 16:52:59 UTC (rev 2848) @@ -0,0 +1,102 @@ +# lineshape functors +# -*- coding: iso-8859-1 -*- +# +# Copyright (C) 2002 Jochen K?pper +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +__doc__ = """Lineshape functors. + +The objects defined in this module can be used to calculate numarrays containing +common lineshape-profiles. + +For the *Profile classes the profile is only evaluated once for each object and +then reused for each call. If you only use a profile once and you are concerned +about memory consumption you could call the underlying functions directly. +""" + +__author__ = "Jochen K?pper " +__date__ = "$Date: 2007/03/14 16:35:57 $"[7:-11] +__version__ = "$Revision: 1.1 $"[11:-2] + + +import numpy as num +from convolve._lineshape import * + + +class Profile(object): + """An base object to provide a convolution kernel.""" + + def __init__(self, x, w, x0=0.0): + # call init for all superclasses + super(Profile, self).__init__(x, w, x0) + self._recalculate(x, w, x0) + + def __call__(self): + return self._kernel + + def _recalculate(self, x, w, x0): + self._kernel = self._profile(x, w, x0) + + +class GaussProfile(Profile): + """An object for Gauss-folding.""" + + def __init__(self, x, w, x0=0.0): + self._profile = gauss + # call init for all superclasses + super(GaussProfile, self).__init__(x, w, x0) + + +class LorentzProfile(Profile): + """An object for Lorentz-folding.""" + + def __init__(self, x, w, x0=0.0): + self._profile = lorentz + # call init for all superclasses + super(LorentzProfile, self).__init__(x, w, x0) + + + +class VoigtProfile(Profile): + """An object for Voigt-folding. + + The constructor takes the following parameter: + |x| Scalar or numarray with values to calculate profile at. + |w| Tuple of Gaussian and Lorentzian linewidth contribution + |x0| Center frequency + """ + + def __init__(self, x, w, x0=0.0): + self._profile = voigt + # call init for all superclasses + super(VoigtProfile, self).__init__(x, w, x0) + + + +## Local Variables: +## mode: python +## mode: auto-fill +## fill-column: 80 +## End: Modified: trunk/Lib/stsci/convolve/setup.py =================================================================== --- trunk/Lib/stsci/convolve/setup.py 2007-03-14 12:46:49 UTC (rev 2847) +++ trunk/Lib/stsci/convolve/setup.py 2007-03-14 16:52:59 UTC (rev 2848) @@ -10,6 +10,10 @@ sources=["src/_correlatemodule.c"], define_macros = [('NUMPY', '1')], include_dirs = [numpy.get_numarray_include()]) + config.add_extension('_lineshape', + sources=["src/_lineshapemodule.c"], + define_macros = [('NUMPY', '1')], + include_dirs = [numpy.get_numarray_include()]) return config if __name__ == "__main__": Added: trunk/Lib/stsci/convolve/src/_lineshapemodule.c =================================================================== --- trunk/Lib/stsci/convolve/src/_lineshapemodule.c 2007-03-14 12:46:49 UTC (rev 2847) +++ trunk/Lib/stsci/convolve/src/_lineshapemodule.c 2007-03-14 16:52:59 UTC (rev 2848) @@ -0,0 +1,381 @@ +/* C implementations of various lineshape functions + * + * Copyright (C) 2002,2003 Jochen K?pper + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "Python.h" + +#include + +#include "numpy/libnumarray.h" + + +#define sqr(x) ((x)*(x)) + + +/* These are apparently not defined in MSVC */ +#if !defined(M_PI) +#define M_PI 3.14159265358979323846 +#endif +#if !defined(M_LN2) +#define M_LN2 0.69314718055994530942 +#endif + + +/*** C implementation ***/ + +static void gauss(size_t n, double *x, double *y, double w, double xc) + /* Evaluate normalized Gauss profile around xc with FWHM w at all x_i, + return in y. */ +{ + int i; + for(i=0; i 0.85) || (fabs(x) < (18.1 * y + 1.65))) { + /* Bereich I */ + for(k=0; k<6; k++) { + xp = x + T_v12[k]; + xm = x - T_v12[k]; + sum += ((alpha_v12[k] * xm + beta_v12[k] * yp) / (xm * xm + yp2) + + (beta_v12[k] * yp - alpha_v12[k] * xp) / (xp * xp + yp2)); + } + } else { + /* Bereich II */ + for(k=0; k<6; k++) { + xp = x + T_v12[k]; + xp2 = xp * xp; + xm = x - T_v12[k]; + xm2 = xm * xm; + sum += (((beta_v12[k] * (xm2 - y0_v12 * yp) - alpha_v12[k] * xm * (yp + y0_v12)) + / ((xm2 + yp2) * (xm2 + y0_v12 * y0_v12))) + + ((beta_v12[k] * (xp2 - y0_v12 * yp) + alpha_v12[k] * xp * (yp + y0_v12)) + / ((xp2 + yp2) * (xp2 + y0_v12 * y0_v12)))); + } + if(fabs(x) < 100.) + sum = y * sum + exp(-pow(x, 2)); + else + sum *= y; + } + return sum; +} + + +static void voigt(size_t n, double *x, double *y, double w[2], double xc) + /* Evaluate normalized Voigt profile at x around xc with Gaussian + * linewidth contribution w[0] and Lorentzian linewidth + * contribution w[1]. + */ +{ + /* Transform into reduced coordinates and call Humlicek's 12 point + * formula: + * x = 2 \sqrt{\ln2} \frac{\nu-\nu_0}{\Delta\nu_G} + * y = \sqrt{\ln2} \frac{\Delta\nu_L}{\Delta\nu_G} + */ + int i; + double yh = sqrt(M_LN2) * w[1] / w[0]; + for(i=0; ind != 1) + return PyErr_Format(_Error, "gauss: x must be scalar or 1d array."); + if (!NA_ShapeEqual(x, y)) + return PyErr_Format(_Error, "gauss: x and y numarray must have same length."); + + /* calculate profile */ + { + double *xa = NA_OFFSETDATA(x); + double *ya = NA_OFFSETDATA(y); + Py_BEGIN_ALLOW_THREADS; + gauss(x->dimensions[0], xa, ya, w, xc); + Py_END_ALLOW_THREADS; + } + + /* cleanup and return */ + Py_XDECREF(x); + return NA_ReturnOutput(oy, y); + } +} + + + +static PyObject * +_lineshape_lorentz(PyObject *self, PyObject *args, PyObject *keywds) +{ + int f; + double w, xc = 0.0; + static char *kwlist[] = {"x", "w", "xc", "y", NULL}; + PyObject *ox, *oy=Py_None; + PyArrayObject *x, *y; + + if(! PyArg_ParseTupleAndKeywords(args, keywds, "Od|dO", kwlist, + &ox, &w, &xc, &oy)) + return PyErr_Format(PyExc_RuntimeError, "lorentz: invalid parameters"); + + if((f = PyFloat_Check(ox)) || PyInt_Check(ox)) { + /* scalar arguments -- always *return* Float result */ + double xa[1], ya[1]; + if(f) + xa[0] = PyFloat_AS_DOUBLE(ox); + else + xa[0] = (double)PyInt_AS_LONG(ox); + Py_BEGIN_ALLOW_THREADS; + lorentz(1, xa, ya, w, xc); + Py_END_ALLOW_THREADS; + Py_DECREF(ox); + return PyFloat_FromDouble(ya[0]); + } else { + /* array conversion */ + if(! ((x = NA_InputArray(ox, tFloat64, C_ARRAY)) + && (y = NA_OptionalOutputArray(oy, tFloat64, C_ARRAY, x)))) + return 0; + if(x->nd != 1) + return PyErr_Format(_Error, "lorentz: x must be scalar or 1d array."); + if (!NA_ShapeEqual(x, y)) + return PyErr_Format(_Error, "lorentz: x and y numarray must have same length."); + + /* calculate profile */ + { + double *xa = NA_OFFSETDATA(x); + double *ya = NA_OFFSETDATA(y); + + Py_BEGIN_ALLOW_THREADS; + lorentz(x->dimensions[0], xa, ya, w, xc); + Py_END_ALLOW_THREADS; + } + + /* cleanup and return */ + Py_XDECREF(x); + return NA_ReturnOutput(oy, y); + } +} + + + +static PyObject * +_lineshape_voigt(PyObject *self, PyObject *args, PyObject *keywds) +{ + int f; + double w[2], xc = 0.0; + static char *kwlist[] = {"x", "w", "xc", "y", NULL}; + PyObject *wt, *ox, *oy=Py_None; + PyArrayObject *x, *y; + + if(! PyArg_ParseTupleAndKeywords(args, keywds, "OO|dO", kwlist, + &ox, &wt, &xc, &oy)) + return PyErr_Format(PyExc_RuntimeError, "voigt: invalid parameters"); + + /* parse linewidths tuple */ + if(! PyArg_ParseTuple(wt, "dd", &(w[0]), &(w[1]))) + return(0); + + if((f = PyFloat_Check(ox)) || PyInt_Check(ox)) { + /* scalar arguments -- always *return* Float result */ + double xa[1], ya[1]; + if(f) + xa[0] = PyFloat_AS_DOUBLE(ox); + else + xa[0] = (double)PyInt_AS_LONG(ox); + Py_BEGIN_ALLOW_THREADS; + voigt(1, xa, ya, w, xc); + Py_END_ALLOW_THREADS; + Py_DECREF(ox); + return PyFloat_FromDouble(ya[0]); + } else { + /* array conversion */ + if(! ((x = NA_InputArray(ox, tFloat64, C_ARRAY)) + && (y = NA_OptionalOutputArray(oy, tFloat64, C_ARRAY, x)))) + return 0; + if(x->nd != 1) + return PyErr_Format(_Error, "voigt: x must be scalar or 1d array."); + if (!NA_ShapeEqual(x, y)) + return PyErr_Format(_Error, "voigt: x and y numarray must have same length."); + + /* calculate profile */ + { + double *xa = NA_OFFSETDATA(x); + double *ya = NA_OFFSETDATA(y); + Py_BEGIN_ALLOW_THREADS; + voigt(x->dimensions[0], xa, ya, w, xc); + Py_END_ALLOW_THREADS; + } + + /* cleanup and return */ + Py_XDECREF(x); + return NA_ReturnOutput(oy, y); + } +} + + + + +/*** table of methods ***/ + +static PyMethodDef _lineshape_Methods[] = { + {"gauss", (PyCFunction)_lineshape_gauss, METH_VARARGS|METH_KEYWORDS, + "gauss(x, w, xc=0.0, y=None)\n\n" + "Gaussian lineshape function\n\n" \ + "Calculate normalized Gaussian with full-width at half maximum |w| at |x|,\n" \ + "optionally specifying the line-center |xc|.\n" \ + "If, and only if |x| is an array an optional output array |y| can be\n" \ + "specified. In this case |x| and |y| must be one-dimensional numarray\n" \ + "with identical shapes.\n\n" \ + "If |x| is an scalar the routine always gives the result as scalar\n" \ + "return value." + }, + {"lorentz", (PyCFunction)_lineshape_lorentz, METH_VARARGS|METH_KEYWORDS, + "lorentz(x, w, xc=0.0, y=None)\n\n" + "Lorentzian lineshape function\n\n" \ + "Calculate normalized Lorentzian with full-width at half maximum |w| at |x|,\n" \ + "optionally specifying the line-center |xc|.\n" \ + "If, and only if |x| is an array an optional output array |y| can be\n" \ + "specified. In this case |x| and |y| must be one-dimensional numarray\n" \ + "with identical shapes.\n\n" \ + "If |x| is an scalar the routine always gives the result as scalar\n" \ + "return value." + }, + {"voigt", (PyCFunction)_lineshape_voigt, METH_VARARGS|METH_KEYWORDS, + "voigt(x, w, xc=0.0, y=None)\n\n" + "Voigt-lineshape function\n\n" \ + "Calculate normalized Voigt-profile with Gaussian full-width at half maximum |w[0]| and\n" \ + "Lorentzian full-width at half maximum |w[1]| at |x|, optionally specifying the line-center\n" \ + "|xc|.\n" \ + "If, and only if |x| is an array an optional output array |y| can be\n" \ + "specified. In this case |x| and |y| must be one-dimensional numarray\n" \ + "with identical shapes.\n\n" \ + "If |x| is an scalar the routine always gives the result as scalar\n" \ + "return value.\n\n" \ + "This function uses Humlicek's 12-point formula to approximate the Voigt\n" \ + "profile (J. Humlicek, J. Quant. Spectrosc. Radiat. Transfer, 21, 309 (1978))." + }, + {NULL, NULL, 0, ""} +}; + + + + +/*** module initialization ***/ + +DL_EXPORT(void) init_lineshape(void) +{ + PyObject *m, *d; + m = Py_InitModule("_lineshape", _lineshape_Methods); + d = PyModule_GetDict(m); + _Error = PyErr_NewException("_lineshape.error", NULL, NULL); + PyDict_SetItemString(d, "error", _Error); + import_libnumarray(); +} + + + +/* + * Local Variables: + * mode: c + * c-file-style: "Stroustrup" + * fill-column: 80 + * End: + */ From scipy-svn at scipy.org Fri Mar 16 16:43:08 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 16 Mar 2007 15:43:08 -0500 (CDT) Subject: [Scipy-svn] r2849 - in trunk/Lib/sandbox/pyloess/sandbox: . examples src Message-ID: <20070316204308.7062439C014@new.scipy.org> Author: pierregm Date: 2007-03-16 15:42:51 -0500 (Fri, 16 Mar 2007) New Revision: 2849 Added: trunk/Lib/sandbox/pyloess/sandbox/examples/gas_data trunk/Lib/sandbox/pyloess/sandbox/examples/gas_result trunk/Lib/sandbox/pyloess/sandbox/examples/madeup_data trunk/Lib/sandbox/pyloess/sandbox/examples/madeup_result Modified: trunk/Lib/sandbox/pyloess/sandbox/pyloess.py trunk/Lib/sandbox/pyloess/sandbox/src/c_numpy.pxd trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx trunk/Lib/sandbox/pyloess/sandbox/src/loess.c trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c Log: updated loess. Still in sandbox till some of issues are not dealt with. Globally, it works when it should. Problems: - when F functions exit abnormally, we should catch the output and process it as an exception instead of brute exit. - ndarray arguments should be modifiable elementwise - find where the "Exception exceptions.NameError: 'c_loess' in ignored" comes from - add anova Added: trunk/Lib/sandbox/pyloess/sandbox/examples/gas_data =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/examples/gas_data 2007-03-14 16:52:59 UTC (rev 2848) +++ trunk/Lib/sandbox/pyloess/sandbox/examples/gas_data 2007-03-16 20:42:51 UTC (rev 2849) @@ -0,0 +1,3 @@ +E (observations) +0.831000 1.045000 1.021000 0.970000 0.825000 0.891000 0.710000 0.801000 1.074000 1.148000 1.000000 0.928000 0.767000 0.701000 0.807000 0.902000 0.997000 1.224000 1.089000 0.973000 0.980000 0.665000 NOx (response) +4.818000 2.849000 3.275000 4.691000 4.255000 5.064000 2.118000 4.602000 2.286000 0.970000 3.965000 5.344000 3.834000 1.990000 5.199000 5.283000 3.752000 0.537000 1.640000 5.055000 4.937000 1.561000 \ No newline at end of file Added: trunk/Lib/sandbox/pyloess/sandbox/examples/gas_result =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/examples/gas_result 2007-03-14 16:52:59 UTC (rev 2848) +++ trunk/Lib/sandbox/pyloess/sandbox/examples/gas_result 2007-03-16 20:42:51 UTC (rev 2849) @@ -0,0 +1,10 @@ +loess(&gas): +4.883437 2.927639 3.572746 4.710510 4.815363 5.196193 2.512832 4.474939 2.149797 0.990044 4.089353 5.303627 3.864174 2.267121 4.575636 5.240293 4.154036 0.523682 1.853026 4.659184 4.521148 1.196414 +loess(&gas_null): +4.892690 3.362733 3.728575 4.489023 4.831715 5.177112 2.535887 4.530370 2.873000 1.453502 4.059136 5.052650 3.943568 2.265232 4.614320 5.163913 4.107184 -0.276342 2.604373 4.445040 4.351615 1.051719 +predict(gas_fit_E, m, &gas, &gas_pred, 0): +1.196414 5.068747 0.523682 +pointwise(&gas_pred, m, coverage, &gas_ci): +0.407208 1.196414 1.985621 3.249187 3.679498 4.109808 4.631187 5.055708 5.480229 4.704010 5.135260 5.566510 2.759703 3.143656 3.527609 0.683247 1.196932 1.710617 -0.424684 0.523682 1.472049 +anova(&gas_null, &gas, &gas_anova): +2.5531 15.663 10.1397 0.000860102 Added: trunk/Lib/sandbox/pyloess/sandbox/examples/madeup_data =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/examples/madeup_data 2007-03-14 16:52:59 UTC (rev 2848) +++ trunk/Lib/sandbox/pyloess/sandbox/examples/madeup_data 2007-03-16 20:42:51 UTC (rev 2849) @@ -0,0 +1,4 @@ +one_two (observations) +-0.957581 -2.809549 -0.696511 3.451000 0.509260 0.557854 0.052582 -2.050644 -1.115675 -1.183665 0.511959 0.334364 -2.057062 -0.121897 0.544238 0.600502 0.531074 0.495400 -1.608602 0.277371 0.290464 0.579894 -0.290441 1.306226 -0.482898 -0.716423 0.742413 -0.911613 1.279436 -0.189153 0.592293 0.952416 0.491436 -0.305681 -0.363871 -0.285424 -0.037209 -0.923529 1.138054 -1.331223 0.551234 -0.852726 1.196875 0.498782 0.320180 0.212447 1.009358 -0.900989 1.132164 0.018867 0.424170 -0.198621 0.955170 0.948321 0.473848 -0.699121 -0.612853 0.580431 1.277996 0.806797 -1.038559 1.008663 -0.578257 -0.323245 -0.756302 1.386352 0.722419 -1.216078 -0.498280 0.726247 -0.260119 -0.741135 -0.184111 0.307762 0.464568 -0.252531 -0.486504 0.426634 -1.303969 0.067149 1.771176 0.907249 0.432350 1.419897 -0.413389 2.442025 0.041138 0.509505 -0.282744 0.179882 -1.188083 0.982653 -1.042886 1.181365 -0.398340 -1.335565 -0.502790 0.484762 -0.806446 1.412077 -0.878874 -0.935197 -0.339255 0.164497 1.370018 -1.494684 1.380505 0.885084 0.835609 0.896235 -1.289541 0.233203 1.183198 -0.857934 -1.334234 -0.923351 0.769146 -0.377948 0.059114 -1.870615 -0.677868 0.038185 0.375301 0.964717 0.695051 -0.342140 -1.145463 -0.993246 -0.130573 1.213711 0.291241 1.106891 0.949571 0.463675 0.455723 0.398786 -0.015849 -1.397373 0.770062 0.083291 0.531798 0.049727 -0.734140 -0.963487 0.573561 -0.281942 -0.594503 0.770262 1.073983 -0.615706 -0.084794 -0.491630 -1.526969 -0.196881 0.165653 0.198357 0.974930 -0.954848 0.588474 -0.426883 0.177119 -0.916442 -1.885139 0.086894 0.456306 0.174285 -0.001308 -0.000585 0.284023 -0.365679 -0.548867 0.857848 0.699094 -0.140026 1.332454 1.601795 0.012415 0.243429 1.077369 1.859246 0.185910 0.033342 0.613008 1.068595 -0.683305 -0.128826 -1.655525 0.013086 0.062454 0.773042 0.127046 0.408652 1.195438 -0.185558 -1.299714 0.899675 -0.033648 -1.544602 0.655203 -0.713935 +response +14.453553 6.622825 13.671414 14.197518 12.860530 12.522856 14.214638 7.924264 12.506938 13.734205 14.710855 13.596223 5.890019 13.558654 14.043167 13.931391 13.218920 17.090560 15.199322 13.261667 15.760636 12.083855 14.344907 12.609494 11.932959 13.408674 13.700765 13.013366 15.794999 14.600198 16.275751 11.564349 14.809023 12.982361 15.003502 14.737337 15.747677 11.674508 14.047278 14.666917 13.806240 13.611149 13.347149 14.225152 14.718846 14.217216 14.418058 14.719634 12.799716 13.933038 15.264603 14.660387 9.738691 14.443424 14.417284 15.184538 13.344938 15.372943 13.811554 15.103777 15.383834 14.368612 12.525202 14.325033 15.259658 13.004547 14.515988 15.176982 14.924187 13.872430 15.395366 13.428076 15.203430 14.186631 13.305833 14.074624 14.103092 13.499669 11.584675 14.264891 14.885616 13.967297 16.604680 10.367606 14.743473 16.308827 14.108673 13.590988 14.674546 15.294047 14.686723 13.611422 11.970270 13.884157 15.071776 12.589816 13.818745 14.245317 14.406530 14.347941 \ No newline at end of file Added: trunk/Lib/sandbox/pyloess/sandbox/examples/madeup_result =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/examples/madeup_result 2007-03-14 16:52:59 UTC (rev 2848) +++ trunk/Lib/sandbox/pyloess/sandbox/examples/madeup_result 2007-03-16 20:42:51 UTC (rev 2849) @@ -0,0 +1,16 @@ +loess(&madeup): +13.898675 5.225583 14.265096 14.237045 13.366442 13.157273 14.189032 7.971348 13.215581 12.835208 13.967757 14.457845 6.039091 14.722007 13.758002 14.654508 14.243303 14.733353 13.696778 12.510036 15.026972 14.346972 14.547927 11.702517 14.222303 14.288345 13.755227 13.742749 14.250887 14.188543 14.388616 12.552611 14.100045 14.552719 14.514971 14.556744 14.496872 12.868609 12.871890 14.427522 14.410413 14.598345 13.415146 14.731999 14.657565 14.778805 13.988940 13.723749 11.932352 14.908485 14.457978 14.616147 11.100703 14.254687 14.411890 14.519007 13.734456 14.634786 13.080897 14.415189 14.623631 13.340049 12.584224 14.510466 14.293842 13.954341 14.281046 14.643596 14.492646 14.497077 14.497688 13.732467 14.573564 14.548255 13.560984 13.917026 14.496924 14.452028 11.687567 13.865395 13.908958 14.184016 14.514209 10.835782 14.203921 15.273614 13.702645 14.383224 14.506619 14.707063 14.595778 13.877506 12.326903 14.236236 13.962165 12.281695 14.477443 13.192765 13.985441 13.206705 +loess(&madeup_new): +12.874079 10.889912 14.072472 14.688408 13.581655 13.741506 12.966195 11.778153 12.623840 12.391277 13.915575 14.549806 10.648311 13.714716 13.908051 14.338239 13.839956 14.661187 14.500423 12.892713 14.344422 14.557473 14.294094 14.258892 13.410545 14.058327 14.340850 12.675257 14.839750 12.706903 14.551439 14.002773 13.589104 14.094192 14.098484 14.246415 14.548803 11.925623 14.212327 14.501013 14.199258 14.517379 15.151176 14.202325 14.044125 14.549456 15.030205 12.957176 14.170346 14.166684 14.617600 14.160491 14.230993 14.821136 14.547624 14.489024 12.630700 14.292239 14.381246 14.834949 14.480650 14.747398 11.611371 14.519760 13.997474 14.591257 14.591759 14.478131 14.427821 14.785485 14.034793 12.821834 13.556879 14.606041 13.505266 12.561710 14.525273 14.555914 11.728344 13.296039 14.621341 14.570526 14.015254 14.451527 13.670446 15.113971 12.849321 14.570355 14.526773 13.616773 14.493652 14.496696 11.739043 14.886699 12.740301 12.265455 14.504240 13.584999 13.370259 15.378514 +loess(&madeup_new) (family = symmetric): +13.853372 13.076392 14.410502 14.317606 13.530344 13.909561 13.483542 13.661465 13.738437 13.662424 14.078653 14.471725 13.362504 14.161261 14.056621 14.370400 13.827138 14.543779 14.563051 13.263340 14.405462 14.511807 14.391442 13.655949 13.919863 14.406599 14.307597 13.717301 14.561751 13.479815 14.423533 13.588048 13.644027 14.268385 14.283955 14.361030 14.528760 13.151054 13.826620 14.570806 14.120641 14.538117 14.640103 14.309962 14.069715 14.527437 14.606612 13.824681 13.607361 14.370144 14.535820 14.399329 14.122194 14.580712 14.478250 14.541334 13.593458 14.346338 14.016117 14.580121 14.566098 14.522580 12.578184 14.528995 14.305679 14.422916 14.523434 14.533691 14.490958 14.574831 14.352653 13.714577 13.911857 14.540189 13.522831 13.495538 14.528432 14.462617 13.481391 13.705501 14.399779 14.509204 14.010568 13.623165 14.211318 14.586042 13.392231 14.520972 14.525897 13.822231 14.577431 14.267078 13.423198 14.589490 13.573646 13.655627 14.531561 13.811793 13.979165 14.705119 +loess(&madeup_new) (normalize = FALSE): +13.853372 13.076392 14.410502 14.317606 13.530344 13.909561 13.483542 13.661465 13.738437 13.662424 14.078653 14.471725 13.362504 14.161261 14.056621 14.370400 13.827138 14.543779 14.563051 13.263340 14.405462 14.511807 14.391442 13.655949 13.919863 14.406599 14.307597 13.717301 14.561751 13.479815 14.423533 13.588048 13.644027 14.268385 14.283955 14.361030 14.528760 13.151054 13.826620 14.570806 14.120641 14.538117 14.640103 14.309962 14.069715 14.527437 14.606612 13.824681 13.607361 14.370144 14.535820 14.399329 14.122194 14.580712 14.478250 14.541334 13.593458 14.346338 14.016117 14.580121 14.566098 14.522580 12.578184 14.528995 14.305679 14.422916 14.523434 14.533691 14.490958 14.574831 14.352653 13.714577 13.911857 14.540189 13.522831 13.495538 14.528432 14.462617 13.481391 13.705501 14.399779 14.509204 14.010568 13.623165 14.211318 14.586042 13.392231 14.520972 14.525897 13.822231 14.577431 14.267078 13.423198 14.589490 13.573646 13.655627 14.531561 13.811793 13.979165 14.705119 +predict(newdata1, m, &madeup, &madeup_pred, 0): +8.156780 14.493587 14.854142 +predict(newdata2, m, &madeup, &madeup_pred, 1): +14.491811 14.389726 +pointwise(&madeup_pred, m, coverage, &madeup_ci): +13.761833 14.491811 15.221789 13.656419 14.389726 15.123034 +anova(&madeup2, &madeup, &madeup_anova): +6.45034 81.2319 2.85933 0.0121449 Modified: trunk/Lib/sandbox/pyloess/sandbox/pyloess.py =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/pyloess.py 2007-03-14 16:52:59 UTC (rev 2848) +++ trunk/Lib/sandbox/pyloess/sandbox/pyloess.py 2007-03-16 20:42:51 UTC (rev 2849) @@ -1,517 +1,250 @@ import os from math import ceil -import numpy -from numpy import bool_, int_, float_ +import numpy as N +from numpy.testing import NumpyTest, NumpyTestCase +from numpy.testing.utils import build_err_msg, \ + assert_equal, assert_almost_equal -narray = numpy.array -nempty = numpy.empty -nzeros = numpy.zeros - -import logging -logging.basicConfig(level=logging.DEBUG) -loesslogging = logging.getLogger('loesss') - import cloess reload(cloess) +from cloess import loess -class paramdict(dict): - def __init__(self, **kwargs): - dict.__init__(self, **kwargs) - - def __getattr__(self, attr): - _got = getattr(super(paramdict,self), attr, None) - if _got is None: - _got = self.get(attr, None) - return _got +#####--------------------------------------------------------------------------- +#---- --- test 2D +#####--------------------------------------------------------------------------- - def __setattr__(self, attr, value): - if attr in self.keys(): - self[attr] = value +class test_loess2d(NumpyTestCase): + "Test class for lowess." + # + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + dfile = open(os.path.join('examples','madeup_data'), 'r') + dfile.readline() + x = N.fromiter((float(v) for v in dfile.readline().rstrip().split()), + N.float_).reshape(-1,2) + dfile.readline() + y = N.fromiter((float(v) for v in dfile.readline().rstrip().split()), + N.float_) + dfile = open(os.path.join('examples','madeup_data'), 'r') + dfile.readline() + # + rfile = open(os.path.join('examples','madeup_result'), 'r') + results = [] + for i in range(8): + rfile.readline() + z = N.fromiter((float(v) for v in rfile.readline().rstrip().split()), + N.float_) + results.append(z) + # + newdata1 = N.array([[-2.5, 0.0, 2.5], [0., 0., 0.]]) + newdata2 = N.array([[-0.5, 0.5], [0., 0.]]) + # + madeup = cloess.loess(x,y) + self.d = (x, y, results, newdata1, newdata2, madeup) + # + def test_2dbasic(self): + "2D standard" + (x, y, results, newdata1, newdata2, madeup) = self.d + madeup = cloess.loess(x,y) + madeup.model.span = 0.5 + madeup.model.normalize = True + madeup.fit() + assert_almost_equal(madeup.outputs.fitted_values, results[0], 5) + assert_almost_equal(madeup.outputs.enp, 14.9, 1) + assert_almost_equal(madeup.outputs.s, 0.9693, 4) + # +# def test_2d_modflags_ez(self): +# "2D - modification of model flags" +# (x, y, results, newdata1, newdata2, madeup) = self.d +# madeup = cloess.loess(x,y) +# madeup.model.span = 0.8 +# madeup.model.drop_square_flags[0] = True +# madeup.model.parametric_flags[0] = True +# assert_equal(madeup.model.parametric_flags[:2],[1,0]) +# madeup.fit() +# assert_almost_equal(madeup.outputs.fitted_values, results[1], 5) +# assert_almost_equal(madeup.outputs.enp, 6.9, 1) +# assert_almost_equal(madeup.outputs.s, 1.4804, 4) + # + def test_2d_modflags_tot(self): + "2D - modification of model flags" + (x, y, results, newdata1, newdata2, madeup) = self.d + madeup = cloess.loess(x,y) + madeup.model.span = 0.8 + madeup.model.drop_square_flags = [True, False] + madeup.model.parametric_flags = [True, False] + assert_equal(madeup.model.parametric_flags[:2],[1,0]) + madeup.fit() + assert_almost_equal(madeup.outputs.fitted_values, results[1], 5) + assert_almost_equal(madeup.outputs.enp, 6.9, 1) + assert_almost_equal(madeup.outputs.s, 1.4804, 4) + # + def test_2d_modfamily(self): + "2D - family modification" + (x, y, results, newdata1, newdata2, madeup) = self.d + madeup.model.span = 0.8 + madeup.model.drop_square_flags = [True, False] + madeup.model.parametric_flags = [True, False] + madeup.model.family = "symmetric" + madeup.fit() + assert_almost_equal(madeup.outputs.fitted_values, results[2], 5) + assert_almost_equal(madeup.outputs.enp, 6.9, 1) + assert_almost_equal(madeup.outputs.s, 1.0868, 4) + # + def test_2d_modnormalize(self): + "2D - normalization modification" + (x, y, results, newdata1, newdata2, madeup) = self.d + madeup.model.span = 0.8 + madeup.model.drop_square_flags = [True, False] + madeup.model.parametric_flags = [True, False] + madeup.model.family = "symmetric" + madeup.model.normalize = False + madeup.fit() + assert_almost_equal(madeup.outputs.fitted_values, results[3], 5) + assert_almost_equal(madeup.outputs.enp, 6.9, 1) + assert_almost_equal(madeup.outputs.s, 1.0868, 4) + # + def test_2d_pred_nostderr(self): + "2D prediction - no stderr" + (x, y, results, newdata1, newdata2, madeup) = self.d + madeup.model.span = 0.5 + madeup.model.normalize = True + madeup.predict(newdata1, stderr=False) + assert_almost_equal(madeup.predicted.values, results[4], 5) + # + madeup_pred = madeup.predict(newdata1, stderr=False) + assert_almost_equal(madeup_pred.values, results[4], 5) + # + def test_2d_pred_nodata(self): + "2D prediction - nodata" + (x, y, results, newdata1, newdata2, madeup) = self.d + try: + madeup.predict(None) + except ValueError: + pass else: - dict.__setattr__(self, attr, value) - -#------------------------------------------------------------------------------- -class _loess_control(dict): - - _optiondict = dict(surface=('interpolate', 'direct'), - statistics=('approximate', 'exact'), - trace_hat=('wait.to.decide', 'exact', 'approximate'),) + raise AssertionError,"The test should have failed" + # + def test_2d_pred_stderr(self): + "2D prediction - w/ stderr" + (x, y, results, newdata1, newdata2, madeup) = self.d + madeup.model.span = 0.5 + madeup.model.normalize = True + madeup_pred = madeup.predict(newdata2, stderr=True) + assert_almost_equal(madeup_pred.values, results[5], 5) + assert_almost_equal(madeup_pred.stderr, [0.276746, 0.278009], 5) + assert_almost_equal(madeup_pred.residual_scale, 0.969302, 6) + assert_almost_equal(madeup_pred.df, 81.2319, 4) + # Direct access + madeup.predict(newdata2, stderr=True) + assert_almost_equal(madeup.predicted.values, results[5], 5) + assert_almost_equal(madeup.predicted.stderr, [0.276746, 0.278009], 5) + assert_almost_equal(madeup.predicted.residual_scale, 0.969302, 6) + assert_almost_equal(madeup.predicted.df, 81.2319, 4) + # + def test_2d_pred_confinv(self): + "2D prediction - confidence" + (x, y, results, newdata1, newdata2, madeup) = self.d + madeup.model.span = 0.5 + madeup.model.normalize = True + madeup_pred = madeup.predict(newdata2, stderr=True) + madeup.predicted.confidence(coverage=0.99) + assert_almost_equal(madeup.predicted.confidence_intervals.lower, + results[6][::3], 5) + assert_almost_equal(madeup.predicted.confidence_intervals.fit, + results[6][1::3], 5) + assert_almost_equal(madeup.predicted.confidence_intervals.upper, + results[6][2::3], 5) + # Direct access + confinv = madeup.predicted.confidence(coverage=0.99) + assert_almost_equal(confinv.lower, results[6][::3], 5) + assert_almost_equal(confinv.fit, results[6][1::3], 5) + assert_almost_equal(confinv.upper, results[6][2::3], 5) - def __init__(self, surface="interpolate", statistics="approximate", - trace_hat="wait.to.decide", iterations=4, cell=0.2): - dict.__init__(self, surface=None, statistics=None, - trace_hat=None, iterations=iterations, - cell=cell) - self.surface = surface.lower() - self.statistics = statistics.lower() - self.trace_hat = trace_hat.lower() +#####--------------------------------------------------------------------------- +#---- --- test 2D +#####--------------------------------------------------------------------------- +class test_loess_gas(NumpyTestCase): + "Test class for lowess." # - def __getattr__(self, attr): - _got = getattr(super(dict,self), attr, None) - if _got is None: - _got = self.get(attr, None) - return _got + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + NOx = N.array([4.818, 2.849, 3.275, 4.691, 4.255, 5.064, 2.118, 4.602, + 2.286, 0.970, 3.965, 5.344, 3.834, 1.990, 5.199, 5.283, + 3.752, 0.537, 1.640, 5.055, 4.937, 1.561]) + E = N.array([0.831, 1.045, 1.021, 0.970, 0.825, 0.891, 0.71, 0.801, + 1.074, 1.148, 1.000, 0.928, 0.767, 0.701, 0.807, 0.902, + 0.997, 1.224, 1.089, 0.973, 0.980, 0.665]) + gas_fit_E = N.array([0.665, 0.949, 1.224]) + newdata = N.array([0.6650000, 0.7581667, 0.8513333, 0.9445000, + 1.0376667, 1.1308333, 1.2240000]) + coverage = 0.99; + + rfile = open(os.path.join('examples','gas_result'), 'r') + results = [] + for i in range(8): + rfile.readline() + z = N.fromiter((float(v) for v in rfile.readline().rstrip().split()), + N.float_) + results.append(z) + self.d = (E, NOx, gas_fit_E, newdata, coverage, results) # - def __setattr__(self, attr, value): - if attr in self.keys(): - self.__setitem__(attr, value) - else: - dict.__setattr__(self, attr, value) + def test_1dbasic(self): + "Basic test 1d" + (E, NOx, gas_fit_E, newdata, coverage, results) = self.d + gas = cloess.loess(E,NOx) + gas.model.span = 2./3. + gas.fit() + assert_almost_equal(gas.outputs.fitted_values, results[0], 6) + assert_almost_equal(gas.outputs.enp, 5.5, 1) + assert_almost_equal(gas.outputs.s, 0.3404, 4) # - def __setitem__(self, attr, value): - if attr in _loess_control._optiondict.keys(): - self.__setoption__(attr, value) - else: - dict.__setitem__(self, attr, value) + def test_1dbasic_alt(self): + "Basic test 1d - part #2" + (E, NOx, gas_fit_E, newdata, coverage, results) = self.d + gas_null = cloess.loess(E, NOx) + gas_null.model.span=1.0 + gas_null.fit() + assert_almost_equal(gas_null.outputs.fitted_values, results[1], 6) + assert_almost_equal(gas_null.outputs.enp, 3.5, 1) + assert_almost_equal(gas_null.outputs.s, 0.5197, 4) # - def __setoption__(self, attr, value): - msg = "Invalid argument: %s must be in %s (got %s)" - attrlist = _loess_control._optiondict[attr] - if (not isinstance(value, str)) or \ - (value.lower() not in attrlist): - raise ValueError, msg % (attr, attrlist, value) - dict.__setitem__(self, attr, value.lower()) + def test_1dpredict(self): + "Basic test 1d - prediction" + (E, NOx, gas_fit_E, newdata, coverage, results) = self.d + gas = cloess.loess(E,NOx, span=2./3.) + gas.fit() + gas.predict(gas_fit_E, stderr=False) + assert_almost_equal(gas.predicted.values, results[2], 6) # -# def set_surface_status(self, new_stat): -# if new_stat.lower() not in ('none','exact','approximate'): -# raise ValueError,"Invalid value for the new_stat parameter: "\ -# "should be in ('none','exact','approximate'), got %s" % new_stat -# if self.surface == "interpolate" and new_stat == "approximate": -# if self.trace_hat == "approximate": -# new_stat = "2.approx" -# else: -# trace_hat='exact' in that case -# new_stat = "1.approx" -# return "/".join([self.surface, new_stat]) - def set_surface_status(self, new_stat): - if new_stat.lower() not in ('none','exact','approximate'): - raise ValueError,"Invalid value for the new_stat parameter: "\ - "should be in ('none','exact','approximate'), got %s" % new_stat - statusdict = {"interpolate":{"none": 10, - "exact":11, - "1.approx":12, - "2.approx":13 }, - "direct":{"none" : 20, - "exact": 21, - "approximate": 22}} - if self.surface == "interpolate" and new_stat == "approximate": - if self.trace_hat == "approximate": - status = 13 - else: - # trace_hat='exact' in that case - status = 12 - else: - status = statusdict[self.surface][new_stat] - return status + def test_1dpredict_2(self): + "Basic test 1d - new predictions" + (E, NOx, gas_fit_E, newdata, coverage, results) = self.d + gas = cloess.loess(E,NOx, span=2./3.) + gas.predict(newdata, stderr=True) + gas.predicted.confidence(0.99) + assert_almost_equal(gas.predicted.confidence_intervals.lower, + results[3][0::3], 6) + assert_almost_equal(gas.predicted.confidence_intervals.fit, + results[3][1::3], 6) + assert_almost_equal(gas.predicted.confidence_intervals.upper, + results[3][2::3], 6) -# -# -# -#class loess(object): -# """ -# -#:Ivariables: -# x : ndarray -# Independent variables -# y : ndarray -# Dependent variables -# weights : ndarray -# """ -# def __init__(self, x, y, weights=None, -# span=0.75, degree=2, normalize=True, family="gaussian", -# surface="interpolate", statistics="approximate", -# cell=0.2, trace_hat="wait.to.decide",iterations=4): -# x = narray(x, copy=False, subok=True, order='F') -# if x.ndim == 2: -# (n,d) = x.shape -# elif x.ndim == 1: -# (n,d) = (len(x),1) -# else: -# raise ValueError,"Argument 'x' should be 2D at most!" -# max_kd = max(n, 200) -# # -# y = narray(y, copy=False, subok=True, order='F') -# if weights is None: -# weights = numpy.ones_like(y) -# self.inputs = paramdict(x=x, y=y, weights=weights, nobs=n, nvars=d) -# self.model = paramdict(span=span, degree=degree, -# normalize=normalize, family=family.lower(), -# parametric=nzeros((d,), bool_, 'F'), -# drop_square=nzeros((d,), bool_, 'F') -# ) -# self.control = _loess_control(surface=surface.lower(), -# statistics=statistics.lower(), -# trace_hat=trace_hat.lower(), -# iterations=iterations, cell=cell, -# ) -# self.outputs = paramdict(fitted_values=nempty((n,), float_, 'F'), -# fitted_residuals=nempty((n,), float_, 'F'), -# pseudovalues=nempty((n,), float_, 'F'), -# diagonal=nempty((n,), float_, 'F'), -# robust=numpy.ones((n,), float_, 'F'), -# divisor=nempty((d,), float_, 'F'), -# enp=0, s=0, one_delta=0, two_delta=0, -# trace_hat=0 -# ) -# self.kd_tree = paramdict(parameter=nempty((7,), int_, 'F'), -# a=nempty((max_kd,), int_, 'F'), -# xi=nempty((max_kd,), float_, 'F'), -# vert=nempty((d*2,), float_, 'F'), -# vval=nempty(((d+1)*max_kd,), float_, 'F') -# ) -# # -# if self.model.family == "gaussian": -# self.control['iterations'] = 0 -# if self.control.trace_hat == "wait.to.decide": -# if (self.control.surface == "interpolate") and n >= 500: -# self.control.trace_hat = "approximate" -# else: -# self.control.trace_hat = "exact" -# #...................................................... -# def fit(self, span = 0.75, degree = 2, parametric = False, -# drop_square = False, normalize = True, -# statistics = "approximate", surface = "interpolate", -# cell = 0.2, iterations = 1, trace_hat = "exact"): -# -# # Get input.................... -# inputs = self.inputs -# (x, y, n, d, weights) = [inputs[k] -# for k in ('x','y','nobs','nvars', 'weights')] -# -# max_kd = max(n, 200) -## a = max_kd -# one_delta = two_delta = trace_hat_out = 0 -# -# # Set temporary ............... -# kd_tree = self.kd_tree -# (a, xi, vert, vval, parameter) = [kd_tree[k] -# for k in ('a', 'xi', 'vert', 'vval', -# 'parameter')] -# a_tmp = nempty((max_kd,), int_) -# xi_tmp = nempty((max_kd,), float_) -# vert_tmp = nempty((2*d,), float_) -# vval_tmp = nempty(((d+1)*max_kd,), float_) -# -# # Check control ................ -# control = self.control -# surface = control.surface -# statistics = control.statistics -# iterations = control.iterations -# trace_hat = control.trace_hat -# # Get model .................... -# model = self.model -# family = model.family -# parametric = model.parametric -# drop_square = model.drop_square -# (span, degree, normalize) = [model[k] -# for k in ('span', 'degree', 'normalize')] -# # -# outputs = self.outputs -# fitted_values = outputs.fitted_values -# fitted_residuals = outputs.fitted_residuals -# pseudovalues = outputs.pseudovalues -# diagonal = outputs.diagonal -# robust = outputs.robust -# (enp, s, one_delta, two_delta) = [outputs[k] -# for k in ('enp','s','one_delta','two_delta')] -# trace_hat = outputs.trace_hat -## parameter = 7 -# (d1_tmp, d2_tmp, trL_tmp, zero,) = (0., 0., 0., 0.) -# (delta1, delta2, trL, trace_hat_in) = (0, 0, 0, 0) -# temp = nempty((n,), float_) -# diag_tmp = nempty((n,), float_) -# param_tmp = nempty((n,), int_) -# if iterations > 0: -# pseudo_resid = nempty((n,), float_) -# # -# new_cell = span * cell -# # -# loesslogging.debug("initial divisor: %s" % self.outputs.divisor) -# if normalize and d > 1: -# cut = int(ceil(0.1*n)) -# x_trimmed = numpy.sort(x, axis=0)[cut:-cut] -# outputs.divisor = x_trimmed.std(axis=0) -# outputs.divisor *= numpy.sqrt(n/float(n-1)) -# x = x / outputs.divisor -# else: -# outputs.divisor = numpy.ones(d, float_) -# loesslogging.debug("final divisor: %s" % self.outputs.divisor) -# # -# sum_drop_sqr = sum(drop_square) -# # -# parametric = narray(parametric, copy=True) -# parametric.resize((d,)) -# sum_parametric = parametric.sum() -# nonparametric = numpy.logical_not(parametric).sum() -# order_parametric = numpy.argsort(parametric) -# # -# order_drop_sqr = 2 - drop_square[order_parametric] -# x = x[:,order_parametric].ravel() -# # -# if degree == 1 and sum_drop_sqr: -# msg = "Specified the square of a factor predictor to be dropped"\ -# " when degree = 1" -# raise ValueError, msg -# if d == 1 and sum_drop_sqr: -# msg = "Specified the square of a predictor to be dropped "\ -# "with only one numeric predictor" -# raise ValueError, msg -# if sum_parametric == d: -# raise ValueError, "Specified parametric for all predictors" -# # -# new_stat = statistics.lower() -# loesslogging.debug("start iteration: %s" % new_stat) -# for j in range(iterations+1): -# if j > 0: -# new_stat = "none" -# robust = weights * robust -# surf_stat = control.set_surface_status(new_stat) -# #setLf = (surf_stat.lower() == "interpolate/exact") -# setLf = int(surf_stat == 11) -# loesslogging.debug("iteration: %i: %s - %s" % (j, surf_stat, setLf)) -# # -# (surf_stat, fitted_values, parameter, a, -# xi, vert, vval, diagonal, trL, delta1, delta2, -# ) = loess_raw(y, x, weights, robust, d, n, span, degree, -# nonparametric, order_drop_sqr, sum_drop_sqr, -# new_cell, surf_stat, fitted_values, parameter, a, -# xi, vert, vval, diagonal, trL, delta1, delta2, -# setLf) -# # -# if j == 0: -# trace_hat_out = trL -# one_delta = delta1 -# two_delta = delta2 -# fitted_residuals = y - fitted_values -# if j < iterations: -# (fitted_residuals, n, robust, temp) = lowesw(fitted_residuals, n, robust, temp) -# # -# if (iterations > 0): -# lowesp(n, y, fitted_values, weights, robust, temp, pseudovalues) -# (temp, param_tmp, a_tmp, xi_tmp, -# vert_tmp, vval_tmp, diag_tmp, trL_tmp, d1_tmp, d2_tmp, -# ) = loess_raw(pseudovalues, x, weights, weights, d, n, span, -# degree, nonparametric, order_drop_sqr, sum_drop_sqr, -# new_cell, surf_stat, temp, param_tmp, a_tmp, xi_tmp, -# vert_tmp, vval_tmp, diag_tmp, trL_tmp, d1_tmp, d2_tmp, -# zero) -# pseudo_resid = pseudovalues - temp -# # -# if (iterations == 0): -# sum_squares = numpy.sum(weights * fitted_residuals**2) -# else: -# sum_squares = numpy.sum(weights * pseudo_resid**2) -# # -# loesslogging.debug("setLf:%s" % setLf) -# loesslogging.debug("SSR:%s" % sum_squares) -# outputs.enp = (one_delta) + 2 * (trace_hat_out) - n; -# loesslogging.debug("one_delta:%s-trace_out:%s" % (one_delta, trace_hat_out)) -# outputs.s = numpy.sqrt(sum_squares / (one_delta)) -# for attr in ('one_delta','two_delta','diagonal','trace_hat', -# 'fitted_values','fitted_residuals','pseudovalues'): -# setattr(outputs,attr,eval(attr)) -## (outputs.one_delta, outputs.two_delta) = (one_delta, two_delta) -## outputs.diagonal = diagonal -## outputs. -# # -# #...................................................... -# def summary(self): -# print "Number of Observations : %d" % self.inputs.nobs -# print "Equivalent Number of Parameters: %.1f" % self.outputs.enp -# if self.model.family == "gaussian": -# print "Residual Standard Error : %.4f" % self.outputs.s -# else: -# print "Residual Scale Estimate : %.4f" % self.outputs.s -# #....................................................... -# def predict(self): -# outputs = self.outputs -# self.prediction = paramdict(fit=None, -# se_fit=None, -# residual_scale=outputs.s, -# df=outputs.one_delta**2 / outputs.two_delta, -# ) -# raise NotImplementedError -# -# -# -# -# -# -## size_info[0] = lo->in.p; -## size_info[1] = lo->in.n; -## size_info[2] = m; -## -## pred_(lo->in.y, lo->in.x, eval, size_info, &lo->out.s, -## lo->in.weights, -## lo->out.robust, -## &lo->model.span, -## &lo->model.degree, -## &lo->model.normalize, -## lo->model.parametric, -## lo->model.drop_square, -## &lo->control.surface, -## &lo->control.cell, -## &lo->model.family, -## lo->kd_tree.parameter, -## lo->kd_tree.a, -## lo->kd_tree.xi, -## lo->kd_tree.vert, -## lo->kd_tree.vval, -## lo->out.divisor, -## &se, -## pre->fit, -## pre->se_fit); -##} -# -##void -##pred_(y, x_, new_x, size_info, s, weights, robust, span, degree, -## normalize, parametric, drop_square, surface, cell, family, -## parameter, a, xi, vert, vval, divisor, se, fit, se_fit) -##double *y, *x_, *new_x, *weights, *robust, *span, *cell, *fit, *s, -## *xi, *vert, *vval, *divisor, *se_fit; -##long *size_info, *degree, *normalize, *parametric, *drop_square, -## *parameter, *a, *se; -##char **surface, **family; -##{ -## double *x, *x_tmp, *x_evaluate, *L, new_cell, z, tmp, *fit_tmp, -## *temp, sum, mean; -## long N, D, M, sum_drop_sqr = 0, sum_parametric = 0, -## nonparametric = 0, *order_parametric, *order_drop_sqr; -## int i, j, k, p, cut, comp(); -## -## D = size_info[0]; -## N = size_info[1]; -## M = size_info[2]; -## -## x = (double *) malloc(N * D * sizeof(double)); -## x_tmp = (double *) malloc(N * D * sizeof(double)); -## x_evaluate = (double *) malloc(M * D * sizeof(double)); -## L = (double *) malloc(N * M * sizeof(double)); -## order_parametric = (long *) malloc(D * sizeof(long)); -## order_drop_sqr = (long *) malloc(D * sizeof(long)); -## temp = (double *) malloc(N * D * sizeof(double)); -## -## for(i = 0; i < (N * D); i++) -## x_tmp[i] = x_[i]; -## for(i = 0; i < D; i++) { -## k = i * M; -## for(j = 0; j < M; j++) { -## p = k + j; -## new_x[p] = new_x[p] / divisor[i]; -## } -## } -## if(!strcmp(*surface, "direct") || se) { -## for(i = 0; i < D; i++) { -## k = i * N; -## for(j = 0; j < N; j++) { -## p = k + j; -## x_tmp[p] = x_[p] / divisor[i]; -## } -## } -## } -## j = D - 1; -## for(i = 0; i < D; i++) { -## sum_drop_sqr = sum_drop_sqr + drop_square[i]; -## sum_parametric = sum_parametric + parametric[i]; -## if(parametric[i]) -## order_parametric[j--] = i; -## else -## order_parametric[nonparametric++] = i; -## } -## for(i = 0; i < D; i++) { -## order_drop_sqr[i] = 2 - drop_square[order_parametric[i]]; -## k = i * M; -## p = order_parametric[i] * M; -## for(j = 0; j < M; j++) -## x_evaluate[k + j] = new_x[p + j]; -## k = i * N; -## p = order_parametric[i] * N; -## for(j = 0; j < N; j++) -## x[k + j] = x_tmp[p + j]; -## } -## for(i = 0; i < N; i++) -## robust[i] = weights[i] * robust[i]; -## -## if(!strcmp(*surface, "direct")) { -## if(*se) { -## loess_dfitse(y, x, x_evaluate, weights, robust, -## !strcmp(*family, "gaussian"), span, degree, -## &nonparametric, order_drop_sqr, &sum_drop_sqr, -## &D, &N, &M, fit, L); -## } -## else { -## loess_dfit(y, x, x_evaluate, robust, span, degree, -## &nonparametric, order_drop_sqr, &sum_drop_sqr, -## &D, &N, &M, fit); -## } -## } -## else { -## loess_ifit(parameter, a, xi, vert, vval, &M, x_evaluate, fit); -## if(*se) { -## new_cell = (*span) * (*cell); -## fit_tmp = (double *) malloc(M * sizeof(double)); -## loess_ise(y, x, x_evaluate, weights, span, degree, -## &nonparametric, order_drop_sqr, &sum_drop_sqr, -## &new_cell, &D, &N, &M, fit_tmp, L); -## free(fit_tmp); -## } -## } -## if(*se) { -## for(i = 0; i < N; i++) { -## k = i * M; -## for(j = 0; j < M; j++) { -## p = k + j; -## L[p] = L[p] / weights[i]; -## L[p] = L[p] * L[p]; -## } -## } -## for(i = 0; i < M; i++) { -## tmp = 0; -## for(j = 0; j < N; j++) -## tmp = tmp + L[i + j * M]; -## se_fit[i] = (*s) * sqrt(tmp); -## } -## } -## free(x); -## free(x_tmp); -## free(x_evaluate); -## free(L); -## free(order_parametric); -## free(order_drop_sqr); -## free(temp); -##} -## -##void -##pred_free_mem(pre) -##struct pred_struct *pre; -##{ -## free(pre->fit); -## free(pre->se_fit); -##} - - - -################################################################################ +######################################################################## if __name__ == '__main__': - import numpy as N - _data = open(os.path.join('examples','sin_data'), 'r') - _result = open(os.path.join('examples','sin_result'), 'r') - x = N.arange(1.,121.) - y = N.concatenate([N.fromiter((float(v) for v in L.rstrip().split()), float_) - for L in _data.readlines()]) - z = N.concatenate([N.fromiter((float(v) for v in L.rstrip().split()), float_) - for L in _result.readlines()]) -# x = N.concatenate([N.fromiter((float(v) for v in L.rstrip().split()), float_) -# for L in open('_data','r').readlines()]) -# x.shape = (-1,2) -# y = N.concatenate([N.fromiter((float(v) for v in L.rstrip().split()), float_) -# for L in open('_response','r').readlines()]) - tester = cloess.loess(x,y) - enp_theo = 4.34 - rse_theo = 0.579 - trc_smoother = 4.73 - print "OK" - tester.fit() - tester.summary() - print "Fit OK" + NumpyTest().run() + + if 0: + NOx = N.array([4.818, 2.849, 3.275, 4.691, 4.255, 5.064, 2.118, 4.602, + 2.286, 0.970, 3.965, 5.344, 3.834, 1.990, 5.199, 5.283, + 3.752, 0.537, 1.640, 5.055, 4.937, 1.561]) + E = N.array([0.831, 1.045, 1.021, 0.970, 0.825, 0.891, 0.71, 0.801, + 1.074, 1.148, 1.000, 0.928, 0.767, 0.701, 0.807, 0.902, + 0.997, 1.224, 1.089, 0.973, 0.980, 0.665]) + gas_fit_E = N.array([0.665, 0.949, 1.224]) + gas_test = loess(E, NOx, span=2./3.) +# gas_test.fit() + gas_test.predict(gas_fit_E, stderr=False) + gas_test.predict(gas_test.predicted.values, stderr=False) + \ No newline at end of file Modified: trunk/Lib/sandbox/pyloess/sandbox/src/c_numpy.pxd =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/c_numpy.pxd 2007-03-14 16:52:59 UTC (rev 2848) +++ trunk/Lib/sandbox/pyloess/sandbox/src/c_numpy.pxd 2007-03-16 20:42:51 UTC (rev 2849) @@ -123,4 +123,7 @@ object PyArray_IterNew(object arr) void PyArray_ITER_NEXT(flatiter it) + + object PyArray_SimpleNewFromData(int ndims, npy_intp* dims, NPY_TYPES type_num, void* data) + void import_array() Modified: trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c 2007-03-14 16:52:59 UTC (rev 2848) +++ trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c 2007-03-16 20:42:51 UTC (rev 2849) @@ -1,4 +1,4 @@ -/* Generated by Pyrex 0.9.5.1a on Wed Mar 14 08:14:04 2007 */ +/* Generated by Pyrex 0.9.5.1a on Fri Mar 16 16:29:33 2007 */ #include "Python.h" #include "structmember.h" @@ -36,6 +36,9 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ +static PyObject *__Pyx_UnpackItem(PyObject *); /*proto*/ +static int __Pyx_EndUnpack(PyObject *); /*proto*/ + static int __Pyx_PrintItem(PyObject *); /*proto*/ static int __Pyx_PrintNewline(void); /*proto*/ @@ -92,6 +95,8 @@ PyObject_HEAD loess_outputs (*_base); long nobs; + long npar; + int activated; }; @@ -102,18 +107,18 @@ }; -struct __pyx_obj_6cloess_confidence_interval { +struct __pyx_obj_6cloess_conf_intervals { PyObject_HEAD - conf_inv (*_base); + conf_inv _base; PyObject *nest; }; struct __pyx_obj_6cloess_loess_predicted { PyObject_HEAD - prediction (*_base); + prediction _base; long nest; - struct __pyx_obj_6cloess_confidence_interval *conf_interval; + struct __pyx_obj_6cloess_conf_intervals *confidence_intervals; }; @@ -126,6 +131,8 @@ struct __pyx_obj_6cloess_loess_kd_tree *kd_tree; struct __pyx_obj_6cloess_loess_outputs *outputs; struct __pyx_obj_6cloess_loess_predicted *predicted; + long nobs; + long npar; }; static PyTypeObject *__pyx_ptype_6cloess_loess_inputs = 0; @@ -134,23 +141,51 @@ static PyTypeObject *__pyx_ptype_6cloess_loess_model = 0; static PyTypeObject *__pyx_ptype_6cloess_loess_outputs = 0; static PyTypeObject *__pyx_ptype_6cloess_loess_anova = 0; -static PyTypeObject *__pyx_ptype_6cloess_confidence_interval = 0; +static PyTypeObject *__pyx_ptype_6cloess_conf_intervals = 0; static PyTypeObject *__pyx_ptype_6cloess_loess_predicted = 0; static PyTypeObject *__pyx_ptype_6cloess_loess = 0; -static PyObject *__pyx_k7; -static PyObject *__pyx_k8; -static PyObject *__pyx_k9; -static PyObject *(__pyx_f_6cloess_floatarray_from_data(PyObject *,PyObject *,double (*))); /*proto*/ -static PyObject *(__pyx_f_6cloess_boolarray_from_data(PyObject *,PyObject *,int (*))); /*proto*/ +static PyObject *__pyx_k35; +static PyObject *__pyx_k36; +static PyObject *__pyx_k37; +static PyObject *(__pyx_f_6cloess_floatarray_from_data(int ,int ,double (*))); /*proto*/ +static PyObject *(__pyx_f_6cloess_boolarray_from_data(int ,int ,int (*))); /*proto*/ /* Implementation of cloess */ -static char (__pyx_k1[]) = "Weights"; +static char (__pyx_k1[]) = "A (n,) ndarray of weights to be given to individual observations in the \n sum of squared residuals that forms the local fitting criterion. If not\n None, the weights should be non negative. If the different observations\n have non-equal variances, the weights should be inversely proportional \n to the variances.\n By default, an unweighted fit is carried out (all the weights are one).\n "; static char (__pyx_k2[]) = "Number of observations."; static char (__pyx_k3[]) = "Number of independent variables."; -static char (__pyx_k4[]) = "Normalize the variables. Only useful if more than one variable..."; -static char (__pyx_k5[]) = "Equivalent number of parameters."; +static char (__pyx_k4[]) = "\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n "; +static char (__pyx_k5[]) = "\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n "; +static char (__pyx_k6[]) = "\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n "; +static char (__pyx_k7[]) = "\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n "; +static char (__pyx_k8[]) = "\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n "; +static char (__pyx_k9[]) = "Smoothing factor, as a fraction of the number of points to take into\n account. By default, span=0.75."; +static char (__pyx_k10[]) = "\n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n "; +static char (__pyx_k11[]) = "\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n "; +static char (__pyx_k12[]) = "\n family : string [\"gaussian\"]\n Determines the assumed distribution of the errors. The values are \n \"gaussian\" or \"symmetric\". If \"gaussian\" is selected, the fit is \n performed with least-squares. If \"symmetric\" is selected, the fit\n is performed robustly by redescending M-estimators.\n "; +static char (__pyx_k13[]) = "\n parametric_flags : sequence [ [False]*p ]\n Indicates which independent variables should be conditionally-parametric\n (if there are two or more independent variables). The argument should \n be a sequence of booleans, with the same size as the number of independent \n variables, specified in the order of the predictor group ordered in x. \n "; +static char (__pyx_k14[]) = "\n drop_square : sequence [ [False]* p]\n When there are two or more independent variables and when a 2nd order\n polynomial is used, \"drop_square_flags\" specifies those numeric predictors \n whose squares should be dropped from the set of fitting variables. \n The method of specification is the same as for parametric. \n "; +static char (__pyx_k15[]) = "\n fitted_values : ndarray\n The (n,) ndarray of fitted values.\n "; +static char (__pyx_k16[]) = "\n fitted_residuals : ndarray\n The (n,) ndarray of fitted residuals (observations - fitted values).\n "; +static char (__pyx_k17[]) = "\n pseudovalues : ndarray\n The (n,) ndarray of adjusted values of the response when robust estimation \n is used.\n "; +static char (__pyx_k18[]) = "\n diagonal :\n Diagonal of the operator hat matrix.\n "; +static char (__pyx_k19[]) = "\n robust : ndarray\n The (n,) ndarray of robustness weights for robust fitting.\n "; +static char (__pyx_k20[]) = "Equivalent number of parameters."; +static char (__pyx_k21[]) = "\n enp : float\n Equivalent number of parameters.\n "; +static char (__pyx_k22[]) = "\n s : float\n Estimate of the scale of residuals.\n "; +static char (__pyx_k23[]) = "\n one_delta: float\n Statistical parameter used in the computation of standard errors.\n "; +static char (__pyx_k24[]) = "\n two_delta : float\n Statistical parameter used in the computation of standard errors.\n "; +static char (__pyx_k25[]) = "\n trace_hat : float \n Trace of the operator hat matrix.\n "; +static char (__pyx_k26[]) = "\n fit : ndarray\n The (m,) ndarray of estimated values\n "; +static char (__pyx_k27[]) = "\n upper : ndarray\n The (m,) ndarray of the upper limits of the pointwise confidence intervals.\n "; +static char (__pyx_k28[]) = "\n lower : ndarray\n The (m,) ndarray of the lower limits of the pointwise confidence intervals.\n "; +static char (__pyx_k29[]) = "\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n "; +static char (__pyx_k30[]) = "\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n "; +static char (__pyx_k31[]) = "\n residual_scale : float\n Estimate of the scale of the residuals\n "; +static char (__pyx_k32[]) = "\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n "; +static char (__pyx_k34[]) = "\n:Keywords:\n x : ndarray\n A (n,p) ndarray of independent variables, with n the number of observations\n and p the number of variables.\n y : ndarray\n A (n,) ndarray of observations\n weights : ndarray\n A (n,) ndarray of weights to be given to individual observations in the \n sum of squared residuals that forms the local fitting criterion. If not\n None, the weights should be non negative. If the different observations\n have non-equal variances, the weights should be inversely proportional \n to the variances.\n By default, an unweighted fit is carried out (all the weights are one).\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n span : float [0.75]\n Smoothing factor, as a fraction of the number of points to take into\n account. \n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n family : string [\"gaussian\"]\n Determines the assumed distribution of the errors. The values are \n \"gaussian\" or \"symmetric\". If \"gaussian\" is selected, the fit is \n performed with least-squares. If \"symmetric\" is selected, the fit\n is performed robustly by redescending M-estimators.\n parametric_flags : sequence [ [False]*p ]\n Indicates which independent variables should be conditionally-parametric\n (if there are two or more independent variables). The argument should \n be a sequence of booleans, with the same size as the number of independent \n variables, specified in the order of the predictor group ordered in x. \n drop_square : sequence [ [False]* p]\n When there are two or more independent variables and when a 2nd order\n polynomial is used, \"drop_square_flags\" specifies those numeric predictors \n whose squares should be dropped from the set of fitting variables. \n The method of specification is the same as for parametric. \n \n:Outputs:\n fitted_values : ndarray\n The (n,) ndarray of fitted values.\n fitted_residuals : ndarray\n The (n,) ndarray of fitted residuals (observations - fitted values).\n enp : float\n Equivalent number of parameters.\n s : float\n Estimate of the scale of residuals.\n one_delta: float\n Statistical parameter used in the computation of standard errors.\n two_delta : float\n Statistical parameter used in the computation of standard errors.\n pseudovalues : ndarray\n The (n,) ndarray of adjusted values of the response when robust estimation \n is used.\n trace_hat : float \n Trace of the operator hat matrix.\n diagonal :\n Diagonal of the operator hat matrix.\n robust : ndarray\n The (n,) ndarray of robustness weights for robust fitting.\n divisor : ndarray\n The (p,) array of normalization divisors for numeric predictors.\n \n\n newdata : ndarray\n The (m,p) array of independent variables where the surface must be estimated.\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n residual_scale : float\n Estimate of the scale of the residuals\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n nest : integer\n Number of new observations.\n \n \n"; static PyObject *__pyx_n_c_python; static PyObject *__pyx_n_c_numpy; @@ -158,97 +193,48 @@ static PyObject *__pyx_n_c_loess; static PyObject *__pyx_n_False; -static PyObject *__pyx_n_empty; -static PyObject *__pyx_n_float; -static PyObject *__pyx_n_dtype; -static PyObject *__pyx_n_size; static PyObject *__pyx_n_shape; - -static PyObject *__pyx_f_6cloess_floatarray_from_data(PyObject *__pyx_v_rows,PyObject *__pyx_v_cols,double (*__pyx_v_data)) { +static PyObject *__pyx_f_6cloess_floatarray_from_data(int __pyx_v_rows,int __pyx_v_cols,double (*__pyx_v_data)) { PyArrayObject *__pyx_v_a_ndr; - double (*__pyx_v_a_dat); - PyObject *__pyx_v_i; + npy_intp __pyx_v_size; PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; + int __pyx_2; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; - PyObject *__pyx_5 = 0; - long __pyx_6; - long __pyx_7; - int __pyx_8; - int __pyx_9; - Py_INCREF(__pyx_v_rows); - Py_INCREF(__pyx_v_cols); __pyx_v_a_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - __pyx_v_i = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":22 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyNumber_Multiply(__pyx_v_rows, __pyx_v_cols); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); - __pyx_1 = 0; - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3); - __pyx_3 = 0; - __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} - __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_float); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (PyDict_SetItem(__pyx_3, __pyx_n_dtype, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_a_ndr)); - __pyx_v_a_ndr = ((PyArrayObject *)__pyx_4); - __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":23 */ - __pyx_v_a_dat = ((double (*))__pyx_v_a_ndr->data); + __pyx_v_size = (__pyx_v_rows * __pyx_v_cols); /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":24 */ - __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} - __pyx_7 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - for (__pyx_6 = 0; __pyx_6 < __pyx_7; ++__pyx_6) { - __pyx_2 = PyInt_FromLong(__pyx_6); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} - Py_DECREF(__pyx_v_i); - __pyx_v_i = __pyx_2; - __pyx_2 = 0; + __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_1)); + Py_DECREF(((PyObject *)__pyx_v_a_ndr)); + __pyx_v_a_ndr = ((PyArrayObject *)((PyObject *)__pyx_1)); + Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":25 */ - __pyx_8 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} - __pyx_9 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;} - (__pyx_v_a_dat[__pyx_9]) = (__pyx_v_data[__pyx_8]); - } + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":29 */ + __pyx_2 = (__pyx_v_cols > 1); + if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":26 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_cols, __pyx_1, &__pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} - __pyx_8 = __pyx_8 > 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__pyx_8) { - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":27 */ - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; goto __pyx_L1;} - Py_INCREF(__pyx_v_rows); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_rows); - Py_INCREF(__pyx_v_cols); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_cols); - if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - goto __pyx_L4; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":30 */ + __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); + PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3); + __pyx_1 = 0; + __pyx_3 = 0; + if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + goto __pyx_L2; } - __pyx_L4:; + __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":28 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":31 */ Py_INCREF(((PyObject *)__pyx_v_a_ndr)); __pyx_r = ((PyObject *)__pyx_v_a_ndr); goto __pyx_L0; @@ -257,138 +243,82 @@ goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); - Py_XDECREF(__pyx_5); __Pyx_AddTraceback("cloess.floatarray_from_data"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_a_ndr); - Py_DECREF(__pyx_v_i); - Py_DECREF(__pyx_v_rows); - Py_DECREF(__pyx_v_cols); return __pyx_r; } -static PyObject *__pyx_n_int; static PyObject *__pyx_n_astype; static PyObject *__pyx_n_bool; - -static PyObject *__pyx_f_6cloess_boolarray_from_data(PyObject *__pyx_v_rows,PyObject *__pyx_v_cols,int (*__pyx_v_data)) { +static PyObject *__pyx_f_6cloess_boolarray_from_data(int __pyx_v_rows,int __pyx_v_cols,int (*__pyx_v_data)) { PyArrayObject *__pyx_v_a_ndr; - int (*__pyx_v_a_dat); - PyObject *__pyx_v_i; + npy_intp __pyx_v_size; PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; + int __pyx_2; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; - PyObject *__pyx_5 = 0; - long __pyx_6; - long __pyx_7; - int __pyx_8; - int __pyx_9; - Py_INCREF(__pyx_v_rows); - Py_INCREF(__pyx_v_cols); __pyx_v_a_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - __pyx_v_i = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":33 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":36 */ + __pyx_v_size = (__pyx_v_rows * __pyx_v_cols); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":39 */ + __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_1)); + Py_DECREF(((PyObject *)__pyx_v_a_ndr)); + __pyx_v_a_ndr = ((PyArrayObject *)((PyObject *)__pyx_1)); Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyNumber_Multiply(__pyx_v_rows, __pyx_v_cols); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); - __pyx_1 = 0; - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3); - __pyx_3 = 0; - __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} - __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_int); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (PyDict_SetItem(__pyx_3, __pyx_n_dtype, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_a_ndr)); - __pyx_v_a_ndr = ((PyArrayObject *)__pyx_4); - __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":34 */ - __pyx_v_a_dat = ((int (*))__pyx_v_a_ndr->data); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":43 */ + __pyx_2 = (__pyx_v_cols > 1); + if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":35 */ - __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} - __pyx_7 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - for (__pyx_6 = 0; __pyx_6 < __pyx_7; ++__pyx_6) { - __pyx_2 = PyInt_FromLong(__pyx_6); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} - Py_DECREF(__pyx_v_i); - __pyx_v_i = __pyx_2; - __pyx_2 = 0; - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":36 */ - __pyx_8 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} - __pyx_9 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} - (__pyx_v_a_dat[__pyx_9]) = (__pyx_v_data[__pyx_8]); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":44 */ + __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); + PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3); + __pyx_1 = 0; + __pyx_3 = 0; + if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + goto __pyx_L2; } + __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":37 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_cols, __pyx_1, &__pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} - __pyx_8 = __pyx_8 > 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":45 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_astype); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_bool); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4); + __pyx_4 = 0; + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__pyx_8) { - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":38 */ - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} - Py_INCREF(__pyx_v_rows); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_rows); - Py_INCREF(__pyx_v_cols); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_cols); - if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - goto __pyx_L4; - } - __pyx_L4:; - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":39 */ - __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_astype); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} - __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_bool); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); - __pyx_2 = 0; - __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); - Py_XDECREF(__pyx_5); __Pyx_AddTraceback("cloess.boolarray_from_data"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_a_ndr); - Py_DECREF(__pyx_v_i); - Py_DECREF(__pyx_v_rows); - Py_DECREF(__pyx_v_cols); return __pyx_r; } @@ -396,26 +326,18 @@ static PyObject *__pyx_f_6cloess_12loess_inputs_1x___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":50 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->x); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":173 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->p,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->x); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); __Pyx_AddTraceback("cloess.loess_inputs.x.__get__"); __pyx_r = 0; __pyx_L0:; @@ -427,26 +349,18 @@ static PyObject *__pyx_f_6cloess_12loess_inputs_1y___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":54 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->y); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":177 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n,1,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->y); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); __Pyx_AddTraceback("cloess.loess_inputs.y.__get__"); __pyx_r = 0; __pyx_L0:; @@ -458,26 +372,18 @@ static PyObject *__pyx_f_6cloess_12loess_inputs_7weights___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":59 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->weights); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":188 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n,1,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->weights); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); __Pyx_AddTraceback("cloess.loess_inputs.weights.__get__"); __pyx_r = 0; __pyx_L0:; @@ -486,11 +392,12 @@ } static PyObject *__pyx_n_ndim; +static PyObject *__pyx_n_size; static PyObject *__pyx_n_ValueError; -static PyObject *__pyx_k12p; +static PyObject *__pyx_k38p; -static char (__pyx_k12[]) = "Invalid size of the 'weights' vector!"; +static char (__pyx_k38[]) = "Invalid size of the 'weights' vector!"; static int __pyx_f_6cloess_12loess_inputs_7weights___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_w); /*proto*/ static int __pyx_f_6cloess_12loess_inputs_7weights___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_w) { @@ -503,40 +410,40 @@ Py_INCREF(__pyx_v_w); __pyx_v_w_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":64 */ - __pyx_1 = PyArray_FROMANY(__pyx_v_w,NPY_DOUBLE,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":193 */ + __pyx_1 = PyArray_FROMANY(__pyx_v_w,NPY_DOUBLE,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;} Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); Py_DECREF(((PyObject *)__pyx_v_w_ndr)); __pyx_v_w_ndr = ((PyArrayObject *)__pyx_1); Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":65 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_ndim); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":194 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_ndim); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} __pyx_2 = __pyx_2 > 0; Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; if (!__pyx_2) { - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} __pyx_2 = __pyx_2 != 0; Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; } if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":66 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;} - __Pyx_Raise(__pyx_1, __pyx_k12p, 0); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":195 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; goto __pyx_L1;} + __Pyx_Raise(__pyx_1, __pyx_k38p, 0); Py_DECREF(__pyx_1); __pyx_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":67 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":196 */ ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->weights = ((double (*))__pyx_v_w_ndr->data); __pyx_r = 0; @@ -559,8 +466,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":72 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":201 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -576,14 +483,14 @@ return __pyx_r; } -static PyObject *__pyx_f_6cloess_12loess_inputs_4nvar___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_12loess_inputs_4nvar___get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_f_6cloess_12loess_inputs_4npar___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_12loess_inputs_4npar___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":77 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":206 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -592,7 +499,7 @@ goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("cloess.loess_inputs.nvar.__get__"); + __Pyx_AddTraceback("cloess.loess_inputs.npar.__get__"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); @@ -605,8 +512,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":87 */ - __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":223 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -622,23 +529,82 @@ return __pyx_r; } +static PyObject *__pyx_n_lower; +static PyObject *__pyx_n_interpolate; +static PyObject *__pyx_n_direct; + +static PyObject *__pyx_k41p; +static PyObject *__pyx_k42p; + +static char (__pyx_k41[]) = "Invalid value for the 'surface' argument: "; +static char (__pyx_k42[]) = "should be in ('interpolate', 'direct')."; + static int __pyx_f_6cloess_13loess_control_7surface___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_surface); /*proto*/ static int __pyx_f_6cloess_13loess_control_7surface___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_surface) { + PyObject *__pyx_v_tmpx; int __pyx_r; - char (*__pyx_1); + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + PyObject *__pyx_4 = 0; + char (*__pyx_5); Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_surface); + __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":89 */ - __pyx_1 = PyString_AsString(__pyx_v_surface); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->surface = __pyx_1; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":225 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} + Py_INCREF(__pyx_n_interpolate); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_interpolate); + Py_INCREF(__pyx_n_direct); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_direct); + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} + __pyx_3 = !__pyx_3; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_3) { + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":226 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + __pyx_1 = PyNumber_Add(__pyx_k41p, __pyx_k42p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); + __pyx_1 = 0; + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_1, 0, 0); + Py_DECREF(__pyx_1); __pyx_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":228 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_tmpx); + __pyx_v_tmpx = __pyx_4; + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":229 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->surface = __pyx_5; + __pyx_r = 0; goto __pyx_L0; __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); __Pyx_AddTraceback("cloess.loess_control.surface.__set__"); __pyx_r = -1; __pyx_L0:; + Py_DECREF(__pyx_v_tmpx); Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_surface); return __pyx_r; @@ -650,8 +616,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":93 */ - __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":240 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -667,23 +633,78 @@ return __pyx_r; } +static PyObject *__pyx_n_approximate; +static PyObject *__pyx_n_exact; + +static PyObject *__pyx_k45p; + +static char (__pyx_k45[]) = "Invalid value for the 'statistics' argument: should be in ('approximate', 'exact')."; + static int __pyx_f_6cloess_13loess_control_10statistics___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_statistics); /*proto*/ static int __pyx_f_6cloess_13loess_control_10statistics___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_statistics) { + PyObject *__pyx_v_tmpx; int __pyx_r; - char (*__pyx_1); + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + PyObject *__pyx_4 = 0; + char (*__pyx_5); Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_statistics); + __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":95 */ - __pyx_1 = PyString_AsString(__pyx_v_statistics); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->statistics = __pyx_1; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":242 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;} + Py_INCREF(__pyx_n_approximate); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_approximate); + Py_INCREF(__pyx_n_exact); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_exact); + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;} + __pyx_3 = !__pyx_3; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_3) { + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":243 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} + Py_INCREF(__pyx_k45p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k45p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":245 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_tmpx); + __pyx_v_tmpx = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":246 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->statistics = __pyx_5; + __pyx_r = 0; goto __pyx_L0; __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); __Pyx_AddTraceback("cloess.loess_control.statistics.__set__"); __pyx_r = -1; __pyx_L0:; + Py_DECREF(__pyx_v_tmpx); Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_statistics); return __pyx_r; @@ -695,8 +716,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":99 */ - __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":262 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -712,23 +733,75 @@ return __pyx_r; } +static PyObject *__pyx_k48p; + +static char (__pyx_k48[]) = "Invalid value for the 'trace_hat' argument: should be in ('approximate', 'exact')."; + static int __pyx_f_6cloess_13loess_control_9trace_hat___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_trace_hat); /*proto*/ static int __pyx_f_6cloess_13loess_control_9trace_hat___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_trace_hat) { + PyObject *__pyx_v_tmpx; int __pyx_r; - char (*__pyx_1); + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + PyObject *__pyx_4 = 0; + char (*__pyx_5); Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_trace_hat); + __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":101 */ - __pyx_1 = PyString_AsString(__pyx_v_trace_hat); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; goto __pyx_L1;} - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->trace_hat = __pyx_1; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":264 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} + Py_INCREF(__pyx_n_approximate); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_approximate); + Py_INCREF(__pyx_n_exact); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_exact); + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} + __pyx_3 = !__pyx_3; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_3) { + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":265 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;} + Py_INCREF(__pyx_k48p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k48p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":267 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_tmpx); + __pyx_v_tmpx = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":268 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->trace_hat = __pyx_5; + __pyx_r = 0; goto __pyx_L0; __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); __Pyx_AddTraceback("cloess.loess_control.trace_hat.__set__"); __pyx_r = -1; __pyx_L0:; + Py_DECREF(__pyx_v_tmpx); Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_trace_hat); return __pyx_r; @@ -740,8 +813,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":105 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":277 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -757,20 +830,52 @@ return __pyx_r; } +static PyObject *__pyx_k49p; + +static char (__pyx_k49[]) = "Invalid number of iterations: should be positive"; + static int __pyx_f_6cloess_13loess_control_10iterations___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_iterations); /*proto*/ static int __pyx_f_6cloess_13loess_control_10iterations___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_iterations) { int __pyx_r; - int __pyx_1; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_iterations); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":107 */ - __pyx_1 = PyInt_AsLong(__pyx_v_iterations); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L1;} - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->iterations = __pyx_1; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":279 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_iterations, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} + __pyx_2 = __pyx_2 < 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_2) { + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":280 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;} + Py_INCREF(__pyx_k49p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k49p); + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":281 */ + __pyx_2 = PyInt_AsLong(__pyx_v_iterations); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->iterations = __pyx_2; + __pyx_r = 0; goto __pyx_L0; __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); __Pyx_AddTraceback("cloess.loess_control.iterations.__set__"); __pyx_r = -1; __pyx_L0:; @@ -785,8 +890,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":111 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":293 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -802,20 +907,53 @@ return __pyx_r; } +static PyObject *__pyx_k50p; + +static char (__pyx_k50[]) = "Invalid value for the cell argument: should be positive"; + static int __pyx_f_6cloess_13loess_control_4cell___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_cell); /*proto*/ static int __pyx_f_6cloess_13loess_control_4cell___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_cell) { int __pyx_r; - double __pyx_1; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + double __pyx_5; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_cell); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":113 */ - __pyx_1 = PyFloat_AsDouble(__pyx_v_cell); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} - ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->cell = __pyx_1; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":295 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_cell, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; goto __pyx_L1;} + __pyx_2 = __pyx_2 <= 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_2) { + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":296 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;} + Py_INCREF(__pyx_k50p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k50p); + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":297 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_cell); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->cell = __pyx_5; + __pyx_r = 0; goto __pyx_L0; __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); __Pyx_AddTraceback("cloess.loess_control.cell.__set__"); __pyx_r = -1; __pyx_L0:; @@ -834,6 +972,7 @@ static PyObject *__pyx_f_6cloess_13loess_control_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6cloess_13loess_control_update[] = "Updates several parameters at once."; static PyObject *__pyx_f_6cloess_13loess_control_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_cellargs = 0; PyObject *__pyx_v_surface; @@ -861,122 +1000,122 @@ __pyx_v_iterations = Py_None; Py_INCREF(Py_None); __pyx_v_cell = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":116 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":301 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;} Py_INCREF(__pyx_n_surface); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_surface); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_surface); __pyx_v_surface = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":117 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":302 */ __pyx_4 = __pyx_v_surface != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":118 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_surface, __pyx_v_surface) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":303 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_surface, __pyx_v_surface) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":120 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":305 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} Py_INCREF(__pyx_n_statistics); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_statistics); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_statistics); __pyx_v_statistics = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":121 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":306 */ __pyx_4 = __pyx_v_statistics != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":122 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_statistics, __pyx_v_statistics) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":307 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_statistics, __pyx_v_statistics) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;} goto __pyx_L3; } __pyx_L3:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":124 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":309 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;} Py_INCREF(__pyx_n_trace_hat); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_trace_hat); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_trace_hat); __pyx_v_trace_hat = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":125 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":310 */ __pyx_4 = __pyx_v_trace_hat != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":126 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_trace_hat, __pyx_v_trace_hat) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":311 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_trace_hat, __pyx_v_trace_hat) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;} goto __pyx_L4; } __pyx_L4:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":128 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":313 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} Py_INCREF(__pyx_n_iterations); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_iterations); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_iterations); __pyx_v_iterations = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":129 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":314 */ __pyx_4 = __pyx_v_iterations != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":130 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_iterations, __pyx_v_iterations) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":315 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_iterations, __pyx_v_iterations) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;} goto __pyx_L5; } __pyx_L5:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":132 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":317 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;} Py_INCREF(__pyx_n_cell); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_cell); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_cell); __pyx_v_cell = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":133 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":318 */ __pyx_4 = __pyx_v_cell != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":134 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":319 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;} goto __pyx_L6; } __pyx_L6:; @@ -1004,21 +1143,21 @@ static PyObject *__pyx_n_join; -static PyObject *__pyx_k18p; -static PyObject *__pyx_k19p; -static PyObject *__pyx_k20p; -static PyObject *__pyx_k21p; -static PyObject *__pyx_k22p; -static PyObject *__pyx_k23p; -static PyObject *__pyx_k24p; +static PyObject *__pyx_k56p; +static PyObject *__pyx_k57p; +static PyObject *__pyx_k58p; +static PyObject *__pyx_k59p; +static PyObject *__pyx_k60p; +static PyObject *__pyx_k61p; +static PyObject *__pyx_k62p; -static char (__pyx_k18[]) = "Control :"; -static char (__pyx_k19[]) = "Surface type : %s"; -static char (__pyx_k20[]) = "Statistics : %s"; -static char (__pyx_k21[]) = "Trace estimation : %s"; -static char (__pyx_k22[]) = "Cell size : %s"; -static char (__pyx_k23[]) = "Nb iterations : %s"; -static char (__pyx_k24[]) = "\n"; +static char (__pyx_k56[]) = "Control :"; +static char (__pyx_k57[]) = "Surface type : %s"; +static char (__pyx_k58[]) = "Statistics : %s"; +static char (__pyx_k59[]) = "Trace estimation : %s"; +static char (__pyx_k60[]) = "Cell size : %s"; +static char (__pyx_k61[]) = "Nb iterations : %s"; +static char (__pyx_k62[]) = "\n"; static PyObject *__pyx_f_6cloess_13loess_control___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_13loess_control___str__(PyObject *__pyx_v_self) { @@ -1033,25 +1172,25 @@ Py_INCREF(__pyx_v_self); __pyx_v_strg = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":138 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k19p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":323 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k57p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;} - __pyx_3 = PyNumber_Remainder(__pyx_k20p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k58p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; goto __pyx_L1;} - __pyx_4 = PyNumber_Remainder(__pyx_k21p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k59p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;} - __pyx_5 = PyNumber_Remainder(__pyx_k22p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k60p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; goto __pyx_L1;} - __pyx_6 = PyNumber_Remainder(__pyx_k23p, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; goto __pyx_L1;} + __pyx_6 = PyNumber_Remainder(__pyx_k61p, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyList_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;} - Py_INCREF(__pyx_k18p); - PyList_SET_ITEM(__pyx_1, 0, __pyx_k18p); + __pyx_1 = PyList_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; goto __pyx_L1;} + Py_INCREF(__pyx_k56p); + PyList_SET_ITEM(__pyx_1, 0, __pyx_k56p); PyList_SET_ITEM(__pyx_1, 1, __pyx_2); PyList_SET_ITEM(__pyx_1, 2, __pyx_3); PyList_SET_ITEM(__pyx_1, 3, __pyx_4); @@ -1066,12 +1205,12 @@ __pyx_v_strg = __pyx_1; __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":144 */ - __pyx_2 = PyObject_GetAttr(__pyx_k24p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":329 */ + __pyx_2 = PyObject_GetAttr(__pyx_k62p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; goto __pyx_L1;} Py_INCREF(__pyx_v_strg); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -1101,8 +1240,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":183 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":370 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -1118,20 +1257,59 @@ return __pyx_r; } +static PyObject *__pyx_k63p; + +static char (__pyx_k63[]) = "Span should be between 0 and 1!"; + static int __pyx_f_6cloess_11loess_model_4span___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_span); /*proto*/ static int __pyx_f_6cloess_11loess_model_4span___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_span) { int __pyx_r; - double __pyx_1; + int __pyx_1; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + double __pyx_5; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_span); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":185 */ - __pyx_1 = PyFloat_AsDouble(__pyx_v_span); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; goto __pyx_L1;} - ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->span = __pyx_1; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":372 */ + __pyx_2 = PyFloat_FromDouble(0.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; goto __pyx_L1;} + __pyx_1 = __pyx_1 <= 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (!__pyx_1) { + __pyx_2 = PyFloat_FromDouble(1.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; goto __pyx_L1;} + __pyx_1 = __pyx_1 > 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + } + if (__pyx_1) { + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":373 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} + Py_INCREF(__pyx_k63p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k63p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":374 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_span); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->span = __pyx_5; + __pyx_r = 0; goto __pyx_L0; __pyx_L1:; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); __Pyx_AddTraceback("cloess.loess_model.span.__set__"); __pyx_r = -1; __pyx_L0:; @@ -1146,8 +1324,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":189 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":383 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -1163,6 +1341,62 @@ return __pyx_r; } +static PyObject *__pyx_k64p; + +static char (__pyx_k64[]) = "Degree should be between 0 and 2!"; + +static int __pyx_f_6cloess_11loess_model_6degree___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_degree); /*proto*/ +static int __pyx_f_6cloess_11loess_model_6degree___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_degree) { + int __pyx_r; + int __pyx_1; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_degree); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":385 */ + __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; goto __pyx_L1;} + __pyx_1 = __pyx_1 < 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (!__pyx_1) { + __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; goto __pyx_L1;} + __pyx_1 = __pyx_1 > 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + } + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":386 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;} + Py_INCREF(__pyx_k64p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k64p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("cloess.loess_model.degree.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_degree); + return __pyx_r; +} + static PyObject *__pyx_f_6cloess_11loess_model_9normalize___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_11loess_model_9normalize___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; @@ -1171,13 +1405,13 @@ PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":194 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_bool); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->normalize); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":399 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_bool); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->normalize); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_2; @@ -1204,8 +1438,8 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_normalize); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":196 */ - __pyx_1 = PyInt_AsLong(__pyx_v_normalize); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":401 */ + __pyx_1 = PyInt_AsLong(__pyx_v_normalize); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;} ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->normalize = __pyx_1; __pyx_r = 0; @@ -1225,8 +1459,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":200 */ - __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":412 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -1242,30 +1476,88 @@ return __pyx_r; } -static PyObject *__pyx_f_6cloess_11loess_model_16parametric_flags___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_11loess_model_16parametric_flags___get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; +static PyObject *__pyx_n_symmetric; +static PyObject *__pyx_n_gaussian; + +static PyObject *__pyx_k67p; + +static char (__pyx_k67[]) = "Invalid value for the 'family' argument: should be in ('symmetric', 'gaussian')."; + +static int __pyx_f_6cloess_11loess_model_6family___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_family); /*proto*/ +static int __pyx_f_6cloess_11loess_model_6family___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_family) { + int __pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; + int __pyx_3; + PyObject *__pyx_4 = 0; + char (*__pyx_5); Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_family); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":204 */ - __pyx_1 = PyInt_FromLong(8); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_boolarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->parametric); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":414 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_family, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; goto __pyx_L1;} + Py_INCREF(__pyx_n_symmetric); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_symmetric); + Py_INCREF(__pyx_n_gaussian); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_gaussian); + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; goto __pyx_L1;} + __pyx_3 = !__pyx_3; Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":415 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; goto __pyx_L1;} + Py_INCREF(__pyx_k67p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k67p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":417 */ + __pyx_5 = PyString_AsString(__pyx_v_family); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->family = __pyx_5; + + __pyx_r = 0; goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("cloess.loess_model.family.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_family); + return __pyx_r; +} +static PyObject *__pyx_f_6cloess_11loess_model_16parametric_flags___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_model_16parametric_flags___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":428 */ + __pyx_1 = __pyx_f_6cloess_boolarray_from_data(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->parametric); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); __Pyx_AddTraceback("cloess.loess_model.parametric_flags.__get__"); __pyx_r = 0; __pyx_L0:; @@ -1273,9 +1565,15 @@ return __pyx_r; } -static PyObject *__pyx_n_NPY_LONG; -static PyObject *__pyx_n_max; +static PyObject *__pyx_n_array; +static PyObject *__pyx_n_copy; +static PyObject *__pyx_n_True; +static PyObject *__pyx_n_subok; +static PyObject *__pyx_n_int; +static PyObject *__pyx_n_dtype; +static PyObject *__pyx_n_min; + static int __pyx_f_6cloess_11loess_model_16parametric_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_paramf); /*proto*/ static int __pyx_f_6cloess_11loess_model_16parametric_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_paramf) { PyArrayObject *__pyx_v_p_ndr; @@ -1283,80 +1581,78 @@ int __pyx_v_i; int __pyx_r; PyObject *__pyx_1 = 0; - enum NPY_TYPES __pyx_2; + PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; - PyObject *__pyx_6 = 0; - PyObject *__pyx_7 = 0; - int __pyx_8; + long __pyx_6; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_paramf); __pyx_v_p_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":209 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_NPY_LONG); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;} - __pyx_2 = ((enum NPY_TYPES )PyInt_AsLong(__pyx_1)); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":433 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyArray_FROMANY(__pyx_v_paramf,__pyx_2,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + Py_INCREF(__pyx_v_paramf); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_paramf); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_int); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_dtype, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_p_ndr)); - __pyx_v_p_ndr = ((PyArrayObject *)__pyx_1); - Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_v_p_ndr = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":210 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":434 */ __pyx_v_p_dat = ((long (*))__pyx_v_p_ndr->data); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":211 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - __pyx_8 = __pyx_8 <= 0; - if (__pyx_8) { - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_max); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - __pyx_5 = PyInt_FromLong(8); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - __pyx_6 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_7, 0, __pyx_5); - PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6); - __pyx_5 = 0; - __pyx_6 = 0; - __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_7); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_7); __pyx_7 = 0; - if (PyObject_Cmp(__pyx_3, __pyx_5, &__pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - __pyx_8 = __pyx_8 < 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - } + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":435 */ + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} + __pyx_4 = PyNumber_Subtract(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_6 = PyInt_FromLong(__pyx_8); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - __pyx_4 = PyObject_GetIter(__pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - Py_DECREF(__pyx_6); __pyx_6 = 0; - for (;;) { - __pyx_7 = PyIter_Next(__pyx_4); - if (!__pyx_7) { - if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - break; - } - __pyx_8 = PyInt_AsLong(__pyx_7); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - Py_DECREF(__pyx_7); __pyx_7 = 0; - __pyx_v_i = __pyx_8; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_4); + __pyx_2 = 0; + __pyx_4 = 0; + __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_6 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_6; ++__pyx_v_i) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":212 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":436 */ (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->parametric[__pyx_v_i]) = (__pyx_v_p_dat[__pyx_v_i]); } - Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); - Py_XDECREF(__pyx_6); - Py_XDECREF(__pyx_7); __Pyx_AddTraceback("cloess.loess_model.parametric_flags.__set__"); __pyx_r = -1; __pyx_L0:; @@ -1370,26 +1666,18 @@ static PyObject *__pyx_f_6cloess_11loess_model_17drop_square_flags___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":216 */ - __pyx_1 = PyInt_FromLong(8); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_boolarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->drop_square); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":447 */ + __pyx_1 = __pyx_f_6cloess_boolarray_from_data(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->drop_square); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); __Pyx_AddTraceback("cloess.loess_model.drop_square_flags.__get__"); __pyx_r = 0; __pyx_L0:; @@ -1397,6 +1685,7 @@ return __pyx_r; } + static int __pyx_f_6cloess_11loess_model_17drop_square_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_drop_sq); /*proto*/ static int __pyx_f_6cloess_11loess_model_17drop_square_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_drop_sq) { PyArrayObject *__pyx_v_d_ndr; @@ -1404,80 +1693,78 @@ int __pyx_v_i; int __pyx_r; PyObject *__pyx_1 = 0; - enum NPY_TYPES __pyx_2; + PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; - PyObject *__pyx_6 = 0; - PyObject *__pyx_7 = 0; - int __pyx_8; + long __pyx_6; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_drop_sq); __pyx_v_d_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":221 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_NPY_LONG); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; goto __pyx_L1;} - __pyx_2 = ((enum NPY_TYPES )PyInt_AsLong(__pyx_1)); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":452 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyArray_FROMANY(__pyx_v_drop_sq,__pyx_2,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + Py_INCREF(__pyx_v_drop_sq); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_drop_sq); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_int); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_dtype, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_d_ndr)); - __pyx_v_d_ndr = ((PyArrayObject *)__pyx_1); - Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_v_d_ndr = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":222 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":453 */ __pyx_v_d_dat = ((long (*))__pyx_v_d_ndr->data); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":223 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} - __pyx_8 = __pyx_8 <= 0; - if (__pyx_8) { - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_max); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} - __pyx_5 = PyInt_FromLong(8); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} - __pyx_6 = PyObject_GetAttr(((PyObject *)__pyx_v_d_ndr), __pyx_n_size); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} - __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_7, 0, __pyx_5); - PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6); - __pyx_5 = 0; - __pyx_6 = 0; - __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_7); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_7); __pyx_7 = 0; - if (PyObject_Cmp(__pyx_3, __pyx_5, &__pyx_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} - __pyx_8 = __pyx_8 < 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - } + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":454 */ + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_d_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_4 = PyNumber_Subtract(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_6 = PyInt_FromLong(__pyx_8); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} - __pyx_4 = PyObject_GetIter(__pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} - Py_DECREF(__pyx_6); __pyx_6 = 0; - for (;;) { - __pyx_7 = PyIter_Next(__pyx_4); - if (!__pyx_7) { - if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} - break; - } - __pyx_8 = PyInt_AsLong(__pyx_7); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} - Py_DECREF(__pyx_7); __pyx_7 = 0; - __pyx_v_i = __pyx_8; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_4); + __pyx_2 = 0; + __pyx_4 = 0; + __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_6 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_6; ++__pyx_v_i) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":224 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":455 */ (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->drop_square[__pyx_v_i]) = (__pyx_v_d_dat[__pyx_v_i]); } - Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); - Py_XDECREF(__pyx_6); - Py_XDECREF(__pyx_7); __Pyx_AddTraceback("cloess.loess_model.drop_square_flags.__set__"); __pyx_r = -1; __pyx_L0:; @@ -1526,146 +1813,146 @@ __pyx_v_parametric = Py_None; Py_INCREF(Py_None); __pyx_v_drop_square = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":227 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":458 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;} Py_INCREF(__pyx_n_family); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_family); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_family); __pyx_v_family = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":228 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":459 */ __pyx_4 = __pyx_v_family != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":229 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_family, __pyx_v_family) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":460 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_family, __pyx_v_family) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":231 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":462 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} Py_INCREF(__pyx_n_span); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_span); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_span); __pyx_v_span = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":232 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":463 */ __pyx_4 = __pyx_v_span != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":233 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_span, __pyx_v_span) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":464 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_span, __pyx_v_span) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; goto __pyx_L1;} goto __pyx_L3; } __pyx_L3:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":235 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":466 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; goto __pyx_L1;} Py_INCREF(__pyx_n_degree); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_degree); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_degree); __pyx_v_degree = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":236 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":467 */ __pyx_4 = __pyx_v_degree != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":237 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_degree, __pyx_v_degree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":468 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_degree, __pyx_v_degree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; goto __pyx_L1;} goto __pyx_L4; } __pyx_L4:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":239 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":470 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; goto __pyx_L1;} Py_INCREF(__pyx_n_normalize); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_normalize); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_normalize); __pyx_v_normalize = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":240 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":471 */ __pyx_4 = __pyx_v_normalize != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":241 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_normalize, __pyx_v_normalize) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":472 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_normalize, __pyx_v_normalize) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} goto __pyx_L5; } __pyx_L5:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":243 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":474 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} Py_INCREF(__pyx_n_parametric); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_parametric); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_parametric); __pyx_v_parametric = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":244 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":475 */ __pyx_4 = __pyx_v_parametric != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":245 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_parametric) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":476 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_parametric) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;} goto __pyx_L6; } __pyx_L6:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":247 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":478 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} Py_INCREF(__pyx_n_drop_square); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_drop_square); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_drop_square); __pyx_v_drop_square = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":248 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":479 */ __pyx_4 = __pyx_v_drop_square != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":249 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_drop_square_flags, __pyx_v_drop_square) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":480 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_drop_square_flags, __pyx_v_drop_square) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; goto __pyx_L1;} goto __pyx_L7; } __pyx_L7:; @@ -1694,9 +1981,9 @@ static PyObject *__pyx_n_id; -static PyObject *__pyx_k31p; +static PyObject *__pyx_k80p; -static char (__pyx_k31[]) = "loess model parameters @%s"; +static char (__pyx_k80[]) = "loess model parameters @%s"; static PyObject *__pyx_f_6cloess_11loess_model___repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_11loess_model___repr__(PyObject *__pyx_v_self) { @@ -1706,15 +1993,15 @@ PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":252 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":483 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;} Py_INCREF(__pyx_v_self); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyNumber_Remainder(__pyx_k31p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k80p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_1; __pyx_1 = 0; @@ -1733,23 +2020,23 @@ return __pyx_r; } -static PyObject *__pyx_k32p; -static PyObject *__pyx_k33p; -static PyObject *__pyx_k34p; -static PyObject *__pyx_k35p; -static PyObject *__pyx_k36p; -static PyObject *__pyx_k37p; -static PyObject *__pyx_k38p; -static PyObject *__pyx_k39p; +static PyObject *__pyx_k81p; +static PyObject *__pyx_k82p; +static PyObject *__pyx_k83p; +static PyObject *__pyx_k84p; +static PyObject *__pyx_k85p; +static PyObject *__pyx_k86p; +static PyObject *__pyx_k87p; +static PyObject *__pyx_k88p; -static char (__pyx_k32[]) = "Model parameters....."; -static char (__pyx_k33[]) = "family : %s"; -static char (__pyx_k34[]) = "span : %s"; -static char (__pyx_k35[]) = "degree : %s"; -static char (__pyx_k36[]) = "normalized : %s"; -static char (__pyx_k37[]) = "parametric : %s"; -static char (__pyx_k38[]) = "drop_square : %s"; -static char (__pyx_k39[]) = "\n"; +static char (__pyx_k81[]) = "Model parameters....."; +static char (__pyx_k82[]) = "family : %s"; +static char (__pyx_k83[]) = "span : %s"; +static char (__pyx_k84[]) = "degree : %s"; +static char (__pyx_k85[]) = "normalized : %s"; +static char (__pyx_k86[]) = "parametric : %s"; +static char (__pyx_k87[]) = "drop_square : %s"; +static char (__pyx_k88[]) = "\n"; static PyObject *__pyx_f_6cloess_11loess_model___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_11loess_model___str__(PyObject *__pyx_v_self) { @@ -1765,32 +2052,32 @@ Py_INCREF(__pyx_v_self); __pyx_v_strg = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":255 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k33p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":486 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k82p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;} - __pyx_3 = PyNumber_Remainder(__pyx_k34p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k83p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} - __pyx_4 = PyNumber_Remainder(__pyx_k35p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k84p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_normalize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; goto __pyx_L1;} - __pyx_5 = PyNumber_Remainder(__pyx_k36p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_normalize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k85p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_parametric_flags); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;} - __pyx_6 = PySequence_GetSlice(__pyx_1, 0, ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_parametric_flags); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; goto __pyx_L1;} + __pyx_6 = PySequence_GetSlice(__pyx_1, 0, ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyNumber_Remainder(__pyx_k37p, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k86p, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; - __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_drop_square_flags); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;} - __pyx_7 = PySequence_GetSlice(__pyx_6, 0, ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_drop_square_flags); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;} + __pyx_7 = PySequence_GetSlice(__pyx_6, 0, ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; - __pyx_6 = PyNumber_Remainder(__pyx_k38p, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;} + __pyx_6 = PyNumber_Remainder(__pyx_k87p, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;} Py_DECREF(__pyx_7); __pyx_7 = 0; - __pyx_7 = PyList_New(7); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;} - Py_INCREF(__pyx_k32p); - PyList_SET_ITEM(__pyx_7, 0, __pyx_k32p); + __pyx_7 = PyList_New(7); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;} + Py_INCREF(__pyx_k81p); + PyList_SET_ITEM(__pyx_7, 0, __pyx_k81p); PyList_SET_ITEM(__pyx_7, 1, __pyx_2); PyList_SET_ITEM(__pyx_7, 2, __pyx_3); PyList_SET_ITEM(__pyx_7, 3, __pyx_4); @@ -1807,12 +2094,12 @@ __pyx_v_strg = __pyx_7; __pyx_7 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":263 */ - __pyx_2 = PyObject_GetAttr(__pyx_k39p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":494 */ + __pyx_2 = PyObject_GetAttr(__pyx_k88p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} Py_INCREF(__pyx_v_strg); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -1841,26 +2128,18 @@ static PyObject *__pyx_f_6cloess_13loess_outputs_13fitted_values___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":274 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->fitted_values); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":510 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->fitted_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); __Pyx_AddTraceback("cloess.loess_outputs.fitted_values.__get__"); __pyx_r = 0; __pyx_L0:; @@ -1872,26 +2151,18 @@ static PyObject *__pyx_f_6cloess_13loess_outputs_16fitted_residuals___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":278 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->fitted_residuals); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":518 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->fitted_residuals); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); __Pyx_AddTraceback("cloess.loess_outputs.fitted_residuals.__get__"); __pyx_r = 0; __pyx_L0:; @@ -1903,26 +2174,18 @@ static PyObject *__pyx_f_6cloess_13loess_outputs_12pseudovalues___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":282 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->pseudovalues); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":527 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->pseudovalues); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); __Pyx_AddTraceback("cloess.loess_outputs.pseudovalues.__get__"); __pyx_r = 0; __pyx_L0:; @@ -1934,26 +2197,18 @@ static PyObject *__pyx_f_6cloess_13loess_outputs_8diagonal___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":286 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->diagonal); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":535 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->diagonal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); __Pyx_AddTraceback("cloess.loess_outputs.diagonal.__get__"); __pyx_r = 0; __pyx_L0:; @@ -1965,26 +2220,18 @@ static PyObject *__pyx_f_6cloess_13loess_outputs_6robust___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":290 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->robust); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":543 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->robust); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); __Pyx_AddTraceback("cloess.loess_outputs.robust.__get__"); __pyx_r = 0; __pyx_L0:; @@ -1992,30 +2239,28 @@ return __pyx_r; } +static PyObject *__pyx_n_nvar; + static PyObject *__pyx_f_6cloess_13loess_outputs_7divisor___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_13loess_outputs_7divisor___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; + int __pyx_2; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":294 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->divisor); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":548 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_nvar); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;} + __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(__pyx_2,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->divisor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); __Pyx_AddTraceback("cloess.loess_outputs.divisor.__get__"); __pyx_r = 0; __pyx_L0:; @@ -2029,8 +2274,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":299 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":556 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2052,8 +2297,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":304 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":564 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2075,8 +2320,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":309 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":572 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2098,8 +2343,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":314 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->two_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":580 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->two_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2121,8 +2366,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":319 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":588 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2138,14 +2383,128 @@ return __pyx_r; } +static PyObject *__pyx_n_fitted_values; +static PyObject *__pyx_n_fitted_residuals; +static PyObject *__pyx_n_enp; +static PyObject *__pyx_n_s; +static PyObject *__pyx_n_one_delta; +static PyObject *__pyx_n_two_delta; +static PyObject *__pyx_n_divisor; + +static PyObject *__pyx_k89p; +static PyObject *__pyx_k90p; +static PyObject *__pyx_k91p; +static PyObject *__pyx_k92p; +static PyObject *__pyx_k93p; +static PyObject *__pyx_k94p; +static PyObject *__pyx_k95p; +static PyObject *__pyx_k96p; + +static char (__pyx_k89[]) = "Outputs................"; +static char (__pyx_k90[]) = "Fitted values : %s\n"; +static char (__pyx_k91[]) = "Fitted residuals : %s\n"; +static char (__pyx_k92[]) = "Eqv. nb of parameters : %s"; +static char (__pyx_k93[]) = "Residual error : %s"; +static char (__pyx_k94[]) = "Deltas : %s - %s"; +static char (__pyx_k95[]) = "Normalization factors : %s"; +static char (__pyx_k96[]) = "\n"; + +static PyObject *__pyx_f_6cloess_13loess_outputs___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_13loess_outputs___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_strg; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + PyObject *__pyx_7 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_strg = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":591 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k90p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_residuals); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k91p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k92p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k93p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_two_delta); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;} + __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1); + PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6); + __pyx_1 = 0; + __pyx_6 = 0; + __pyx_1 = PyNumber_Remainder(__pyx_k94p, __pyx_7); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;} + Py_DECREF(__pyx_7); __pyx_7 = 0; + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_divisor); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; goto __pyx_L1;} + __pyx_7 = PyNumber_Remainder(__pyx_k95p, __pyx_6); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_6 = PyList_New(7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;} + Py_INCREF(__pyx_k89p); + PyList_SET_ITEM(__pyx_6, 0, __pyx_k89p); + PyList_SET_ITEM(__pyx_6, 1, __pyx_2); + PyList_SET_ITEM(__pyx_6, 2, __pyx_3); + PyList_SET_ITEM(__pyx_6, 3, __pyx_4); + PyList_SET_ITEM(__pyx_6, 4, __pyx_5); + PyList_SET_ITEM(__pyx_6, 5, __pyx_1); + PyList_SET_ITEM(__pyx_6, 6, __pyx_7); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_1 = 0; + __pyx_7 = 0; + Py_DECREF(__pyx_v_strg); + __pyx_v_strg = __pyx_6; + __pyx_6 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":598 */ + __pyx_2 = PyObject_GetAttr(__pyx_k96p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;} + Py_INCREF(__pyx_v_strg); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + Py_XDECREF(__pyx_7); + __Pyx_AddTraceback("cloess.loess_outputs.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_strg); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + static PyObject *__pyx_f_6cloess_11loess_anova_3dfn___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_11loess_anova_3dfn___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":339 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->dfn); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":610 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->dfn); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2167,8 +2526,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":343 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->dfd); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":614 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->dfd); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2190,8 +2549,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":347 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->F_value); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":618 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->F_value); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2213,8 +2572,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":351 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->Pr_F); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":622 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->Pr_F); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2232,21 +2591,21 @@ static PyObject *__pyx_n_pw_free_mem; -static void __pyx_f_6cloess_19confidence_interval___dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_f_6cloess_19confidence_interval___dealloc__(PyObject *__pyx_v_self) { +static void __pyx_f_6cloess_14conf_intervals___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_f_6cloess_14conf_intervals___dealloc__(PyObject *__pyx_v_self) { PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":361 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_c_loess); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_pw_free_mem); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":632 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_c_loess); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_pw_free_mem); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;} Py_INCREF(__pyx_v_self); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self); - __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; @@ -2256,91 +2615,135 @@ Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("cloess.confidence_interval.__dealloc__"); + __Pyx_AddTraceback("cloess.conf_intervals.__dealloc__"); __pyx_L0:; Py_DECREF(__pyx_v_self); } -static PyObject *__pyx_n_nest; +static PyObject *__pyx_f_6cloess_14conf_intervals_3fit___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_14conf_intervals_3fit___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + int __pyx_1; + PyObject *__pyx_2 = 0; + Py_INCREF(__pyx_v_self); -static PyObject *__pyx_f_6cloess_19confidence_interval_3fit___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_19confidence_interval_3fit___get__(PyObject *__pyx_v_self) { + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":640 */ + __pyx_1 = PyInt_AsLong(((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->nest); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + __pyx_2 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,1,((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->_base.fit); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + __pyx_r = __pyx_2; + __pyx_2 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_2); + __Pyx_AddTraceback("cloess.conf_intervals.fit.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_14conf_intervals_5upper___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_14conf_intervals_5upper___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; - PyObject *__pyx_1 = 0; + int __pyx_1; PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":365 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_confidence_interval *)__pyx_v_self)->_base->fit); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":648 */ + __pyx_1 = PyInt_AsLong(((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->nest); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; goto __pyx_L1;} + __pyx_2 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,1,((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->_base.upper); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; goto __pyx_L1;} + __pyx_r = __pyx_2; + __pyx_2 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; - Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("cloess.confidence_interval.fit.__get__"); + __Pyx_AddTraceback("cloess.conf_intervals.upper.__get__"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } -static PyObject *__pyx_f_6cloess_19confidence_interval_5upper___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_19confidence_interval_5upper___get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_f_6cloess_14conf_intervals_5lower___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_14conf_intervals_5lower___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; - PyObject *__pyx_1 = 0; + int __pyx_1; PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":369 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_confidence_interval *)__pyx_v_self)->_base->upper); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":656 */ + __pyx_1 = PyInt_AsLong(((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->nest); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;} + __pyx_2 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,1,((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->_base.lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;} + __pyx_r = __pyx_2; + __pyx_2 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; - Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("cloess.confidence_interval.upper.__get__"); + __Pyx_AddTraceback("cloess.conf_intervals.lower.__get__"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } -static PyObject *__pyx_f_6cloess_19confidence_interval_5lower___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_19confidence_interval_5lower___get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_n_r_; +static PyObject *__pyx_n_fit; +static PyObject *__pyx_n_upper; +static PyObject *__pyx_n_T; + +static PyObject *__pyx_k97p; + +static char (__pyx_k97[]) = "Confidence intervals....\nLower b./ fit / upper b.\n%s"; + +static PyObject *__pyx_f_6cloess_14conf_intervals___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_14conf_intervals___str__(PyObject *__pyx_v_self) { + PyArrayObject *__pyx_v_tmp_ndr; PyObject *__pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; Py_INCREF(__pyx_v_self); + __pyx_v_tmp_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":373 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_confidence_interval *)__pyx_v_self)->_base->lower); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":660 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_r_); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fit); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} + __pyx_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_upper); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} + __pyx_5 = PyList_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} + PyList_SET_ITEM(__pyx_5, 0, __pyx_1); + PyList_SET_ITEM(__pyx_5, 1, __pyx_3); + PyList_SET_ITEM(__pyx_5, 2, __pyx_4); + __pyx_1 = 0; + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_1 = PyObject_GetItem(__pyx_2, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_T); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_tmp_ndr)); + __pyx_v_tmp_ndr = ((PyArrayObject *)__pyx_3); __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":661 */ + __pyx_4 = PyNumber_Remainder(__pyx_k97p, ((PyObject *)__pyx_v_tmp_ndr)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; goto __pyx_L1;} + __pyx_r = __pyx_4; + __pyx_4 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); @@ -2349,9 +2752,12 @@ Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("cloess.confidence_interval.lower.__get__"); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("cloess.conf_intervals.__str__"); __pyx_r = 0; __pyx_L0:; + Py_DECREF(__pyx_v_tmp_ndr); Py_DECREF(__pyx_v_self); return __pyx_r; } @@ -2360,84 +2766,66 @@ static void __pyx_f_6cloess_15loess_predicted___dealloc__(PyObject *__pyx_v_self) { Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":384 */ - pred_free_mem(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":674 */ + pred_free_mem((&((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base)); Py_DECREF(__pyx_v_self); } -static PyObject *__pyx_f_6cloess_15loess_predicted_9predicted___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_15loess_predicted_9predicted___get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_f_6cloess_15loess_predicted_6values___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_15loess_predicted_6values___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":388 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base->fit); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":682 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base.fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("cloess.loess_predicted.predicted.__get__"); + __Pyx_AddTraceback("cloess.loess_predicted.values.__get__"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } -static PyObject *__pyx_f_6cloess_15loess_predicted_16predicted_stderr___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_15loess_predicted_16predicted_stderr___get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_f_6cloess_15loess_predicted_6stderr___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_15loess_predicted_6stderr___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":392 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;} - __pyx_3 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,__pyx_2,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base->se_fit); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":691 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base.se_fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("cloess.loess_predicted.predicted_stderr.__get__"); + __Pyx_AddTraceback("cloess.loess_predicted.stderr.__get__"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } -static PyObject *__pyx_n_residual_scale; - static PyObject *__pyx_f_6cloess_15loess_predicted_14residual_scale___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_15loess_predicted_14residual_scale___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":396 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":699 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base.residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2453,16 +2841,14 @@ return __pyx_r; } -static PyObject *__pyx_n_df; - static PyObject *__pyx_f_6cloess_15loess_predicted_2df___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_15loess_predicted_2df___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":400 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":708 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base.df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2478,25 +2864,98 @@ return __pyx_r; } +static PyObject *__pyx_k98p; + +static char (__pyx_k98[]) = "The coverage precentage should be between 0 and 1!"; + static PyObject *__pyx_f_6cloess_15loess_predicted_confidence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6cloess_15loess_predicted_confidence[] = "\n coverage : float\n Confidence level of the confidence intervals limits as a fraction.\n "; +static char __pyx_doc_6cloess_15loess_predicted_confidence[] = "Returns the pointwise confidence intervals for each predicted values,\nat the given confidence interval coverage.\n \n:Parameters:\n coverage : float\n Confidence level of the confidence intervals limits, as a fraction.\n "; static PyObject *__pyx_f_6cloess_15loess_predicted_confidence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_coverage = 0; + conf_inv __pyx_v__conf_intv; PyObject *__pyx_r; - double __pyx_1; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + double __pyx_5; static char *__pyx_argnames[] = {"coverage",0}; - __pyx_v_coverage = __pyx_k7; + __pyx_v_coverage = __pyx_k35; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_coverage)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_coverage); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":407 */ - __pyx_1 = PyFloat_AsDouble(__pyx_v_coverage); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;} - pointwise(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest,__pyx_1,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->conf_interval->_base); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":719 */ + __pyx_1 = PyFloat_FromDouble(0.5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;} + __pyx_2 = __pyx_2 < 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_2) { + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":720 */ + __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; goto __pyx_L1;} + __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_v_coverage); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_v_coverage); + __pyx_v_coverage = __pyx_3; + __pyx_3 = 0; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":721 */ + __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;} + __pyx_2 = __pyx_2 > 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":722 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; goto __pyx_L1;} + Py_INCREF(__pyx_k98p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k98p); + __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":723 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_coverage); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; goto __pyx_L1;} + pointwise((&((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base),((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest,__pyx_5,(&__pyx_v__conf_intv)); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":724 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_conf_intervals), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6cloess_conf_intervals)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals)); + ((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals = ((struct __pyx_obj_6cloess_conf_intervals *)__pyx_3); + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":725 */ + ((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals->_base = __pyx_v__conf_intv; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":726 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;} + Py_DECREF(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals->nest); + ((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals->nest = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":727 */ + Py_INCREF(((PyObject *)((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals)); + __pyx_r = ((PyObject *)((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals); + goto __pyx_L0; + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); __Pyx_AddTraceback("cloess.loess_predicted.confidence"); __pyx_r = 0; __pyx_L0:; @@ -2505,28 +2964,136 @@ return __pyx_r; } +static PyObject *__pyx_n_values; +static PyObject *__pyx_n_stderr; +static PyObject *__pyx_n_residual_scale; +static PyObject *__pyx_n_df; + +static PyObject *__pyx_k99p; +static PyObject *__pyx_k100p; +static PyObject *__pyx_k101p; +static PyObject *__pyx_k102p; +static PyObject *__pyx_k103p; +static PyObject *__pyx_k104p; + +static char (__pyx_k99[]) = "Outputs................"; +static char (__pyx_k100[]) = "Predicted values : %s\n"; +static char (__pyx_k101[]) = "Predicted std error : %s\n"; +static char (__pyx_k102[]) = "Residual scale : %s"; +static char (__pyx_k103[]) = "Degrees of freedom : %s"; +static char (__pyx_k104[]) = "\n"; + +static PyObject *__pyx_f_6cloess_15loess_predicted___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_15loess_predicted___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_strg; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_strg = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":730 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k100p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_stderr); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k101p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k102p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k103p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyList_New(5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; goto __pyx_L1;} + Py_INCREF(__pyx_k99p); + PyList_SET_ITEM(__pyx_1, 0, __pyx_k99p); + PyList_SET_ITEM(__pyx_1, 1, __pyx_2); + PyList_SET_ITEM(__pyx_1, 2, __pyx_3); + PyList_SET_ITEM(__pyx_1, 3, __pyx_4); + PyList_SET_ITEM(__pyx_1, 4, __pyx_5); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + Py_DECREF(__pyx_v_strg); + __pyx_v_strg = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":737 */ + __pyx_2 = PyObject_GetAttr(__pyx_k104p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; goto __pyx_L1;} + Py_INCREF(__pyx_v_strg); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("cloess.loess_predicted.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_strg); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_order; +static PyObject *__pyx_n_C; static PyObject *__pyx_n_len; +static PyObject *__pyx_n_iteritems; +static PyObject *__pyx_n_update; +static PyObject *__pyx_k113p; + +static char (__pyx_k113[]) = "Incompatible size between the response array (%i) and the predictor array (%i)"; + static int __pyx_f_6cloess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_f_6cloess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_x = 0; PyObject *__pyx_v_y = 0; PyObject *__pyx_v_weights = 0; + PyObject *__pyx_v_options = 0; PyArrayObject *__pyx_v_x_ndr; PyArrayObject *__pyx_v_y_ndr; double (*__pyx_v_x_dat); double (*__pyx_v_y_dat); PyObject *__pyx_v_n; PyObject *__pyx_v_p; + PyObject *__pyx_v_modelopt; + PyObject *__pyx_v_controlopt; + PyObject *__pyx_v_k; + PyObject *__pyx_v_v; int __pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; - long __pyx_4; + PyObject *__pyx_4 = 0; long __pyx_5; + int __pyx_6; + long __pyx_7; static char *__pyx_argnames[] = {"x","y","weights",0}; - __pyx_v_weights = __pyx_k8; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_weights)) return -1; + __pyx_v_weights = __pyx_k36; + if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 3, 0, &__pyx_v_options) < 0) return -1; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_weights)) { + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + Py_XDECREF(__pyx_v_options); + return -1; + } Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_x); Py_INCREF(__pyx_v_y); @@ -2535,164 +3102,383 @@ __pyx_v_y_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_n = Py_None; Py_INCREF(Py_None); __pyx_v_p = Py_None; Py_INCREF(Py_None); + __pyx_v_modelopt = Py_None; Py_INCREF(Py_None); + __pyx_v_controlopt = Py_None; Py_INCREF(Py_None); + __pyx_v_k = Py_None; Py_INCREF(Py_None); + __pyx_v_v = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":429 */ - __pyx_1 = PyArray_FROMANY(__pyx_v_x,NPY_DOUBLE,1,1,NPY_FORTRAN); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); - Py_DECREF(((PyObject *)__pyx_v_x_ndr)); - __pyx_v_x_ndr = ((PyArrayObject *)__pyx_1); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":759 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":430 */ - __pyx_1 = PyArray_FROMANY(__pyx_v_y,NPY_DOUBLE,1,1,NPY_FORTRAN); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); - Py_DECREF(((PyObject *)__pyx_v_y_ndr)); - __pyx_v_y_ndr = ((PyArrayObject *)__pyx_1); + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + Py_INCREF(__pyx_v_x); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_x); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_x_ndr)); + __pyx_v_x_ndr = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":431 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":760 */ __pyx_v_x_dat = ((double (*))__pyx_v_x_ndr->data); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":432 */ - __pyx_v_y_dat = ((double (*))__pyx_v_y_ndr->data); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":433 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":761 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;} Py_INCREF(((PyObject *)__pyx_v_x_ndr)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_x_ndr)); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_x_ndr)); + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_n); __pyx_v_n = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":434 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_x_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; goto __pyx_L1;} - __pyx_2 = PyNumber_Divide(__pyx_1, __pyx_v_n); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":762 */ + __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_x_ndr), __pyx_n_size); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; goto __pyx_L1;} + __pyx_2 = PyNumber_Divide(__pyx_4, __pyx_v_n); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_v_p); __pyx_v_p = __pyx_2; __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":435 */ - __pyx_4 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} - __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} - loess_setup(__pyx_v_x_dat,__pyx_v_y_dat,__pyx_4,__pyx_5,(&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base)); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":763 */ + __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->npar = __pyx_5; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":437 */ - __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_inputs), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6cloess_loess_inputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":764 */ + __pyx_5 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->nobs = __pyx_5; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":766 */ + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_p, __pyx_1, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;} + __pyx_6 = __pyx_6 > 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_6) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":767 */ + __pyx_3 = PyNumber_Multiply(__pyx_v_n, __pyx_v_p); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + if (PyObject_SetAttr(((PyObject *)__pyx_v_x_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":769 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + Py_INCREF(__pyx_v_y); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_y); + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (PyDict_SetItem(__pyx_4, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + __pyx_2 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_y_ndr)); + __pyx_v_y_ndr = ((PyArrayObject *)__pyx_2); + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":770 */ + __pyx_v_y_dat = ((double (*))__pyx_v_y_ndr->data); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":771 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_y_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_v_n, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;} + __pyx_6 = __pyx_6 != 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_6) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":772 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_v_y_ndr)); + PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_y_ndr)); + Py_INCREF(__pyx_v_n); + PyTuple_SET_ITEM(__pyx_4, 1, __pyx_v_n); + __pyx_2 = PyNumber_Remainder(__pyx_k113p, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); + __pyx_2 = 0; + __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":775 */ + __pyx_5 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;} + __pyx_7 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;} + loess_setup(__pyx_v_x_dat,__pyx_v_y_dat,__pyx_5,__pyx_7,(&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base)); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":777 */ + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_inputs), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_inputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs)); - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs = ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_3); - __pyx_3 = 0; + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs = ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_2); + __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":438 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":778 */ ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.inputs); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":440 */ - __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_model), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_6cloess_loess_model)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":780 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_model), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6cloess_loess_model)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model)); - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model = ((struct __pyx_obj_6cloess_loess_model *)__pyx_1); - __pyx_1 = 0; + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model = ((struct __pyx_obj_6cloess_loess_model *)__pyx_3); + __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":441 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":781 */ ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.model); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":442 */ - __pyx_4 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;} - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model->npar = __pyx_4; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":782 */ + __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model->npar = __pyx_5; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":444 */ - __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_control), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_control)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":784 */ + __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_control), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_6cloess_loess_control)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control)); - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control = ((struct __pyx_obj_6cloess_loess_control *)__pyx_2); - __pyx_2 = 0; + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control = ((struct __pyx_obj_6cloess_loess_control *)__pyx_1); + __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":445 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":785 */ ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.control); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":447 */ - __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_kd_tree), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6cloess_loess_kd_tree)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":787 */ + __pyx_4 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_kd_tree), 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_6cloess_loess_kd_tree)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree)); - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree = ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_3); - __pyx_3 = 0; + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree = ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_4); + __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":448 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":788 */ ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.kd_tree); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":450 */ - __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_outputs), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_6cloess_loess_outputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":790 */ + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_outputs), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_outputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs)); - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs = ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_1); - __pyx_1 = 0; + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs = ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_2); + __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":451 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":791 */ ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.outputs); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":452 */ - __pyx_5 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->nobs = __pyx_5; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":792 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; goto __pyx_L1;} + __pyx_6 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->activated = __pyx_6; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":793 */ + __pyx_7 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->nobs = __pyx_7; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":794 */ + __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->npar = __pyx_5; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":796 */ + __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;} + Py_DECREF(__pyx_v_modelopt); + __pyx_v_modelopt = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":797 */ + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;} + Py_DECREF(__pyx_v_controlopt); + __pyx_v_controlopt = __pyx_4; + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":798 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_options, __pyx_n_iteritems); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = PyObject_GetIter(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + for (;;) { + __pyx_4 = PyIter_Next(__pyx_1); + if (!__pyx_4) { + if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + break; + } + __pyx_2 = PyObject_GetIter(__pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_3 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + Py_DECREF(__pyx_v_k); + __pyx_v_k = __pyx_3; + __pyx_3 = 0; + __pyx_4 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + Py_DECREF(__pyx_v_v); + __pyx_v_v = __pyx_4; + __pyx_4 = 0; + if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":799 */ + __pyx_3 = PyTuple_New(6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;} + Py_INCREF(__pyx_n_family); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_family); + Py_INCREF(__pyx_n_span); + PyTuple_SET_ITEM(__pyx_3, 1, __pyx_n_span); + Py_INCREF(__pyx_n_degree); + PyTuple_SET_ITEM(__pyx_3, 2, __pyx_n_degree); + Py_INCREF(__pyx_n_normalize); + PyTuple_SET_ITEM(__pyx_3, 3, __pyx_n_normalize); + Py_INCREF(__pyx_n_parametric); + PyTuple_SET_ITEM(__pyx_3, 4, __pyx_n_parametric); + Py_INCREF(__pyx_n_drop_square); + PyTuple_SET_ITEM(__pyx_3, 5, __pyx_n_drop_square); + __pyx_6 = PySequence_Contains(__pyx_3, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__pyx_6) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":801 */ + if (PyObject_SetItem(__pyx_v_modelopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;} + goto __pyx_L6; + } + __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;} + Py_INCREF(__pyx_n_surface); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_surface); + Py_INCREF(__pyx_n_statistics); + PyTuple_SET_ITEM(__pyx_4, 1, __pyx_n_statistics); + Py_INCREF(__pyx_n_trace_hat); + PyTuple_SET_ITEM(__pyx_4, 2, __pyx_n_trace_hat); + Py_INCREF(__pyx_n_iterations); + PyTuple_SET_ITEM(__pyx_4, 3, __pyx_n_iterations); + Py_INCREF(__pyx_n_cell); + PyTuple_SET_ITEM(__pyx_4, 4, __pyx_n_cell); + __pyx_6 = PySequence_Contains(__pyx_4, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (__pyx_6) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":804 */ + if (PyObject_SetItem(__pyx_v_controlopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; goto __pyx_L1;} + goto __pyx_L6; + } + __pyx_L6:; + } + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":805 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control), __pyx_n_update); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;} + __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;} + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_3, __pyx_v_controlopt); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":806 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model), __pyx_n_update); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;} + __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;} + __pyx_3 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_2, __pyx_v_modelopt); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); __Pyx_AddTraceback("cloess.loess.__init__"); __pyx_r = -1; __pyx_L0:; + Py_XDECREF(__pyx_v_options); Py_DECREF(__pyx_v_x_ndr); Py_DECREF(__pyx_v_y_ndr); Py_DECREF(__pyx_v_n); Py_DECREF(__pyx_v_p); + Py_DECREF(__pyx_v_modelopt); + Py_DECREF(__pyx_v_controlopt); + Py_DECREF(__pyx_v_k); + Py_DECREF(__pyx_v_v); Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_x); Py_DECREF(__pyx_v_y); Py_DECREF(__pyx_v_weights); + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); return __pyx_r; } static PyObject *__pyx_f_6cloess_5loess_fit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6cloess_5loess_fit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; static char *__pyx_argnames[] = {0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":455 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":809 */ loess_fit((&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base)); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":456 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":810 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;} + __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->activated = __pyx_2; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":811 */ __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("cloess.loess.fit"); + __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } static PyObject *__pyx_n_nobs; -static PyObject *__pyx_n_enp; -static PyObject *__pyx_n_gaussian; -static PyObject *__pyx_n_s; -static PyObject *__pyx_k40p; -static PyObject *__pyx_k41p; -static PyObject *__pyx_k43p; -static PyObject *__pyx_k44p; +static PyObject *__pyx_k125p; +static PyObject *__pyx_k126p; +static PyObject *__pyx_k128p; +static PyObject *__pyx_k129p; -static char (__pyx_k40[]) = "Number of Observations : %d"; -static char (__pyx_k41[]) = "Equivalent Number of Parameters: %.1f"; -static char (__pyx_k43[]) = "Residual Standard Error : %.4f"; -static char (__pyx_k44[]) = "Residual Scale Estimate : %.4f"; +static char (__pyx_k125[]) = "Number of Observations : %d"; +static char (__pyx_k126[]) = "Equivalent Number of Parameters: %.1f"; +static char (__pyx_k128[]) = "Residual Standard Error : %.4f"; +static char (__pyx_k129[]) = "Residual Scale Estimate : %.4f"; static PyObject *__pyx_f_6cloess_5loess_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6cloess_5loess_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -2704,47 +3490,47 @@ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":459 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs), __pyx_n_nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k40p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":814 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs), __pyx_n_nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k125p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":460 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k41p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":815 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k126p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":461 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model), __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_n_gaussian, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":816 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model), __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_n_gaussian, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} __pyx_3 = __pyx_3 == 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_3) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":462 */ - __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} - __pyx_1 = PyNumber_Remainder(__pyx_k43p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":817 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k128p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} goto __pyx_L2; } /*else*/ { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":464 */ - __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; goto __pyx_L1;} - __pyx_1 = PyNumber_Remainder(__pyx_k44p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":819 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k129p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;} } __pyx_L2:; @@ -2760,8 +3546,15 @@ return __pyx_r; } -static PyObject *__pyx_n_nvar; +static PyObject *__pyx_n_ravel; +static PyObject *__pyx_n_divmod; +static PyObject *__pyx_k134p; +static PyObject *__pyx_k135p; + +static char (__pyx_k134[]) = "Can't predict without input data !"; +static char (__pyx_k135[]) = "Incompatible data size: there should be as many rows as parameters"; + static PyObject *__pyx_f_6cloess_5loess_predict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6cloess_5loess_predict[] = "\n newdata: ndarray\n A (m,p) ndarray specifying the values of the predictors at which the \n evaluation is to be carried out.\n stderr: Boolean\n Logical flag for computing standard errors at newdata.\n "; static PyObject *__pyx_f_6cloess_5loess_predict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -2769,137 +3562,315 @@ PyObject *__pyx_v_stderr = 0; PyArrayObject *__pyx_v_p_ndr; double (*__pyx_v_p_dat); + prediction __pyx_v__prediction; int __pyx_v_m; + PyObject *__pyx_v_notOK; PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - int __pyx_2; + int __pyx_1; + PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"newdata","stderr",0}; - __pyx_v_stderr = __pyx_k9; + __pyx_v_stderr = __pyx_k37; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_newdata, &__pyx_v_stderr)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_newdata); Py_INCREF(__pyx_v_stderr); __pyx_v_p_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + __pyx_v_notOK = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":478 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_nvar); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} - __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyArray_FROMANY(__pyx_v_newdata,NPY_DOUBLE,1,__pyx_2,NPY_FORTRAN); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":834 */ + __pyx_1 = (((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->activated == 0); + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":835 */ + loess_fit((&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base)); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":836 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;} + __pyx_1 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->activated = __pyx_1; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":838 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + Py_INCREF(__pyx_v_newdata); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_newdata); + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (PyDict_SetItem(__pyx_4, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_3, __pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_ravel); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_2 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_p_ndr)); - __pyx_v_p_ndr = ((PyArrayObject *)__pyx_1); - Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_v_p_ndr = ((PyArrayObject *)__pyx_2); + __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":479 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":839 */ __pyx_v_p_dat = ((double (*))__pyx_v_p_ndr->data); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":480 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":841 */ + __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; goto __pyx_L1;} + __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_4, __pyx_5, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; goto __pyx_L1;} + __pyx_1 = __pyx_1 == 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":842 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;} + Py_INCREF(__pyx_k134p); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k134p); + __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":843 */ + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_divmod); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} Py_INCREF(((PyObject *)__pyx_v_p_ndr)); - PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_p_ndr)); - __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_p_ndr)); + __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_2 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->npar); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); + PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3); + __pyx_4 = 0; + __pyx_3 = 0; + __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = PyObject_GetIter(__pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_v_m = __pyx_2; + __pyx_5 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + __pyx_1 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_v_m = __pyx_1; + __pyx_2 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + Py_DECREF(__pyx_v_notOK); + __pyx_v_notOK = __pyx_2; + __pyx_2 = 0; + if (__Pyx_EndUnpack(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":481 */ - __pyx_2 = PyInt_AsLong(__pyx_v_stderr); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; goto __pyx_L1;} - predict(__pyx_v_p_dat,__pyx_v_m,(&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base),((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted->_base,__pyx_2); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":844 */ + __pyx_1 = PyObject_IsTrue(__pyx_v_notOK); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; goto __pyx_L1;} + if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":482 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":845 */ + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;} + Py_INCREF(__pyx_k135p); + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k135p); + __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + __Pyx_Raise(__pyx_2, 0, 0); + Py_DECREF(__pyx_2); __pyx_2 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;} + goto __pyx_L4; + } + __pyx_L4:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":848 */ + __pyx_1 = PyInt_AsLong(__pyx_v_stderr); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; goto __pyx_L1;} + predict(__pyx_v_p_dat,__pyx_v_m,(&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base),(&__pyx_v__prediction),__pyx_1); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":849 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_predicted), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6cloess_loess_predicted)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted)); + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted = ((struct __pyx_obj_6cloess_loess_predicted *)__pyx_3); + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":850 */ + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted->_base = __pyx_v__prediction; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":851 */ ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted->nest = __pyx_v_m; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":852 */ + Py_INCREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted)); + __pyx_r = ((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted); + goto __pyx_L0; + __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; - Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); __Pyx_AddTraceback("cloess.loess.predict"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_p_ndr); + Py_DECREF(__pyx_v_notOK); Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_newdata); Py_DECREF(__pyx_v_stderr); return __pyx_r; } +static void __pyx_f_6cloess_5loess___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_f_6cloess_5loess___dealloc__(PyObject *__pyx_v_self) { + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":855 */ + loess_free_mem((&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base)); + + Py_DECREF(__pyx_v_self); +} + static __Pyx_InternTabEntry __pyx_intern_tab[] = { + {&__pyx_n_C, "C"}, {&__pyx_n_False, "False"}, - {&__pyx_n_NPY_LONG, "NPY_LONG"}, + {&__pyx_n_T, "T"}, + {&__pyx_n_True, "True"}, {&__pyx_n_ValueError, "ValueError"}, + {&__pyx_n_approximate, "approximate"}, + {&__pyx_n_array, "array"}, {&__pyx_n_astype, "astype"}, {&__pyx_n_bool, "bool"}, {&__pyx_n_c_loess, "c_loess"}, {&__pyx_n_c_numpy, "c_numpy"}, {&__pyx_n_c_python, "c_python"}, {&__pyx_n_cell, "cell"}, + {&__pyx_n_copy, "copy"}, {&__pyx_n_degree, "degree"}, {&__pyx_n_df, "df"}, + {&__pyx_n_direct, "direct"}, + {&__pyx_n_divisor, "divisor"}, + {&__pyx_n_divmod, "divmod"}, {&__pyx_n_drop_square, "drop_square"}, {&__pyx_n_drop_square_flags, "drop_square_flags"}, {&__pyx_n_dtype, "dtype"}, - {&__pyx_n_empty, "empty"}, {&__pyx_n_enp, "enp"}, + {&__pyx_n_exact, "exact"}, {&__pyx_n_family, "family"}, - {&__pyx_n_float, "float"}, + {&__pyx_n_fit, "fit"}, + {&__pyx_n_fitted_residuals, "fitted_residuals"}, + {&__pyx_n_fitted_values, "fitted_values"}, {&__pyx_n_gaussian, "gaussian"}, {&__pyx_n_get, "get"}, {&__pyx_n_id, "id"}, {&__pyx_n_int, "int"}, + {&__pyx_n_interpolate, "interpolate"}, {&__pyx_n_iterations, "iterations"}, + {&__pyx_n_iteritems, "iteritems"}, {&__pyx_n_join, "join"}, {&__pyx_n_len, "len"}, - {&__pyx_n_max, "max"}, + {&__pyx_n_lower, "lower"}, + {&__pyx_n_min, "min"}, {&__pyx_n_ndim, "ndim"}, - {&__pyx_n_nest, "nest"}, {&__pyx_n_nobs, "nobs"}, {&__pyx_n_normalize, "normalize"}, {&__pyx_n_numpy, "numpy"}, {&__pyx_n_nvar, "nvar"}, + {&__pyx_n_one_delta, "one_delta"}, + {&__pyx_n_order, "order"}, {&__pyx_n_parametric, "parametric"}, {&__pyx_n_parametric_flags, "parametric_flags"}, {&__pyx_n_pw_free_mem, "pw_free_mem"}, + {&__pyx_n_r_, "r_"}, + {&__pyx_n_ravel, "ravel"}, {&__pyx_n_residual_scale, "residual_scale"}, {&__pyx_n_s, "s"}, {&__pyx_n_shape, "shape"}, {&__pyx_n_size, "size"}, {&__pyx_n_span, "span"}, {&__pyx_n_statistics, "statistics"}, + {&__pyx_n_stderr, "stderr"}, + {&__pyx_n_subok, "subok"}, {&__pyx_n_surface, "surface"}, + {&__pyx_n_symmetric, "symmetric"}, {&__pyx_n_trace_hat, "trace_hat"}, + {&__pyx_n_two_delta, "two_delta"}, + {&__pyx_n_update, "update"}, + {&__pyx_n_upper, "upper"}, + {&__pyx_n_values, "values"}, {0, 0} }; static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_k12p, __pyx_k12, sizeof(__pyx_k12)}, - {&__pyx_k18p, __pyx_k18, sizeof(__pyx_k18)}, - {&__pyx_k19p, __pyx_k19, sizeof(__pyx_k19)}, - {&__pyx_k20p, __pyx_k20, sizeof(__pyx_k20)}, - {&__pyx_k21p, __pyx_k21, sizeof(__pyx_k21)}, - {&__pyx_k22p, __pyx_k22, sizeof(__pyx_k22)}, - {&__pyx_k23p, __pyx_k23, sizeof(__pyx_k23)}, - {&__pyx_k24p, __pyx_k24, sizeof(__pyx_k24)}, - {&__pyx_k31p, __pyx_k31, sizeof(__pyx_k31)}, - {&__pyx_k32p, __pyx_k32, sizeof(__pyx_k32)}, - {&__pyx_k33p, __pyx_k33, sizeof(__pyx_k33)}, - {&__pyx_k34p, __pyx_k34, sizeof(__pyx_k34)}, - {&__pyx_k35p, __pyx_k35, sizeof(__pyx_k35)}, - {&__pyx_k36p, __pyx_k36, sizeof(__pyx_k36)}, - {&__pyx_k37p, __pyx_k37, sizeof(__pyx_k37)}, {&__pyx_k38p, __pyx_k38, sizeof(__pyx_k38)}, - {&__pyx_k39p, __pyx_k39, sizeof(__pyx_k39)}, - {&__pyx_k40p, __pyx_k40, sizeof(__pyx_k40)}, {&__pyx_k41p, __pyx_k41, sizeof(__pyx_k41)}, - {&__pyx_k43p, __pyx_k43, sizeof(__pyx_k43)}, - {&__pyx_k44p, __pyx_k44, sizeof(__pyx_k44)}, + {&__pyx_k42p, __pyx_k42, sizeof(__pyx_k42)}, + {&__pyx_k45p, __pyx_k45, sizeof(__pyx_k45)}, + {&__pyx_k48p, __pyx_k48, sizeof(__pyx_k48)}, + {&__pyx_k49p, __pyx_k49, sizeof(__pyx_k49)}, + {&__pyx_k50p, __pyx_k50, sizeof(__pyx_k50)}, + {&__pyx_k56p, __pyx_k56, sizeof(__pyx_k56)}, + {&__pyx_k57p, __pyx_k57, sizeof(__pyx_k57)}, + {&__pyx_k58p, __pyx_k58, sizeof(__pyx_k58)}, + {&__pyx_k59p, __pyx_k59, sizeof(__pyx_k59)}, + {&__pyx_k60p, __pyx_k60, sizeof(__pyx_k60)}, + {&__pyx_k61p, __pyx_k61, sizeof(__pyx_k61)}, + {&__pyx_k62p, __pyx_k62, sizeof(__pyx_k62)}, + {&__pyx_k63p, __pyx_k63, sizeof(__pyx_k63)}, + {&__pyx_k64p, __pyx_k64, sizeof(__pyx_k64)}, + {&__pyx_k67p, __pyx_k67, sizeof(__pyx_k67)}, + {&__pyx_k80p, __pyx_k80, sizeof(__pyx_k80)}, + {&__pyx_k81p, __pyx_k81, sizeof(__pyx_k81)}, + {&__pyx_k82p, __pyx_k82, sizeof(__pyx_k82)}, + {&__pyx_k83p, __pyx_k83, sizeof(__pyx_k83)}, + {&__pyx_k84p, __pyx_k84, sizeof(__pyx_k84)}, + {&__pyx_k85p, __pyx_k85, sizeof(__pyx_k85)}, + {&__pyx_k86p, __pyx_k86, sizeof(__pyx_k86)}, + {&__pyx_k87p, __pyx_k87, sizeof(__pyx_k87)}, + {&__pyx_k88p, __pyx_k88, sizeof(__pyx_k88)}, + {&__pyx_k89p, __pyx_k89, sizeof(__pyx_k89)}, + {&__pyx_k90p, __pyx_k90, sizeof(__pyx_k90)}, + {&__pyx_k91p, __pyx_k91, sizeof(__pyx_k91)}, + {&__pyx_k92p, __pyx_k92, sizeof(__pyx_k92)}, + {&__pyx_k93p, __pyx_k93, sizeof(__pyx_k93)}, + {&__pyx_k94p, __pyx_k94, sizeof(__pyx_k94)}, + {&__pyx_k95p, __pyx_k95, sizeof(__pyx_k95)}, + {&__pyx_k96p, __pyx_k96, sizeof(__pyx_k96)}, + {&__pyx_k97p, __pyx_k97, sizeof(__pyx_k97)}, + {&__pyx_k98p, __pyx_k98, sizeof(__pyx_k98)}, + {&__pyx_k99p, __pyx_k99, sizeof(__pyx_k99)}, + {&__pyx_k100p, __pyx_k100, sizeof(__pyx_k100)}, + {&__pyx_k101p, __pyx_k101, sizeof(__pyx_k101)}, + {&__pyx_k102p, __pyx_k102, sizeof(__pyx_k102)}, + {&__pyx_k103p, __pyx_k103, sizeof(__pyx_k103)}, + {&__pyx_k104p, __pyx_k104, sizeof(__pyx_k104)}, + {&__pyx_k113p, __pyx_k113, sizeof(__pyx_k113)}, + {&__pyx_k125p, __pyx_k125, sizeof(__pyx_k125)}, + {&__pyx_k126p, __pyx_k126, sizeof(__pyx_k126)}, + {&__pyx_k128p, __pyx_k128, sizeof(__pyx_k128)}, + {&__pyx_k129p, __pyx_k129, sizeof(__pyx_k129)}, + {&__pyx_k134p, __pyx_k134, sizeof(__pyx_k134)}, + {&__pyx_k135p, __pyx_k135, sizeof(__pyx_k135)}, {0, 0, 0} }; @@ -2946,8 +3917,8 @@ return __pyx_f_6cloess_12loess_inputs_4nobs___get__(o); } -static PyObject *__pyx_getprop_6cloess_12loess_inputs_nvar(PyObject *o, void *x) { - return __pyx_f_6cloess_12loess_inputs_4nvar___get__(o); +static PyObject *__pyx_getprop_6cloess_12loess_inputs_npar(PyObject *o, void *x) { + return __pyx_f_6cloess_12loess_inputs_4npar___get__(o); } static struct PyMethodDef __pyx_methods_6cloess_loess_inputs[] = { @@ -2959,7 +3930,7 @@ {"y", __pyx_getprop_6cloess_12loess_inputs_y, 0, 0, 0}, {"weights", __pyx_getprop_6cloess_12loess_inputs_weights, __pyx_setprop_6cloess_12loess_inputs_weights, __pyx_k1, 0}, {"nobs", __pyx_getprop_6cloess_12loess_inputs_nobs, 0, __pyx_k2, 0}, - {"nvar", __pyx_getprop_6cloess_12loess_inputs_nvar, 0, __pyx_k3, 0}, + {"npar", __pyx_getprop_6cloess_12loess_inputs_npar, 0, __pyx_k3, 0}, {0, 0, 0, 0, 0} }; @@ -3167,16 +4138,16 @@ } static struct PyMethodDef __pyx_methods_6cloess_loess_control[] = { - {"update", (PyCFunction)__pyx_f_6cloess_13loess_control_update, METH_VARARGS|METH_KEYWORDS, 0}, + {"update", (PyCFunction)__pyx_f_6cloess_13loess_control_update, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6cloess_13loess_control_update}, {0, 0, 0, 0} }; static struct PyGetSetDef __pyx_getsets_6cloess_loess_control[] = { - {"surface", __pyx_getprop_6cloess_13loess_control_surface, __pyx_setprop_6cloess_13loess_control_surface, 0, 0}, - {"statistics", __pyx_getprop_6cloess_13loess_control_statistics, __pyx_setprop_6cloess_13loess_control_statistics, 0, 0}, - {"trace_hat", __pyx_getprop_6cloess_13loess_control_trace_hat, __pyx_setprop_6cloess_13loess_control_trace_hat, 0, 0}, - {"iterations", __pyx_getprop_6cloess_13loess_control_iterations, __pyx_setprop_6cloess_13loess_control_iterations, 0, 0}, - {"cell", __pyx_getprop_6cloess_13loess_control_cell, __pyx_setprop_6cloess_13loess_control_cell, 0, 0}, + {"surface", __pyx_getprop_6cloess_13loess_control_surface, __pyx_setprop_6cloess_13loess_control_surface, __pyx_k4, 0}, + {"statistics", __pyx_getprop_6cloess_13loess_control_statistics, __pyx_setprop_6cloess_13loess_control_statistics, __pyx_k5, 0}, + {"trace_hat", __pyx_getprop_6cloess_13loess_control_trace_hat, __pyx_setprop_6cloess_13loess_control_trace_hat, __pyx_k6, 0}, + {"iterations", __pyx_getprop_6cloess_13loess_control_iterations, __pyx_setprop_6cloess_13loess_control_iterations, __pyx_k7, 0}, + {"cell", __pyx_getprop_6cloess_13loess_control_cell, __pyx_setprop_6cloess_13loess_control_cell, __pyx_k8, 0}, {0, 0, 0, 0, 0} }; @@ -3468,6 +4439,16 @@ return __pyx_f_6cloess_11loess_model_6degree___get__(o); } +static int __pyx_setprop_6cloess_11loess_model_degree(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6cloess_11loess_model_6degree___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + static PyObject *__pyx_getprop_6cloess_11loess_model_normalize(PyObject *o, void *x) { return __pyx_f_6cloess_11loess_model_9normalize___get__(o); } @@ -3486,6 +4467,16 @@ return __pyx_f_6cloess_11loess_model_6family___get__(o); } +static int __pyx_setprop_6cloess_11loess_model_family(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6cloess_11loess_model_6family___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + static PyObject *__pyx_getprop_6cloess_11loess_model_parametric_flags(PyObject *o, void *x) { return __pyx_f_6cloess_11loess_model_16parametric_flags___get__(o); } @@ -3520,12 +4511,12 @@ }; static struct PyGetSetDef __pyx_getsets_6cloess_loess_model[] = { - {"span", __pyx_getprop_6cloess_11loess_model_span, __pyx_setprop_6cloess_11loess_model_span, 0, 0}, - {"degree", __pyx_getprop_6cloess_11loess_model_degree, 0, 0, 0}, - {"normalize", __pyx_getprop_6cloess_11loess_model_normalize, __pyx_setprop_6cloess_11loess_model_normalize, __pyx_k4, 0}, - {"family", __pyx_getprop_6cloess_11loess_model_family, 0, 0, 0}, - {"parametric_flags", __pyx_getprop_6cloess_11loess_model_parametric_flags, __pyx_setprop_6cloess_11loess_model_parametric_flags, 0, 0}, - {"drop_square_flags", __pyx_getprop_6cloess_11loess_model_drop_square_flags, __pyx_setprop_6cloess_11loess_model_drop_square_flags, 0, 0}, + {"span", __pyx_getprop_6cloess_11loess_model_span, __pyx_setprop_6cloess_11loess_model_span, __pyx_k9, 0}, + {"degree", __pyx_getprop_6cloess_11loess_model_degree, __pyx_setprop_6cloess_11loess_model_degree, __pyx_k10, 0}, + {"normalize", __pyx_getprop_6cloess_11loess_model_normalize, __pyx_setprop_6cloess_11loess_model_normalize, __pyx_k11, 0}, + {"family", __pyx_getprop_6cloess_11loess_model_family, __pyx_setprop_6cloess_11loess_model_family, __pyx_k12, 0}, + {"parametric_flags", __pyx_getprop_6cloess_11loess_model_parametric_flags, __pyx_setprop_6cloess_11loess_model_parametric_flags, __pyx_k13, 0}, + {"drop_square_flags", __pyx_getprop_6cloess_11loess_model_drop_square_flags, __pyx_setprop_6cloess_11loess_model_drop_square_flags, __pyx_k14, 0}, {0, 0, 0, 0, 0} }; @@ -3710,18 +4701,23 @@ {0, 0, 0, 0} }; +static struct PyMemberDef __pyx_members_6cloess_loess_outputs[] = { + {"activated", T_INT, offsetof(struct __pyx_obj_6cloess_loess_outputs, activated), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + static struct PyGetSetDef __pyx_getsets_6cloess_loess_outputs[] = { - {"fitted_values", __pyx_getprop_6cloess_13loess_outputs_fitted_values, 0, 0, 0}, - {"fitted_residuals", __pyx_getprop_6cloess_13loess_outputs_fitted_residuals, 0, 0, 0}, - {"pseudovalues", __pyx_getprop_6cloess_13loess_outputs_pseudovalues, 0, 0, 0}, - {"diagonal", __pyx_getprop_6cloess_13loess_outputs_diagonal, 0, 0, 0}, - {"robust", __pyx_getprop_6cloess_13loess_outputs_robust, 0, 0, 0}, - {"divisor", __pyx_getprop_6cloess_13loess_outputs_divisor, 0, 0, 0}, - {"enp", __pyx_getprop_6cloess_13loess_outputs_enp, 0, __pyx_k5, 0}, - {"s", __pyx_getprop_6cloess_13loess_outputs_s, 0, 0, 0}, - {"one_delta", __pyx_getprop_6cloess_13loess_outputs_one_delta, 0, 0, 0}, - {"two_delta", __pyx_getprop_6cloess_13loess_outputs_two_delta, 0, 0, 0}, - {"trace_hat", __pyx_getprop_6cloess_13loess_outputs_trace_hat, 0, 0, 0}, + {"fitted_values", __pyx_getprop_6cloess_13loess_outputs_fitted_values, 0, __pyx_k15, 0}, + {"fitted_residuals", __pyx_getprop_6cloess_13loess_outputs_fitted_residuals, 0, __pyx_k16, 0}, + {"pseudovalues", __pyx_getprop_6cloess_13loess_outputs_pseudovalues, 0, __pyx_k17, 0}, + {"diagonal", __pyx_getprop_6cloess_13loess_outputs_diagonal, 0, __pyx_k18, 0}, + {"robust", __pyx_getprop_6cloess_13loess_outputs_robust, 0, __pyx_k19, 0}, + {"divisor", __pyx_getprop_6cloess_13loess_outputs_divisor, 0, __pyx_k20, 0}, + {"enp", __pyx_getprop_6cloess_13loess_outputs_enp, 0, __pyx_k21, 0}, + {"s", __pyx_getprop_6cloess_13loess_outputs_s, 0, __pyx_k22, 0}, + {"one_delta", __pyx_getprop_6cloess_13loess_outputs_one_delta, 0, __pyx_k23, 0}, + {"two_delta", __pyx_getprop_6cloess_13loess_outputs_two_delta, 0, __pyx_k24, 0}, + {"trace_hat", __pyx_getprop_6cloess_13loess_outputs_trace_hat, 0, __pyx_k25, 0}, {0, 0, 0, 0, 0} }; @@ -3809,7 +4805,7 @@ &__pyx_tp_as_mapping_loess_outputs, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ - 0, /*tp_str*/ + __pyx_f_6cloess_13loess_outputs___str__, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_loess_outputs, /*tp_as_buffer*/ @@ -3822,7 +4818,7 @@ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6cloess_loess_outputs, /*tp_methods*/ - 0, /*tp_members*/ + __pyx_members_6cloess_loess_outputs, /*tp_members*/ __pyx_getsets_6cloess_loess_outputs, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ @@ -4002,20 +4998,20 @@ 0, /*tp_weaklist*/ }; -static PyObject *__pyx_tp_new_6cloess_confidence_interval(PyTypeObject *t, PyObject *a, PyObject *k) { +static PyObject *__pyx_tp_new_6cloess_conf_intervals(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); - struct __pyx_obj_6cloess_confidence_interval *p = (struct __pyx_obj_6cloess_confidence_interval *)o; + struct __pyx_obj_6cloess_conf_intervals *p = (struct __pyx_obj_6cloess_conf_intervals *)o; p->nest = Py_None; Py_INCREF(Py_None); return o; } -static void __pyx_tp_dealloc_6cloess_confidence_interval(PyObject *o) { - struct __pyx_obj_6cloess_confidence_interval *p = (struct __pyx_obj_6cloess_confidence_interval *)o; +static void __pyx_tp_dealloc_6cloess_conf_intervals(PyObject *o) { + struct __pyx_obj_6cloess_conf_intervals *p = (struct __pyx_obj_6cloess_conf_intervals *)o; { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++o->ob_refcnt; - __pyx_f_6cloess_19confidence_interval___dealloc__(o); + __pyx_f_6cloess_14conf_intervals___dealloc__(o); if (PyErr_Occurred()) PyErr_WriteUnraisable(o); --o->ob_refcnt; PyErr_Restore(etype, eval, etb); @@ -4024,46 +5020,46 @@ (*o->ob_type->tp_free)(o); } -static int __pyx_tp_traverse_6cloess_confidence_interval(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_6cloess_conf_intervals(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_6cloess_confidence_interval *p = (struct __pyx_obj_6cloess_confidence_interval *)o; + struct __pyx_obj_6cloess_conf_intervals *p = (struct __pyx_obj_6cloess_conf_intervals *)o; if (p->nest) { e = (*v)(p->nest, a); if (e) return e; } return 0; } -static int __pyx_tp_clear_6cloess_confidence_interval(PyObject *o) { - struct __pyx_obj_6cloess_confidence_interval *p = (struct __pyx_obj_6cloess_confidence_interval *)o; +static int __pyx_tp_clear_6cloess_conf_intervals(PyObject *o) { + struct __pyx_obj_6cloess_conf_intervals *p = (struct __pyx_obj_6cloess_conf_intervals *)o; Py_XDECREF(p->nest); p->nest = Py_None; Py_INCREF(Py_None); return 0; } -static PyObject *__pyx_getprop_6cloess_19confidence_interval_fit(PyObject *o, void *x) { - return __pyx_f_6cloess_19confidence_interval_3fit___get__(o); +static PyObject *__pyx_getprop_6cloess_14conf_intervals_fit(PyObject *o, void *x) { + return __pyx_f_6cloess_14conf_intervals_3fit___get__(o); } -static PyObject *__pyx_getprop_6cloess_19confidence_interval_upper(PyObject *o, void *x) { - return __pyx_f_6cloess_19confidence_interval_5upper___get__(o); +static PyObject *__pyx_getprop_6cloess_14conf_intervals_upper(PyObject *o, void *x) { + return __pyx_f_6cloess_14conf_intervals_5upper___get__(o); } -static PyObject *__pyx_getprop_6cloess_19confidence_interval_lower(PyObject *o, void *x) { - return __pyx_f_6cloess_19confidence_interval_5lower___get__(o); +static PyObject *__pyx_getprop_6cloess_14conf_intervals_lower(PyObject *o, void *x) { + return __pyx_f_6cloess_14conf_intervals_5lower___get__(o); } -static struct PyMethodDef __pyx_methods_6cloess_confidence_interval[] = { +static struct PyMethodDef __pyx_methods_6cloess_conf_intervals[] = { {0, 0, 0, 0} }; -static struct PyGetSetDef __pyx_getsets_6cloess_confidence_interval[] = { - {"fit", __pyx_getprop_6cloess_19confidence_interval_fit, 0, 0, 0}, - {"upper", __pyx_getprop_6cloess_19confidence_interval_upper, 0, 0, 0}, - {"lower", __pyx_getprop_6cloess_19confidence_interval_lower, 0, 0, 0}, +static struct PyGetSetDef __pyx_getsets_6cloess_conf_intervals[] = { + {"fit", __pyx_getprop_6cloess_14conf_intervals_fit, 0, __pyx_k26, 0}, + {"upper", __pyx_getprop_6cloess_14conf_intervals_upper, 0, __pyx_k27, 0}, + {"lower", __pyx_getprop_6cloess_14conf_intervals_lower, 0, __pyx_k28, 0}, {0, 0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_confidence_interval = { +static PyNumberMethods __pyx_tp_as_number_conf_intervals = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -4104,7 +5100,7 @@ 0, /*nb_inplace_true_divide*/ }; -static PySequenceMethods __pyx_tp_as_sequence_confidence_interval = { +static PySequenceMethods __pyx_tp_as_sequence_conf_intervals = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -4117,51 +5113,51 @@ 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_confidence_interval = { +static PyMappingMethods __pyx_tp_as_mapping_conf_intervals = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_confidence_interval = { +static PyBufferProcs __pyx_tp_as_buffer_conf_intervals = { 0, /*bf_getreadbuffer*/ 0, /*bf_getwritebuffer*/ 0, /*bf_getsegcount*/ 0, /*bf_getcharbuffer*/ }; -PyTypeObject __pyx_type_6cloess_confidence_interval = { +PyTypeObject __pyx_type_6cloess_conf_intervals = { PyObject_HEAD_INIT(0) 0, /*ob_size*/ - "cloess.confidence_interval", /*tp_name*/ - sizeof(struct __pyx_obj_6cloess_confidence_interval), /*tp_basicsize*/ + "cloess.conf_intervals", /*tp_name*/ + sizeof(struct __pyx_obj_6cloess_conf_intervals), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6cloess_confidence_interval, /*tp_dealloc*/ + __pyx_tp_dealloc_6cloess_conf_intervals, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ - &__pyx_tp_as_number_confidence_interval, /*tp_as_number*/ - &__pyx_tp_as_sequence_confidence_interval, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_confidence_interval, /*tp_as_mapping*/ + &__pyx_tp_as_number_conf_intervals, /*tp_as_number*/ + &__pyx_tp_as_sequence_conf_intervals, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_conf_intervals, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ - 0, /*tp_str*/ + __pyx_f_6cloess_14conf_intervals___str__, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_confidence_interval, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_conf_intervals, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_6cloess_confidence_interval, /*tp_traverse*/ - __pyx_tp_clear_6cloess_confidence_interval, /*tp_clear*/ + __pyx_tp_traverse_6cloess_conf_intervals, /*tp_traverse*/ + __pyx_tp_clear_6cloess_conf_intervals, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_6cloess_confidence_interval, /*tp_methods*/ + __pyx_methods_6cloess_conf_intervals, /*tp_methods*/ 0, /*tp_members*/ - __pyx_getsets_6cloess_confidence_interval, /*tp_getset*/ + __pyx_getsets_6cloess_conf_intervals, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -4169,7 +5165,7 @@ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_6cloess_confidence_interval, /*tp_new*/ + __pyx_tp_new_6cloess_conf_intervals, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -4182,7 +5178,7 @@ static PyObject *__pyx_tp_new_6cloess_loess_predicted(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); struct __pyx_obj_6cloess_loess_predicted *p = (struct __pyx_obj_6cloess_loess_predicted *)o; - p->conf_interval = ((struct __pyx_obj_6cloess_confidence_interval *)Py_None); Py_INCREF(Py_None); + p->confidence_intervals = ((struct __pyx_obj_6cloess_conf_intervals *)Py_None); Py_INCREF(Py_None); return o; } @@ -4197,32 +5193,32 @@ --o->ob_refcnt; PyErr_Restore(etype, eval, etb); } - Py_XDECREF(((PyObject *)p->conf_interval)); + Py_XDECREF(((PyObject *)p->confidence_intervals)); (*o->ob_type->tp_free)(o); } static int __pyx_tp_traverse_6cloess_loess_predicted(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_6cloess_loess_predicted *p = (struct __pyx_obj_6cloess_loess_predicted *)o; - if (p->conf_interval) { - e = (*v)(((PyObject*)p->conf_interval), a); if (e) return e; + if (p->confidence_intervals) { + e = (*v)(((PyObject*)p->confidence_intervals), a); if (e) return e; } return 0; } static int __pyx_tp_clear_6cloess_loess_predicted(PyObject *o) { struct __pyx_obj_6cloess_loess_predicted *p = (struct __pyx_obj_6cloess_loess_predicted *)o; - Py_XDECREF(((PyObject *)p->conf_interval)); - p->conf_interval = ((struct __pyx_obj_6cloess_confidence_interval *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->confidence_intervals)); + p->confidence_intervals = ((struct __pyx_obj_6cloess_conf_intervals *)Py_None); Py_INCREF(Py_None); return 0; } -static PyObject *__pyx_getprop_6cloess_15loess_predicted_predicted(PyObject *o, void *x) { - return __pyx_f_6cloess_15loess_predicted_9predicted___get__(o); +static PyObject *__pyx_getprop_6cloess_15loess_predicted_values(PyObject *o, void *x) { + return __pyx_f_6cloess_15loess_predicted_6values___get__(o); } -static PyObject *__pyx_getprop_6cloess_15loess_predicted_predicted_stderr(PyObject *o, void *x) { - return __pyx_f_6cloess_15loess_predicted_16predicted_stderr___get__(o); +static PyObject *__pyx_getprop_6cloess_15loess_predicted_stderr(PyObject *o, void *x) { + return __pyx_f_6cloess_15loess_predicted_6stderr___get__(o); } static PyObject *__pyx_getprop_6cloess_15loess_predicted_residual_scale(PyObject *o, void *x) { @@ -4238,11 +5234,17 @@ {0, 0, 0, 0} }; +static struct PyMemberDef __pyx_members_6cloess_loess_predicted[] = { + {"nest", T_LONG, offsetof(struct __pyx_obj_6cloess_loess_predicted, nest), READONLY, 0}, + {"confidence_intervals", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess_predicted, confidence_intervals), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + static struct PyGetSetDef __pyx_getsets_6cloess_loess_predicted[] = { - {"predicted", __pyx_getprop_6cloess_15loess_predicted_predicted, 0, 0, 0}, - {"predicted_stderr", __pyx_getprop_6cloess_15loess_predicted_predicted_stderr, 0, 0, 0}, - {"residual_scale", __pyx_getprop_6cloess_15loess_predicted_residual_scale, 0, 0, 0}, - {"df", __pyx_getprop_6cloess_15loess_predicted_df, 0, 0, 0}, + {"values", __pyx_getprop_6cloess_15loess_predicted_values, 0, __pyx_k29, 0}, + {"stderr", __pyx_getprop_6cloess_15loess_predicted_stderr, 0, __pyx_k30, 0}, + {"residual_scale", __pyx_getprop_6cloess_15loess_predicted_residual_scale, 0, __pyx_k31, 0}, + {"df", __pyx_getprop_6cloess_15loess_predicted_df, 0, __pyx_k32, 0}, {0, 0, 0, 0, 0} }; @@ -4330,7 +5332,7 @@ &__pyx_tp_as_mapping_loess_predicted, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ - 0, /*tp_str*/ + __pyx_f_6cloess_15loess_predicted___str__, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_loess_predicted, /*tp_as_buffer*/ @@ -4343,7 +5345,7 @@ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6cloess_loess_predicted, /*tp_methods*/ - 0, /*tp_members*/ + __pyx_members_6cloess_loess_predicted, /*tp_members*/ __pyx_getsets_6cloess_loess_predicted, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ @@ -4376,6 +5378,15 @@ static void __pyx_tp_dealloc_6cloess_loess(PyObject *o) { struct __pyx_obj_6cloess_loess *p = (struct __pyx_obj_6cloess_loess *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++o->ob_refcnt; + __pyx_f_6cloess_5loess___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --o->ob_refcnt; + PyErr_Restore(etype, eval, etb); + } Py_XDECREF(((PyObject *)p->inputs)); Py_XDECREF(((PyObject *)p->model)); Py_XDECREF(((PyObject *)p->control)); @@ -4440,6 +5451,8 @@ {"kd_tree", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess, kd_tree), READONLY, 0}, {"outputs", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess, outputs), READONLY, 0}, {"predicted", T_OBJECT, offsetof(struct __pyx_obj_6cloess_loess, predicted), READONLY, 0}, + {"nobs", T_LONG, offsetof(struct __pyx_obj_6cloess_loess, nobs), 0, 0}, + {"npar", T_LONG, offsetof(struct __pyx_obj_6cloess_loess, npar), 0, 0}, {0, 0, 0, 0, 0} }; @@ -4577,62 +5590,67 @@ if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; - if (PyType_Ready(&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_inputs", (PyObject *)&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_inputs", (PyObject *)&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; goto __pyx_L1;} __pyx_ptype_6cloess_loess_inputs = &__pyx_type_6cloess_loess_inputs; - if (PyType_Ready(&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_control", (PyObject *)&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_control", (PyObject *)&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} __pyx_ptype_6cloess_loess_control = &__pyx_type_6cloess_loess_control; - if (PyType_Ready(&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_kd_tree", (PyObject *)&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_kd_tree", (PyObject *)&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;} __pyx_ptype_6cloess_loess_kd_tree = &__pyx_type_6cloess_loess_kd_tree; - if (PyType_Ready(&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_model", (PyObject *)&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_model", (PyObject *)&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; goto __pyx_L1;} __pyx_ptype_6cloess_loess_model = &__pyx_type_6cloess_loess_model; - if (PyType_Ready(&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_outputs", (PyObject *)&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_outputs", (PyObject *)&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; goto __pyx_L1;} __pyx_ptype_6cloess_loess_outputs = &__pyx_type_6cloess_loess_outputs; - if (PyType_Ready(&__pyx_type_6cloess_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_anova", (PyObject *)&__pyx_type_6cloess_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_anova", (PyObject *)&__pyx_type_6cloess_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;} __pyx_ptype_6cloess_loess_anova = &__pyx_type_6cloess_loess_anova; - __pyx_type_6cloess_confidence_interval.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6cloess_confidence_interval) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "confidence_interval", (PyObject *)&__pyx_type_6cloess_confidence_interval) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; goto __pyx_L1;} - __pyx_ptype_6cloess_confidence_interval = &__pyx_type_6cloess_confidence_interval; + __pyx_type_6cloess_conf_intervals.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_6cloess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "conf_intervals", (PyObject *)&__pyx_type_6cloess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;} + __pyx_ptype_6cloess_conf_intervals = &__pyx_type_6cloess_conf_intervals; __pyx_type_6cloess_loess_predicted.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6cloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_predicted", (PyObject *)&__pyx_type_6cloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_predicted", (PyObject *)&__pyx_type_6cloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; goto __pyx_L1;} __pyx_ptype_6cloess_loess_predicted = &__pyx_type_6cloess_loess_predicted; __pyx_type_6cloess_loess.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess", (PyObject *)&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess", (PyObject *)&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; goto __pyx_L1;} __pyx_ptype_6cloess_loess = &__pyx_type_6cloess_loess; __pyx_ptype_7c_numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (!__pyx_ptype_7c_numpy_dtype) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; goto __pyx_L1;} __pyx_ptype_7c_numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (!__pyx_ptype_7c_numpy_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 81; goto __pyx_L1;} __pyx_ptype_7c_numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject)); if (!__pyx_ptype_7c_numpy_flatiter) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 90; goto __pyx_L1;} __pyx_ptype_7c_numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject)); if (!__pyx_ptype_7c_numpy_broadcast) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; goto __pyx_L1;} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":7 */ - __pyx_1 = __Pyx_Import(__pyx_n_numpy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} - if (PyObject_SetAttr(__pyx_m, __pyx_n_numpy, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":8 */ + __pyx_1 = __Pyx_Import(__pyx_n_numpy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_numpy, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":14 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":15 */ import_array(); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":402 */ - __pyx_1 = PyFloat_FromDouble(0.95); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; goto __pyx_L1;} - __pyx_k7 = __pyx_1; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":48 */ + __pyx_k34; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":710 */ + __pyx_1 = PyFloat_FromDouble(0.95); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;} + __pyx_k35 = __pyx_1; __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":423 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":753 */ Py_INCREF(Py_None); - __pyx_k8 = Py_None; + __pyx_k36 = Py_None; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":466 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; goto __pyx_L1;} - __pyx_k9 = __pyx_2; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":821 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;} + __pyx_k37 = __pyx_2; __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":854 */ return; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -4835,6 +5853,32 @@ return; } +static void __Pyx_UnpackError(void) { + PyErr_SetString(PyExc_ValueError, "unpack sequence of wrong size"); +} + +static PyObject *__Pyx_UnpackItem(PyObject *iter) { + PyObject *item; + if (!(item = PyIter_Next(iter))) { + if (!PyErr_Occurred()) + __Pyx_UnpackError(); + } + return item; +} + +static int __Pyx_EndUnpack(PyObject *iter) { + PyObject *item; + if ((item = PyIter_Next(iter))) { + Py_DECREF(item); + __Pyx_UnpackError(); + return -1; + } + else if (!PyErr_Occurred()) + return 0; + else + return -1; +} + static PyObject *__Pyx_GetStdout(void) { PyObject *f = PySys_GetObject("stdout"); if (!f) { Modified: trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx 2007-03-14 16:52:59 UTC (rev 2848) +++ trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx 2007-03-16 20:42:51 UTC (rev 2849) @@ -3,7 +3,8 @@ cimport c_numpy from c_numpy cimport ndarray, npy_intp, \ PyArray_SIZE, PyArray_EMPTY, PyArray_FROMANY, \ - NPY_INT, NPY_DOUBLE, NPY_OWNDATA, NPY_ALIGNED, NPY_FORTRAN + NPY_INT, NPY_DOUBLE, NPY_OWNDATA, NPY_ALIGNED, NPY_FORTRAN, \ + PyArray_SimpleNewFromData import numpy #narray = _N.array @@ -16,29 +17,151 @@ cimport c_loess -cdef floatarray_from_data(rows, cols, double *data): +cdef floatarray_from_data(int rows, int cols, double *data): cdef ndarray a_ndr - cdef double *a_dat - a_ndr = numpy.empty((rows*cols,), dtype=numpy.float) - a_dat = a_ndr.data - for i from 0 <= i < a_ndr.size: - a_dat[i] = data[i] + cdef npy_intp size + size = rows*cols + a_ndr = PyArray_SimpleNewFromData(1, &size, NPY_DOUBLE, data) +# a_ndr = numpy.empty((rows*cols,), dtype=numpy.float) +# a_dat = a_ndr.data +# for i from 0 <= i < a_ndr.size: +# a_dat[i] = data[i] if cols > 1: a_ndr.shape = (rows, cols) return a_ndr -cdef boolarray_from_data(rows, cols, int *data): +cdef boolarray_from_data(int rows, int cols, int *data): cdef ndarray a_ndr - cdef int *a_dat - a_ndr = numpy.empty((rows*cols,), dtype=numpy.int) - a_dat = a_ndr.data - for i from 0 <= i < a_ndr.size: - a_dat[i] = data[i] + cdef npy_intp size + size = rows*cols +# cdef int *a_dat +# a_ndr = numpy.empty((rows*cols,), dtype=numpy.int) + a_ndr = PyArray_SimpleNewFromData(1, &size, NPY_DOUBLE, data) +# a_dat = a_ndr.data +# for i from 0 <= i < a_ndr.size: +# a_dat[i] = data[i] if cols > 1: a_ndr.shape = (rows, cols) return a_ndr.astype(numpy.bool) - + +""" +:Keywords: + x : ndarray + A (n,p) ndarray of independent variables, with n the number of observations + and p the number of variables. + y : ndarray + A (n,) ndarray of observations + weights : ndarray + A (n,) ndarray of weights to be given to individual observations in the + sum of squared residuals that forms the local fitting criterion. If not + None, the weights should be non negative. If the different observations + have non-equal variances, the weights should be inversely proportional + to the variances. + By default, an unweighted fit is carried out (all the weights are one). + surface : string ["interpolate"] + Determines whether the fitted surface is computed directly at all points + ("direct") or whether an interpolation method is used ("interpolate"). + The default ("interpolate") is what most users should use unless special + circumstances warrant. + statistics : string ["approximate"] + Determines whether the statistical quantities are computed exactly + ("exact") or approximately ("approximate"). "exact" should only be used + for testing the approximation in statistical development and is not meant + for routine usage because computation time can be horrendous. + trace_hat : string ["wait.to.decide"] + Determines how the trace of the hat matrix should be computed. The hat + matrix is used in the computation of the statistical quantities. + If "exact", an exact computation is done; this could be slow when the + number of observations n becomes large. If "wait.to.decide" is selected, + then a default is "exact" for n < 500 and "approximate" otherwise. + This option is only useful when the fitted surface is interpolated. If + surface is "exact", an exact computation is always done for the trace. + Setting trace_hat to "approximate" for large dataset will substantially + reduce the computation time. + iterations : integer + Number of iterations of the robust fitting method. If the family is + "gaussian", the number of iterations is set to 0. + cell : integer + Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span), + where n is the number of observations, and span the smoothing parameter. + Then, a cell is further divided if the number of observations within it + is greater than or equal to k. This option is only used if the surface + is interpolated. + span : float [0.75] + Smoothing factor, as a fraction of the number of points to take into + account. + degree : integer [2] + Overall degree of locally-fitted polynomial. 1 is locally-linear + fitting and 2 is locally-quadratic fitting. Degree should be 2 at most. + normalize : boolean [True] + Determines whether the independent variables should be normalized. + If True, the normalization is performed by setting the 10% trimmed + standard deviation to one. If False, no normalization is carried out. + This option is only useful for more than one variable. For spatial + coordinates predictors or variables with a common scale, it should be + set to False. + family : string ["gaussian"] + Determines the assumed distribution of the errors. The values are + "gaussian" or "symmetric". If "gaussian" is selected, the fit is + performed with least-squares. If "symmetric" is selected, the fit + is performed robustly by redescending M-estimators. + parametric_flags : sequence [ [False]*p ] + Indicates which independent variables should be conditionally-parametric + (if there are two or more independent variables). The argument should + be a sequence of booleans, with the same size as the number of independent + variables, specified in the order of the predictor group ordered in x. + drop_square : sequence [ [False]* p] + When there are two or more independent variables and when a 2nd order + polynomial is used, "drop_square_flags" specifies those numeric predictors + whose squares should be dropped from the set of fitting variables. + The method of specification is the same as for parametric. + +:Outputs: + fitted_values : ndarray + The (n,) ndarray of fitted values. + fitted_residuals : ndarray + The (n,) ndarray of fitted residuals (observations - fitted values). + enp : float + Equivalent number of parameters. + s : float + Estimate of the scale of residuals. + one_delta: float + Statistical parameter used in the computation of standard errors. + two_delta : float + Statistical parameter used in the computation of standard errors. + pseudovalues : ndarray + The (n,) ndarray of adjusted values of the response when robust estimation + is used. + trace_hat : float + Trace of the operator hat matrix. + diagonal : + Diagonal of the operator hat matrix. + robust : ndarray + The (n,) ndarray of robustness weights for robust fitting. + divisor : ndarray + The (p,) array of normalization divisors for numeric predictors. + + + newdata : ndarray + The (m,p) array of independent variables where the surface must be estimated. + values : ndarray + The (m,) ndarray of loess values evaluated at newdata + stderr : ndarray + The (m,) ndarray of the estimates of the standard error on the estimated + values. + residual_scale : float + Estimate of the scale of the residuals + df : integer + Degrees of freedom of the t-distribution used to compute pointwise + confidence intervals for the evaluated surface. + nest : integer + Number of new observations. + + +""" + + #####--------------------------------------------------------------------------- #---- ---- loess model --- #####--------------------------------------------------------------------------- @@ -54,7 +177,13 @@ return floatarray_from_data(self._base.n, 1, self._base.y) #......... property weights: - "Weights" + """A (n,) ndarray of weights to be given to individual observations in the + sum of squared residuals that forms the local fitting criterion. If not + None, the weights should be non negative. If the different observations + have non-equal variances, the weights should be inversely proportional + to the variances. + By default, an unweighted fit is carried out (all the weights are one). + """ def __get__(self): return floatarray_from_data(self._base.n, 1, self._base.weights) @@ -71,7 +200,7 @@ def __get__(self): return self._base.n #......... - property nvar: + property npar: "Number of independent variables." def __get__(self): return self._base.p @@ -83,36 +212,92 @@ cdef c_loess.c_loess_control *_base #......... property surface: + """ + surface : string ["interpolate"] + Determines whether the fitted surface is computed directly at all points + ("direct") or whether an interpolation method is used ("interpolate"). + The default ("interpolate") is what most users should use unless special + circumstances warrant. + """ def __get__(self): return self._base.surface def __set__(self, surface): - self._base.surface = surface + if surface.lower() not in ('interpolate', 'direct'): + raise ValueError("Invalid value for the 'surface' argument: "+ + "should be in ('interpolate', 'direct').") + tmpx = surface.lower() + self._base.surface = tmpx #......... property statistics: + """ + statistics : string ["approximate"] + Determines whether the statistical quantities are computed exactly + ("exact") or approximately ("approximate"). "exact" should only be used + for testing the approximation in statistical development and is not meant + for routine usage because computation time can be horrendous. + """ def __get__(self): return self._base.statistics def __set__(self, statistics): - self._base.statistics = statistics + if statistics.lower() not in ('approximate', 'exact'): + raise ValueError("Invalid value for the 'statistics' argument: "\ + "should be in ('approximate', 'exact').") + tmpx = statistics.lower() + self._base.statistics = tmpx #......... property trace_hat: + """ + trace_hat : string ["wait.to.decide"] + Determines how the trace of the hat matrix should be computed. The hat + matrix is used in the computation of the statistical quantities. + If "exact", an exact computation is done; this could be slow when the + number of observations n becomes large. If "wait.to.decide" is selected, + then a default is "exact" for n < 500 and "approximate" otherwise. + This option is only useful when the fitted surface is interpolated. If + surface is "exact", an exact computation is always done for the trace. + Setting trace_hat to "approximate" for large dataset will substantially + reduce the computation time. + """ def __get__(self): return self._base.trace_hat def __set__(self, trace_hat): - self._base.trace_hat = trace_hat + if trace_hat.lower() not in ('approximate', 'exact'): + raise ValueError("Invalid value for the 'trace_hat' argument: "\ + "should be in ('approximate', 'exact').") + tmpx = trace_hat.lower() + self._base.trace_hat = tmpx #......... property iterations: + """ + iterations : integer + Number of iterations of the robust fitting method. If the family is + "gaussian", the number of iterations is set to 0. + """ def __get__(self): return self._base.iterations def __set__(self, iterations): + if iterations < 0: + raise ValueError("Invalid number of iterations: should be positive") self._base.iterations = iterations #......... property cell: + """ + cell : integer + Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span), + where n is the number of observations, and span the smoothing parameter. + Then, a cell is further divided if the number of observations within it + is greater than or equal to k. This option is only used if the surface + is interpolated. + """ def __get__(self): return self._base.cell def __set__(self, cell): + if cell <= 0: + raise ValueError("Invalid value for the cell argument: should be positive") self._base.cell = cell #......... def update(self, **cellargs): + """Updates several parameters at once.""" surface = cellargs.get('surface', None) if surface is not None: self.surface = surface @@ -179,48 +364,94 @@ cdef long npar #......... property span: + """Smoothing factor, as a fraction of the number of points to take into + account. By default, span=0.75.""" def __get__(self): return self._base.span def __set__(self, span): + if span <= 0. or span > 1.: + raise ValueError("Span should be between 0 and 1!") self._base.span = span #......... property degree: + """ + degree : integer [2] + Overall degree of locally-fitted polynomial. 1 is locally-linear + fitting and 2 is locally-quadratic fitting. Degree should be 2 at most. + """ def __get__(self): return self._base.degree + def __set__(self, degree): + if degree < 0 or degree > 2: + raise ValueError("Degree should be between 0 and 2!") #......... property normalize: - "Normalize the variables. Only useful if more than one variable..." + """ + normalize : boolean [True] + Determines whether the independent variables should be normalized. + If True, the normalization is performed by setting the 10% trimmed + standard deviation to one. If False, no normalization is carried out. + This option is only useful for more than one variable. For spatial + coordinates predictors or variables with a common scale, it should be + set to False. + """ def __get__(self): return bool(self._base.normalize) def __set__(self, normalize): self._base.normalize = normalize #......... property family: + """ + family : string ["gaussian"] + Determines the assumed distribution of the errors. The values are + "gaussian" or "symmetric". If "gaussian" is selected, the fit is + performed with least-squares. If "symmetric" is selected, the fit + is performed robustly by redescending M-estimators. + """ def __get__(self): return self._base.family + def __set__(self, family): + if family.lower() not in ('symmetric', 'gaussian'): + raise ValueError("Invalid value for the 'family' argument: "\ + "should be in ('symmetric', 'gaussian').") + self._base.family = family #......... property parametric_flags: + """ + parametric_flags : sequence [ [False]*p ] + Indicates which independent variables should be conditionally-parametric + (if there are two or more independent variables). The argument should + be a sequence of booleans, with the same size as the number of independent + variables, specified in the order of the predictor group ordered in x. + """ def __get__(self): - return boolarray_from_data(8, 1, self._base.parametric) + return boolarray_from_data(self.npar, 1, self._base.parametric) def __set__(self, paramf): cdef ndarray p_ndr cdef long *p_dat cdef int i - p_ndr = PyArray_FROMANY(paramf, NPY_LONG, 1, 1, NPY_OWNDATA) + p_ndr = numpy.array(paramf, copy=False, subok=True, dtype=numpy.int) p_dat = p_ndr.data - for i in 0 <= i < max(8, p_ndr.size): + for i from 0 <= i < min(self.npar, p_ndr.size - 1): self._base.parametric[i] = p_dat[i] #......... property drop_square_flags: + """ + drop_square : sequence [ [False]* p] + When there are two or more independent variables and when a 2nd order + polynomial is used, "drop_square_flags" specifies those numeric predictors + whose squares should be dropped from the set of fitting variables. + The method of specification is the same as for parametric. + """ def __get__(self): - return boolarray_from_data(8, 1, self._base.drop_square) + return boolarray_from_data(self.npar, 1, self._base.drop_square) def __set__(self, drop_sq): cdef ndarray d_ndr cdef long *d_dat cdef int i - d_ndr = PyArray_FROMANY(drop_sq, NPY_LONG, 1, 1, NPY_OWNDATA) + d_ndr = numpy.array(drop_sq, copy=False, subok=True, dtype=numpy.int) d_dat = d_ndr.data - for i in 0 <= i < max(8, d_ndr.size): + for i from 0 <= i < min(self.npar, d_ndr.size - 1): self._base.drop_square[i] = d_dat[i] #........ def update(self, **modelargs): @@ -267,64 +498,104 @@ #####--------------------------------------------------------------------------- cdef class loess_outputs: cdef c_loess.c_loess_outputs *_base - cdef long nobs + cdef long nobs, npar + cdef readonly int activated #........ - property fitted_values: + property fitted_values: + """ + fitted_values : ndarray + The (n,) ndarray of fitted values. + """ def __get__(self): return floatarray_from_data(self.nobs, 1, self._base.fitted_values) #......... property fitted_residuals: + """ + fitted_residuals : ndarray + The (n,) ndarray of fitted residuals (observations - fitted values). + """ def __get__(self): return floatarray_from_data(self.nobs, 1, self._base.fitted_residuals) #......... property pseudovalues: + """ + pseudovalues : ndarray + The (n,) ndarray of adjusted values of the response when robust estimation + is used. + """ def __get__(self): return floatarray_from_data(self.nobs, 1, self._base.pseudovalues) #......... property diagonal: + """ + diagonal : + Diagonal of the operator hat matrix. + """ def __get__(self): return floatarray_from_data(self.nobs, 1, self._base.diagonal) #......... property robust: + """ + robust : ndarray + The (n,) ndarray of robustness weights for robust fitting. + """ def __get__(self): return floatarray_from_data(self.nobs, 1, self._base.robust) #......... property divisor: + "Equivalent number of parameters." def __get__(self): - return floatarray_from_data(self.nobs, 1, self._base.divisor) + return floatarray_from_data(self.nvar, 1, self._base.divisor) #......... property enp: - "Equivalent number of parameters." + """ + enp : float + Equivalent number of parameters. + """ def __get__(self): return self._base.enp #......... property s: -# "" + """ + s : float + Estimate of the scale of residuals. + """ def __get__(self): return self._base.s #......... property one_delta: -# "" + """ + one_delta: float + Statistical parameter used in the computation of standard errors. + """ def __get__(self): - return self._base.one_delta + return self._base.one_delta #......... property two_delta: -# "" + """ + two_delta : float + Statistical parameter used in the computation of standard errors. + """ def __get__(self): return self._base.two_delta #......... property trace_hat: -# "" + """ + trace_hat : float + Trace of the operator hat matrix. + """ def __get__(self): - return self._base.trace_hat -# #......... -# def __str__(self): -# strg = ["Outputs :", -# "enp : %s" % self.enp, -# "s : %s" % self.s, -# "Deltas : %s/%s" % (self.one_delta, self.two_delta), -# "Divisor : %s" % self.divisor,] -# return '\n'.join(strg) + return self._base.trace_hat # "" + #......... + def __str__(self): + strg = ["Outputs................", + "Fitted values : %s\n" % self.fitted_values, + "Fitted residuals : %s\n" % self.fitted_residuals, + "Eqv. nb of parameters : %s" % self.enp, + "Residual error : %s" % self.s, + "Deltas : %s - %s" % (self.one_delta, self.two_delta), + "Normalization factors : %s" % self.divisor,] + return '\n'.join(strg) #####--------------------------------------------------------------------------- @@ -353,59 +624,117 @@ #####--------------------------------------------------------------------------- #---- ---- loess confidence --- #####--------------------------------------------------------------------------- -cdef class confidence_interval: - cdef c_loess.c_conf_inv *_base +cdef class conf_intervals: + cdef c_loess.c_conf_inv _base cdef nest #......... def __dealloc__(self): c_loess.pw_free_mem(self) #......... property fit: + """ + fit : ndarray + The (m,) ndarray of estimated values + """ def __get__(self): - return floatarray_from_data(nest, 1, self._base.fit) + return floatarray_from_data(self.nest, 1, self._base.fit) #......... property upper: + """ + upper : ndarray + The (m,) ndarray of the upper limits of the pointwise confidence intervals. + """ def __get__(self): - return floatarray_from_data(nest, 1, self._base.upper) + return floatarray_from_data(self.nest, 1, self._base.upper) #......... - property lower: + property lower: + """ + lower : ndarray + The (m,) ndarray of the lower limits of the pointwise confidence intervals. + """ def __get__(self): - return floatarray_from_data(nest, 1, self._base.lower) + return floatarray_from_data(self.nest, 1, self._base.lower) + #......... + def __str__(self): + cdef ndarray tmp_ndr + tmp_ndr = numpy.r_[[self.lower,self.fit,self.upper]].T + return "Confidence intervals....\nLower b./ fit / upper b.\n%s" % \ + tmp_ndr #####--------------------------------------------------------------------------- #---- ---- loess predictions --- #####--------------------------------------------------------------------------- cdef class loess_predicted: - cdef c_loess.c_prediction *_base - cdef long nest - cdef confidence_interval conf_interval + cdef c_loess.c_prediction _base + cdef readonly long nest + cdef readonly conf_intervals confidence_intervals + #......... def __dealloc__(self): - c_loess.pred_free_mem(self._base) + c_loess.pred_free_mem(&self._base) #......... - property predicted: + property values: + """ + values : ndarray + The (m,) ndarray of loess values evaluated at newdata + """ def __get__(self): - return floatarray_from_data(nest, 1, self._base.fit) + return floatarray_from_data(self.nest, 1, self._base.fit) #......... - property predicted_stderr: + property stderr: + """ + stderr : ndarray + The (m,) ndarray of the estimates of the standard error on the estimated + values. + """ def __get__(self): - return floatarray_from_data(nest, 1, self._base.se_fit) + return floatarray_from_data(self.nest, 1, self._base.se_fit) #......... property residual_scale: + """ + residual_scale : float + Estimate of the scale of the residuals + """ def __get__(self): - return self.residual_scale + return self._base.residual_scale #......... property df: + """ + df : integer + Degrees of freedom of the t-distribution used to compute pointwise + confidence intervals for the evaluated surface. + """ def __get__(self): - return self.df + return self._base.df #......... def confidence(self, coverage=0.95): - """ + """Returns the pointwise confidence intervals for each predicted values, +at the given confidence interval coverage. + +:Parameters: coverage : float - Confidence level of the confidence intervals limits as a fraction. + Confidence level of the confidence intervals limits, as a fraction. """ - c_loess.pointwise(self._base, self.nest, coverage, - self.conf_interval._base) + cdef c_loess.c_conf_inv _conf_intv + if coverage < 0.5: + coverage = 1. - coverage + if coverage > 1. : + raise ValueError("The coverage precentage should be between 0 and 1!") + c_loess.pointwise(&self._base, self.nest, coverage, &_conf_intv) + self.confidence_intervals = conf_intervals() + self.confidence_intervals._base = _conf_intv + self.confidence_intervals.nest = self.nest + return self.confidence_intervals + #......... + def __str__(self): + strg = ["Outputs................", + "Predicted values : %s\n" % self.values, + "Predicted std error : %s\n" % self.stderr, + "Residual scale : %s" % self.residual_scale, + "Degrees of freedom : %s" % self.df, +# "Confidence intervals : %s" % self.confidence, + ] + return '\n'.join(strg) #####--------------------------------------------------------------------------- @@ -419,19 +748,30 @@ cdef readonly loess_kd_tree kd_tree cdef readonly loess_outputs outputs cdef readonly loess_predicted predicted + cdef public long nobs, npar - def __init__(self, object x, object y, object weights=None): + def __init__(self, object x, object y, object weights=None, **options): # cdef ndarray x_ndr, y_ndr cdef double *x_dat, *y_dat cdef int i - # - x_ndr = PyArray_FROMANY(x, NPY_DOUBLE, 1, 1, NPY_FORTRAN) - y_ndr = PyArray_FROMANY(y, NPY_DOUBLE, 1, 1, NPY_FORTRAN) + # Get the predictor array + x_ndr = numpy.array(x, copy=True, subok=True, order='C') x_dat = x_ndr.data - y_dat = y_ndr.data n = len(x_ndr) p = x_ndr.size / n + self.npar = p + self.nobs = n + # Ravel the predictor array ... + if p > 1: + x_ndr.shape = (n*p,) + # Get the response array ...... + y_ndr = numpy.array(y, copy=False, subok=True, order='C') + y_dat = y_ndr.data + if y_ndr.size != n: + raise ValueError("Incompatible size between the response array (%i)"\ + " and the predictor array (%i)" % (y_ndr,n)) + # Initialization .............. c_loess.loess_setup(x_dat, y_dat, n, p, &self._base) # self.inputs = loess_inputs() @@ -449,10 +789,25 @@ # self.outputs = loess_outputs() self.outputs._base = &self._base.outputs + self.outputs.activated = False self.outputs.nobs = n + self.outputs.npar = p + # Process options ............. + modelopt = {} + controlopt = {} + for (k,v) in options.iteritems(): + if k in ('family', 'span', 'degree', 'normalize', + 'parametric', 'drop_square',): + modelopt[k] = v + elif k in ('surface', 'statistics', 'trace_hat', + 'iterations', 'cell'): + controlopt[k] = v + self.control.update(**controlopt) + self.model.update(**modelopt) #...................................................... def fit(self): c_loess.loess_fit(&self._base) + self.outputs.activated = True return #...................................................... def summary(self): @@ -473,22 +828,55 @@ """ cdef ndarray p_ndr cdef double *p_dat + cdef c_loess.c_prediction _prediction cdef int i, m - # - p_ndr = PyArray_FROMANY(newdata, NPY_DOUBLE, 1, self.nvar, NPY_FORTRAN) + # Make sure there's been a fit earlier ... + if self.outputs.activated == 0: + c_loess.loess_fit(&self._base) + self.outputs.activated = True + # Note : we need a copy as we may have to normalize + p_ndr = numpy.array(newdata, copy=True, subok=True, order='C').ravel() p_dat = p_ndr.data - m = len(p_ndr) - c_loess.predict(p_dat, m, &self._base, self.predicted._base, stderr) + # Test the compatibility of sizes ....... + if p_ndr.size == 0: + raise ValueError("Can't predict without input data !") + (m, notOK) = divmod(len(p_ndr), self.npar) + if notOK: + raise ValueError( + "Incompatible data size: there should be as many rows as parameters") + #..... + c_loess.predict(p_dat, m, &self._base, &_prediction, stderr) + self.predicted = loess_predicted() + self.predicted._base = _prediction self.predicted.nest = m + return self.predicted + #......... + def __dealloc__(self): + c_loess.loess_free_mem(&self._base) #...................................................... -# def pointwisevoid(predicted *pre, int m, double coverage, -# struct ci_struct *ci) -# c_loess.pointwise(predicted *pre, int m, double coverage, -# struct ci_struct *ci) -# + + +#cdef prediction(loess loess_obj, object newdata, object stderr): +# cdef c_loess.c_prediction _base +# cdef ndarray p_ndr +# cdef double *p_dat +# cdef int i, m +# cdef loess_prediction result +# # +# p_ndr = numpy.array(newdata, copy=False, subok=True, order='F') #.ravel() +## p_ndr = PyArray_FROMANY(newdata, NPY_DOUBLE, 1, self.model.npar, NPY_FORTRAN) +# p_dat = p_ndr.data +# m = len(p_ndr) +# c_loess.predict(p_dat, m, &loess_obj._base, &_base, stderr) +# result = loess_predicted() +# result._base = _base +# result.nest = m +# return result + + #def anova(loess_one, loess_two): # cdef c_loess.c_anova result -# +# # c_loess.anova(loess_one._base, loess_two._base, &result) # \ No newline at end of file Modified: trunk/Lib/sandbox/pyloess/sandbox/src/loess.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/loess.c 2007-03-14 16:52:59 UTC (rev 2848) +++ trunk/Lib/sandbox/pyloess/sandbox/src/loess.c 2007-03-16 20:42:51 UTC (rev 2849) @@ -3,7 +3,6 @@ #include #include -#include static char *surf_stat; @@ -118,12 +117,6 @@ int cut, comp(); char *new_stat; void condition(); - char timestr[30]; - size_t timestri; - struct tm tim; - time_t now; - now = time(NULL); - tim = *(localtime(&now)); D = size_info[0]; N = size_info[1]; @@ -220,11 +213,9 @@ *one_delta = delta1; *two_delta = delta2; } - strftime(timestr,30,"%b %d, %Y; %H:%M:%S\n",&tim); - printf("%s", timestr); - for(i = 0; i < N; i++) - printf("%.6f\n", fitted_values[i]); + for(i = 0; i < N; i++){ fitted_residuals[i] = y[i] - fitted_values[i]; + }; if(j < (*iterations)) F77_SUB(lowesw)(fitted_residuals, &N, robust, temp); } Modified: trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c 2007-03-14 16:52:59 UTC (rev 2848) +++ trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c 2007-03-16 20:42:51 UTC (rev 2849) @@ -1,6 +1,7 @@ #include "S.h" #include #include +#include #define min(x,y) ((x) < (y) ? (x) : (y)) #define max(x,y) ((x) > (y) ? (x) : (y)) @@ -255,7 +256,7 @@ /* begin ehg's FORTRAN-callable C-codes */ -void +void* F77_SUB(ehg182)(int *i) { char *mess, mess2[50]; @@ -298,7 +299,9 @@ case 999: mess="not yet implemented"; break; default: sprintf(mess=mess2,"Assert failed; error code %d\n",*i); break; } - Recover(mess,NULL_ENTRY); /* in /usr/s/current/src/qpe/debug.c */ + printf(mess); + return(i); +// Recover(mess,NULL_ENTRY); /* in /usr/s/current/src/qpe/debug.c */ } void From scipy-svn at scipy.org Mon Mar 19 19:50:35 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 19 Mar 2007 18:50:35 -0500 (CDT) Subject: [Scipy-svn] r2850 - in trunk/Lib/sandbox/pyloess/sandbox: . src Message-ID: <20070319235035.F3D2739C0AB@new.scipy.org> Author: pierregm Date: 2007-03-19 18:50:21 -0500 (Mon, 19 Mar 2007) New Revision: 2850 Modified: trunk/Lib/sandbox/pyloess/sandbox/pyloess.py trunk/Lib/sandbox/pyloess/sandbox/src/S.h trunk/Lib/sandbox/pyloess/sandbox/src/c_loess.pxd trunk/Lib/sandbox/pyloess/sandbox/src/c_python.pxd trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c trunk/Lib/sandbox/pyloess/sandbox/src/cloess.h trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx trunk/Lib/sandbox/pyloess/sandbox/src/loess.c trunk/Lib/sandbox/pyloess/sandbox/src/loess.h trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c trunk/Lib/sandbox/pyloess/sandbox/src/loessf.f trunk/Lib/sandbox/pyloess/sandbox/src/misc.c trunk/Lib/sandbox/pyloess/sandbox/src/predict.c Log: * Add anova * Prevent the code to exit on Fortran error, raise an exception instead * Fixed the exception.NameError in confidence_intervals TODO: Modify parametric_flags and drop_square on an element-by-element basis Modified: trunk/Lib/sandbox/pyloess/sandbox/pyloess.py =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/pyloess.py 2007-03-16 20:42:51 UTC (rev 2849) +++ trunk/Lib/sandbox/pyloess/sandbox/pyloess.py 2007-03-19 23:50:21 UTC (rev 2850) @@ -110,10 +110,10 @@ (x, y, results, newdata1, newdata2, madeup) = self.d madeup.model.span = 0.5 madeup.model.normalize = True - madeup.predict(newdata1, stderr=False) + madeup.predict(newdata1, stderror=False) assert_almost_equal(madeup.predicted.values, results[4], 5) # - madeup_pred = madeup.predict(newdata1, stderr=False) + madeup_pred = madeup.predict(newdata1, stderror=False) assert_almost_equal(madeup_pred.values, results[4], 5) # def test_2d_pred_nodata(self): @@ -131,13 +131,13 @@ (x, y, results, newdata1, newdata2, madeup) = self.d madeup.model.span = 0.5 madeup.model.normalize = True - madeup_pred = madeup.predict(newdata2, stderr=True) + madeup_pred = madeup.predict(newdata2, stderror=True) assert_almost_equal(madeup_pred.values, results[5], 5) assert_almost_equal(madeup_pred.stderr, [0.276746, 0.278009], 5) assert_almost_equal(madeup_pred.residual_scale, 0.969302, 6) assert_almost_equal(madeup_pred.df, 81.2319, 4) # Direct access - madeup.predict(newdata2, stderr=True) + madeup.predict(newdata2, stderror=True) assert_almost_equal(madeup.predicted.values, results[5], 5) assert_almost_equal(madeup.predicted.stderr, [0.276746, 0.278009], 5) assert_almost_equal(madeup.predicted.residual_scale, 0.969302, 6) @@ -148,7 +148,7 @@ (x, y, results, newdata1, newdata2, madeup) = self.d madeup.model.span = 0.5 madeup.model.normalize = True - madeup_pred = madeup.predict(newdata2, stderr=True) + madeup_pred = madeup.predict(newdata2, stderror=True) madeup.predicted.confidence(coverage=0.99) assert_almost_equal(madeup.predicted.confidence_intervals.lower, results[6][::3], 5) @@ -215,14 +215,14 @@ (E, NOx, gas_fit_E, newdata, coverage, results) = self.d gas = cloess.loess(E,NOx, span=2./3.) gas.fit() - gas.predict(gas_fit_E, stderr=False) + gas.predict(gas_fit_E, stderror=False) assert_almost_equal(gas.predicted.values, results[2], 6) # def test_1dpredict_2(self): "Basic test 1d - new predictions" (E, NOx, gas_fit_E, newdata, coverage, results) = self.d gas = cloess.loess(E,NOx, span=2./3.) - gas.predict(newdata, stderr=True) + gas.predict(newdata, stderror=True) gas.predicted.confidence(0.99) assert_almost_equal(gas.predicted.confidence_intervals.lower, results[3][0::3], 6) @@ -230,11 +230,59 @@ results[3][1::3], 6) assert_almost_equal(gas.predicted.confidence_intervals.upper, results[3][2::3], 6) + # + def test_anova(self): + "Tests anova" + (E, NOx, gas_fit_E, newdata, coverage, results) = self.d + gas = cloess.loess(E,NOx, span=2./3.) + gas.fit() + gas_null = cloess.loess(E, NOx, span=1.0) + gas_null.fit() + gas_anova = cloess.anova(gas, gas_null) + gas_anova_theo = results[4] + assert_almost_equal(gas_anova.dfn, gas_anova_theo[0], 5) + assert_almost_equal(gas_anova.dfd, gas_anova_theo[1], 5) + assert_almost_equal(gas_anova.F_value, gas_anova_theo[2], 5) + assert_almost_equal(gas_anova.Pr_F, gas_anova_theo[3], 5) + # + def test_failures(self): + "Tests failures" + (E, NOx, gas_fit_E, newdata, coverage, results) = self.d + gas = cloess.loess(E,NOx, span=2./3.) + # This one should fail (all parametric) + gas.model.parametric_flags = True + self.assertRaises(ValueError, gas.fit) + # This one also (all drop_square) + gas.model.drop_square_flags = True + self.assertRaises(ValueError, gas.fit) + gas.model.degree = 1 + self.assertRaises(ValueError, gas.fit) + # This one should not (revert to std) + gas.model.parametric_flags = False + gas.model.drop_square_flags = False + gas.model.degree = 2 + gas.fit() + # Now, for predict ................. + gas.predict(gas_fit_E, stderror=False) + # This one should fail (extrapolation & blending) + self.assertRaises(ValueError, + gas.predict, gas.predicted.values, stderror=False) + # But this one should not .......... + gas.predict(gas_fit_E, stderror=False) + print "OK" + + + + + ######################################################################## if __name__ == '__main__': NumpyTest().run() + print "cloess:", dir(cloess) +# print "cloess.modelflags", dir(cloess.modelflags) + if 0: NOx = N.array([4.818, 2.849, 3.275, 4.691, 4.255, 5.064, 2.118, 4.602, 2.286, 0.970, 3.965, 5.344, 3.834, 1.990, 5.199, 5.283, @@ -243,8 +291,48 @@ 1.074, 1.148, 1.000, 0.928, 0.767, 0.701, 0.807, 0.902, 0.997, 1.224, 1.089, 0.973, 0.980, 0.665]) gas_fit_E = N.array([0.665, 0.949, 1.224]) - gas_test = loess(E, NOx, span=2./3.) -# gas_test.fit() - gas_test.predict(gas_fit_E, stderr=False) - gas_test.predict(gas_test.predicted.values, stderr=False) + gas = loess(E, NOx, span=2./3.) + # + gas.model.parametric_flags = True + try: + gas.fit() + except ValueError: + pass + else: + raise AssertionError("ValueError not raised !") + + + # + if 0: + dfile = open(os.path.join('examples','madeup_data'), 'r') + dfile.readline() + x = N.fromiter((float(v) for v in dfile.readline().rstrip().split()), + N.float_).reshape(-1,2) + dfile.readline() + y = N.fromiter((float(v) for v in dfile.readline().rstrip().split()), + N.float_) + dfile = open(os.path.join('examples','madeup_data'), 'r') + dfile.readline() + # + rfile = open(os.path.join('examples','madeup_result'), 'r') + results = [] + for i in range(8): + rfile.readline() + z = N.fromiter((float(v) for v in rfile.readline().rstrip().split()), + N.float_) + results.append(z) + # + newdata1 = N.array([[-2.5, 0.0, 2.5], [0., 0., 0.]]) + newdata2 = N.array([[-0.5, 0.5], [0., 0.]]) + # + madeup = cloess.loess(x,y) + + print madeup.model + madeup.model.parametric_flags = [True, False] + print madeup.model + madeup.model.parametric_flags[0] = False + print madeup.model + madeup.model.update(family="symmetric",normalize=False) + print madeup.model + \ No newline at end of file Modified: trunk/Lib/sandbox/pyloess/sandbox/src/S.h =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/S.h 2007-03-16 20:42:51 UTC (rev 2849) +++ trunk/Lib/sandbox/pyloess/sandbox/src/S.h 2007-03-19 23:50:21 UTC (rev 2850) @@ -27,3 +27,6 @@ #define NULL_ENTRY ((int *)NULL) + + + Modified: trunk/Lib/sandbox/pyloess/sandbox/src/c_loess.pxd =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/c_loess.pxd 2007-03-16 20:42:51 UTC (rev 2849) +++ trunk/Lib/sandbox/pyloess/sandbox/src/c_loess.pxd 2007-03-19 23:50:21 UTC (rev 2850) @@ -1,6 +1,9 @@ # -*- Mode: Python -*- cdef extern from "loess.h": + ctypedef struct c_loess_errstatus "loess_errstatus": + int err_status + char *err_msg ctypedef struct c_loess_inputs "loess_inputs": long n long p @@ -40,16 +43,17 @@ c_loess_control control c_loess_kd_tree kd_tree c_loess_outputs outputs + c_loess_errstatus status ctypedef struct c_prediction "prediction": double *fit double *se_fit double residual_scale double df - ctypedef struct c_anova "anova_struct": - double dfn - double dfd - double F_value - double Pr_F +# ctypedef struct c_anova "anova_struct": +# double dfn +# double dfd +# double F_value +# double Pr_F ctypedef struct c_conf_inv "conf_inv": double *fit double *upper @@ -61,8 +65,11 @@ void loess_free_mem(c_loess *lo) void loess_summary(c_loess *lo) # - void predict(double *eval, int m, c_loess *lo, c_prediction *pre, int se) + void c_predict "predict" (double *eval, int m, c_loess *lo, c_prediction *pre, int se) void pred_free_mem(c_prediction *pre) # - void anova(c_loess *one, c_loess *two, c_anova *out) - void pointwise(c_prediction *pre, int m, double coverage, c_conf_inv *ci) \ No newline at end of file + void c_pointwise "pointwise" (c_prediction *pre, int m, double coverage, c_conf_inv *ci) + double pf (double q, double df1, double df2) + double ibeta (double x, double a, double b) + void pw_free_mem (c_conf_inv *ci) + Modified: trunk/Lib/sandbox/pyloess/sandbox/src/c_python.pxd =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/c_python.pxd 2007-03-16 20:42:51 UTC (rev 2849) +++ trunk/Lib/sandbox/pyloess/sandbox/src/c_python.pxd 2007-03-19 23:50:21 UTC (rev 2850) @@ -18,3 +18,5 @@ void Py_XINCREF(object o) void Py_XDECREF(object o) void Py_CLEAR(object o) # use instead of decref + + object PyList_New(int size) Modified: trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c 2007-03-16 20:42:51 UTC (rev 2849) +++ trunk/Lib/sandbox/pyloess/sandbox/src/cloess.c 2007-03-19 23:50:21 UTC (rev 2850) @@ -1,4 +1,4 @@ -/* Generated by Pyrex 0.9.5.1a on Fri Mar 16 16:29:33 2007 */ +/* Generated by Pyrex 0.9.5.1a on Mon Mar 19 19:46:10 2007 */ #include "Python.h" #include "structmember.h" @@ -46,6 +46,8 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ +static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ + static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/ static void __Pyx_AddTraceback(char *funcname); /*proto*/ @@ -86,11 +88,17 @@ struct __pyx_obj_6cloess_loess_model { PyObject_HEAD + struct __pyx_vtabstruct_6cloess_loess_model *__pyx_vtab; loess_model (*_base); long npar; }; +struct __pyx_vtabstruct_6cloess_loess_model { + PyObject *((*setup)(struct __pyx_obj_6cloess_loess_model *,loess_model (*),long )); +}; +static struct __pyx_vtabstruct_6cloess_loess_model *__pyx_vtabptr_6cloess_loess_model; + struct __pyx_obj_6cloess_loess_outputs { PyObject_HEAD loess_outputs (*_base); @@ -100,28 +108,35 @@ }; -struct __pyx_obj_6cloess_loess_anova { - PyObject_HEAD - anova_struct (*_base); - long nest; -}; - - struct __pyx_obj_6cloess_conf_intervals { PyObject_HEAD + struct __pyx_vtabstruct_6cloess_conf_intervals *__pyx_vtab; conf_inv _base; - PyObject *nest; + PyArrayObject *lower; + PyArrayObject *fit; + PyArrayObject *upper; }; +struct __pyx_vtabstruct_6cloess_conf_intervals { + PyObject *((*setup)(struct __pyx_obj_6cloess_conf_intervals *,conf_inv ,long )); +}; +static struct __pyx_vtabstruct_6cloess_conf_intervals *__pyx_vtabptr_6cloess_conf_intervals; + struct __pyx_obj_6cloess_loess_predicted { PyObject_HEAD + struct __pyx_vtabstruct_6cloess_loess_predicted *__pyx_vtab; prediction _base; long nest; struct __pyx_obj_6cloess_conf_intervals *confidence_intervals; }; +struct __pyx_vtabstruct_6cloess_loess_predicted { + PyObject *((*setup)(struct __pyx_obj_6cloess_loess_predicted *,prediction ,long )); +}; +static struct __pyx_vtabstruct_6cloess_loess_predicted *__pyx_vtabptr_6cloess_loess_predicted; + struct __pyx_obj_6cloess_loess { PyObject_HEAD loess _base; @@ -135,18 +150,27 @@ long npar; }; + +struct __pyx_obj_6cloess_anova { + PyObject_HEAD + double dfn; + double dfd; + double F_value; + double Pr_F; +}; + static PyTypeObject *__pyx_ptype_6cloess_loess_inputs = 0; static PyTypeObject *__pyx_ptype_6cloess_loess_control = 0; static PyTypeObject *__pyx_ptype_6cloess_loess_kd_tree = 0; static PyTypeObject *__pyx_ptype_6cloess_loess_model = 0; static PyTypeObject *__pyx_ptype_6cloess_loess_outputs = 0; -static PyTypeObject *__pyx_ptype_6cloess_loess_anova = 0; static PyTypeObject *__pyx_ptype_6cloess_conf_intervals = 0; static PyTypeObject *__pyx_ptype_6cloess_loess_predicted = 0; static PyTypeObject *__pyx_ptype_6cloess_loess = 0; -static PyObject *__pyx_k35; -static PyObject *__pyx_k36; -static PyObject *__pyx_k37; +static PyTypeObject *__pyx_ptype_6cloess_anova = 0; +static PyObject *__pyx_k32; +static PyObject *__pyx_k33; +static PyObject *__pyx_k34; static PyObject *(__pyx_f_6cloess_floatarray_from_data(int ,int ,double (*))); /*proto*/ static PyObject *(__pyx_f_6cloess_boolarray_from_data(int ,int ,int (*))); /*proto*/ @@ -161,9 +185,9 @@ static char (__pyx_k6[]) = "\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n "; static char (__pyx_k7[]) = "\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n "; static char (__pyx_k8[]) = "\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n "; -static char (__pyx_k9[]) = "Smoothing factor, as a fraction of the number of points to take into\n account. By default, span=0.75."; -static char (__pyx_k10[]) = "\n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n "; -static char (__pyx_k11[]) = "\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n "; +static char (__pyx_k9[]) = "\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n "; +static char (__pyx_k10[]) = "Smoothing factor, as a fraction of the number of points to take into\n account. By default, span=0.75."; +static char (__pyx_k11[]) = "\n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n "; static char (__pyx_k12[]) = "\n family : string [\"gaussian\"]\n Determines the assumed distribution of the errors. The values are \n \"gaussian\" or \"symmetric\". If \"gaussian\" is selected, the fit is \n performed with least-squares. If \"symmetric\" is selected, the fit\n is performed robustly by redescending M-estimators.\n "; static char (__pyx_k13[]) = "\n parametric_flags : sequence [ [False]*p ]\n Indicates which independent variables should be conditionally-parametric\n (if there are two or more independent variables). The argument should \n be a sequence of booleans, with the same size as the number of independent \n variables, specified in the order of the predictor group ordered in x. \n "; static char (__pyx_k14[]) = "\n drop_square : sequence [ [False]* p]\n When there are two or more independent variables and when a 2nd order\n polynomial is used, \"drop_square_flags\" specifies those numeric predictors \n whose squares should be dropped from the set of fitting variables. \n The method of specification is the same as for parametric. \n "; @@ -178,19 +202,18 @@ static char (__pyx_k23[]) = "\n one_delta: float\n Statistical parameter used in the computation of standard errors.\n "; static char (__pyx_k24[]) = "\n two_delta : float\n Statistical parameter used in the computation of standard errors.\n "; static char (__pyx_k25[]) = "\n trace_hat : float \n Trace of the operator hat matrix.\n "; -static char (__pyx_k26[]) = "\n fit : ndarray\n The (m,) ndarray of estimated values\n "; -static char (__pyx_k27[]) = "\n upper : ndarray\n The (m,) ndarray of the upper limits of the pointwise confidence intervals.\n "; -static char (__pyx_k28[]) = "\n lower : ndarray\n The (m,) ndarray of the lower limits of the pointwise confidence intervals.\n "; -static char (__pyx_k29[]) = "\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n "; -static char (__pyx_k30[]) = "\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n "; -static char (__pyx_k31[]) = "\n residual_scale : float\n Estimate of the scale of the residuals\n "; -static char (__pyx_k32[]) = "\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n "; -static char (__pyx_k34[]) = "\n:Keywords:\n x : ndarray\n A (n,p) ndarray of independent variables, with n the number of observations\n and p the number of variables.\n y : ndarray\n A (n,) ndarray of observations\n weights : ndarray\n A (n,) ndarray of weights to be given to individual observations in the \n sum of squared residuals that forms the local fitting criterion. If not\n None, the weights should be non negative. If the different observations\n have non-equal variances, the weights should be inversely proportional \n to the variances.\n By default, an unweighted fit is carried out (all the weights are one).\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n span : float [0.75]\n Smoothing factor, as a fraction of the number of points to take into\n account. \n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n family : string [\"gaussian\"]\n Determines the assumed distribution of the errors. The values are \n \"gaussian\" or \"symmetric\". If \"gaussian\" is selected, the fit is \n performed with least-squares. If \"symmetric\" is selected, the fit\n is performed robustly by redescending M-estimators.\n parametric_flags : sequence [ [False]*p ]\n Indicates which independent variables should be conditionally-parametric\n (if there are two or more independent variables). The argument should \n be a sequence of booleans, with the same size as the number of independent \n variables, specified in the order of the predictor group ordered in x. \n drop_square : sequence [ [False]* p]\n When there are two or more independent variables and when a 2nd order\n polynomial is used, \"drop_square_flags\" specifies those numeric predictors \n whose squares should be dropped from the set of fitting variables. \n The method of specification is the same as for parametric. \n \n:Outputs:\n fitted_values : ndarray\n The (n,) ndarray of fitted values.\n fitted_residuals : ndarray\n The (n,) ndarray of fitted residuals (observations - fitted values).\n enp : float\n Equivalent number of parameters.\n s : float\n Estimate of the scale of residuals.\n one_delta: float\n Statistical parameter used in the computation of standard errors.\n two_delta : float\n Statistical parameter used in the computation of standard errors.\n pseudovalues : ndarray\n The (n,) ndarray of adjusted values of the response when robust estimation \n is used.\n trace_hat : float \n Trace of the operator hat matrix.\n diagonal :\n Diagonal of the operator hat matrix.\n robust : ndarray\n The (n,) ndarray of robustness weights for robust fitting.\n divisor : ndarray\n The (p,) array of normalization divisors for numeric predictors.\n \n\n newdata : ndarray\n The (m,p) array of independent variables where the surface must be estimated.\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n residual_scale : float\n Estimate of the scale of the residuals\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n nest : integer\n Number of new observations.\n \n \n"; +static char (__pyx_k26[]) = "\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n "; +static char (__pyx_k27[]) = "\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n "; +static char (__pyx_k28[]) = "\n residual_scale : float\n Estimate of the scale of the residuals\n "; +static char (__pyx_k29[]) = "\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n "; +static char (__pyx_k31[]) = "\n:Keywords:\n x : ndarray\n A (n,p) ndarray of independent variables, with n the number of observations\n and p the number of variables.\n y : ndarray\n A (n,) ndarray of observations\n weights : ndarray\n A (n,) ndarray of weights to be given to individual observations in the \n sum of squared residuals that forms the local fitting criterion. If not\n None, the weights should be non negative. If the different observations\n have non-equal variances, the weights should be inversely proportional \n to the variances.\n By default, an unweighted fit is carried out (all the weights are one).\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n span : float [0.75]\n Smoothing factor, as a fraction of the number of points to take into\n account. \n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n family : string [\"gaussian\"]\n Determines the assumed distribution of the errors. The values are \n \"gaussian\" or \"symmetric\". If \"gaussian\" is selected, the fit is \n performed with least-squares. If \"symmetric\" is selected, the fit\n is performed robustly by redescending M-estimators.\n parametric_flags : sequence [ [False]*p ]\n Indicates which independent variables should be conditionally-parametric\n (if there are two or more independent variables). The argument should \n be a sequence of booleans, with the same size as the number of independent \n variables, specified in the order of the predictor group ordered in x. \n drop_square : sequence [ [False]* p]\n When there are two or more independent variables and when a 2nd order\n polynomial is used, \"drop_square_flags\" specifies those numeric predictors \n whose squares should be dropped from the set of fitting variables. \n The method of specification is the same as for parametric. \n \n:Outputs:\n fitted_values : ndarray\n The (n,) ndarray of fitted values.\n fitted_residuals : ndarray\n The (n,) ndarray of fitted residuals (observations - fitted values).\n enp : float\n Equivalent number of parameters.\n s : float\n Estimate of the scale of residuals.\n one_delta: float\n Statistical parameter used in the computation of standard errors.\n two_delta : float\n Statistical parameter used in the computation of standard errors.\n pseudovalues : ndarray\n The (n,) ndarray of adjusted values of the response when robust estimation \n is used.\n trace_hat : float \n Trace of the operator hat matrix.\n diagonal :\n Diagonal of the operator hat matrix.\n robust : ndarray\n The (n,) ndarray of robustness weights for robust fitting.\n divisor : ndarray\n The (p,) array of normalization divisors for numeric predictors.\n \n\n newdata : ndarray\n The (m,p) array of independent variables where the surface must be estimated.\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n residual_scale : float\n Estimate of the scale of the residuals\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n nest : integer\n Number of new observations.\n \n \n"; static PyObject *__pyx_n_c_python; static PyObject *__pyx_n_c_numpy; static PyObject *__pyx_n_numpy; +static PyObject *__pyx_n_narray; static PyObject *__pyx_n_c_loess; +static PyObject *__pyx_n_array; static PyObject *__pyx_n_False; static PyObject *__pyx_n_shape; @@ -205,36 +228,36 @@ PyObject *__pyx_4 = 0; __pyx_v_a_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":23 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":19 */ __pyx_v_size = (__pyx_v_rows * __pyx_v_cols); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":24 */ - __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":20 */ + __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} Py_INCREF(((PyObject *)__pyx_1)); Py_DECREF(((PyObject *)__pyx_v_a_ndr)); __pyx_v_a_ndr = ((PyArrayObject *)((PyObject *)__pyx_1)); Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":29 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":21 */ __pyx_2 = (__pyx_v_cols > 1); if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":30 */ - __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} - __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":22 */ + __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3); __pyx_1 = 0; __pyx_3 = 0; - if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":31 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":23 */ Py_INCREF(((PyObject *)__pyx_v_a_ndr)); __pyx_r = ((PyObject *)__pyx_v_a_ndr); goto __pyx_L0; @@ -265,44 +288,44 @@ PyObject *__pyx_4 = 0; __pyx_v_a_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":36 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":28 */ __pyx_v_size = (__pyx_v_rows * __pyx_v_cols); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":39 */ - __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":29 */ + __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} Py_INCREF(((PyObject *)__pyx_1)); Py_DECREF(((PyObject *)__pyx_v_a_ndr)); __pyx_v_a_ndr = ((PyArrayObject *)((PyObject *)__pyx_1)); Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":43 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":30 */ __pyx_2 = (__pyx_v_cols > 1); if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":44 */ - __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} - __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":31 */ + __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3); __pyx_1 = 0; __pyx_3 = 0; - if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L1;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":45 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_astype); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} - __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_bool); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":32 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_astype); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_bool); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4); __pyx_4 = 0; - __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -328,8 +351,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":173 */ - __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->p,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->x); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":198 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->p,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->x); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -351,8 +374,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":177 */ - __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n,1,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->y); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":202 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n,1,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->y); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -374,8 +397,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":188 */ - __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n,1,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->weights); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":213 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n,1,((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->weights); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -395,9 +418,9 @@ static PyObject *__pyx_n_size; static PyObject *__pyx_n_ValueError; -static PyObject *__pyx_k38p; +static PyObject *__pyx_k35p; -static char (__pyx_k38[]) = "Invalid size of the 'weights' vector!"; +static char (__pyx_k35[]) = "Invalid size of the 'weights' vector!"; static int __pyx_f_6cloess_12loess_inputs_7weights___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_w); /*proto*/ static int __pyx_f_6cloess_12loess_inputs_7weights___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_w) { @@ -410,40 +433,40 @@ Py_INCREF(__pyx_v_w); __pyx_v_w_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":193 */ - __pyx_1 = PyArray_FROMANY(__pyx_v_w,NPY_DOUBLE,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":218 */ + __pyx_1 = PyArray_FROMANY(__pyx_v_w,NPY_DOUBLE,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;} Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); Py_DECREF(((PyObject *)__pyx_v_w_ndr)); __pyx_v_w_ndr = ((PyArrayObject *)__pyx_1); Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":194 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_ndim); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":219 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_ndim); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} __pyx_2 = __pyx_2 > 0; Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; if (!__pyx_2) { - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} __pyx_2 = __pyx_2 != 0; Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; } if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":195 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; goto __pyx_L1;} - __Pyx_Raise(__pyx_1, __pyx_k38p, 0); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":220 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;} + __Pyx_Raise(__pyx_1, __pyx_k35p, 0); Py_DECREF(__pyx_1); __pyx_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":196 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":221 */ ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->weights = ((double (*))__pyx_v_w_ndr->data); __pyx_r = 0; @@ -466,8 +489,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":201 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":226 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -489,8 +512,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":206 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":231 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_inputs *)__pyx_v_self)->_base->p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -512,8 +535,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":223 */ - __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":248 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -533,11 +556,11 @@ static PyObject *__pyx_n_interpolate; static PyObject *__pyx_n_direct; -static PyObject *__pyx_k41p; -static PyObject *__pyx_k42p; +static PyObject *__pyx_k38p; +static PyObject *__pyx_k39p; -static char (__pyx_k41[]) = "Invalid value for the 'surface' argument: "; -static char (__pyx_k42[]) = "should be in ('interpolate', 'direct')."; +static char (__pyx_k38[]) = "Invalid value for the 'surface' argument: "; +static char (__pyx_k39[]) = "should be in ('interpolate', 'direct')."; static int __pyx_f_6cloess_13loess_control_7surface___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_surface); /*proto*/ static int __pyx_f_6cloess_13loess_control_7surface___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_surface) { @@ -552,47 +575,47 @@ Py_INCREF(__pyx_v_surface); __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":225 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} - __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":250 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;} Py_INCREF(__pyx_n_interpolate); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_interpolate); Py_INCREF(__pyx_n_direct); PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_direct); - __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;} + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;} __pyx_3 = !__pyx_3; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_3) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":226 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} - __pyx_1 = PyNumber_Add(__pyx_k41p, __pyx_k42p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":251 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + __pyx_1 = PyNumber_Add(__pyx_k38p, __pyx_k39p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_1, 0, 0); Py_DECREF(__pyx_1); __pyx_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":228 */ - __pyx_2 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;} - __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":253 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_tmpx); __pyx_v_tmpx = __pyx_4; __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":229 */ - __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":254 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;} ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->surface = __pyx_5; __pyx_r = 0; @@ -616,8 +639,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":240 */ - __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":265 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -636,9 +659,9 @@ static PyObject *__pyx_n_approximate; static PyObject *__pyx_n_exact; -static PyObject *__pyx_k45p; +static PyObject *__pyx_k42p; -static char (__pyx_k45[]) = "Invalid value for the 'statistics' argument: should be in ('approximate', 'exact')."; +static char (__pyx_k42[]) = "Invalid value for the 'statistics' argument: should be in ('approximate', 'exact')."; static int __pyx_f_6cloess_13loess_control_10statistics___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_statistics); /*proto*/ static int __pyx_f_6cloess_13loess_control_10statistics___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_statistics) { @@ -653,46 +676,46 @@ Py_INCREF(__pyx_v_statistics); __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":242 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;} - __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":267 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;} + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} Py_INCREF(__pyx_n_approximate); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_approximate); Py_INCREF(__pyx_n_exact); PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_exact); - __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;} + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} __pyx_3 = !__pyx_3; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_3) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":243 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} - Py_INCREF(__pyx_k45p); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k45p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":268 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + Py_INCREF(__pyx_k42p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k42p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":245 */ - __pyx_2 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;} - __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":270 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_tmpx); __pyx_v_tmpx = __pyx_1; __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":246 */ - __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":271 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; goto __pyx_L1;} ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->statistics = __pyx_5; __pyx_r = 0; @@ -716,8 +739,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":262 */ - __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":287 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -733,9 +756,9 @@ return __pyx_r; } -static PyObject *__pyx_k48p; +static PyObject *__pyx_k45p; -static char (__pyx_k48[]) = "Invalid value for the 'trace_hat' argument: should be in ('approximate', 'exact')."; +static char (__pyx_k45[]) = "Invalid value for the 'trace_hat' argument: should be in ('approximate', 'exact')."; static int __pyx_f_6cloess_13loess_control_9trace_hat___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_trace_hat); /*proto*/ static int __pyx_f_6cloess_13loess_control_9trace_hat___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_trace_hat) { @@ -750,46 +773,46 @@ Py_INCREF(__pyx_v_trace_hat); __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":264 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} - __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":289 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} Py_INCREF(__pyx_n_approximate); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_approximate); Py_INCREF(__pyx_n_exact); PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_exact); - __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} __pyx_3 = !__pyx_3; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_3) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":265 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;} - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;} - Py_INCREF(__pyx_k48p); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k48p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":290 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + Py_INCREF(__pyx_k45p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k45p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":267 */ - __pyx_2 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} - __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":292 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_tmpx); __pyx_v_tmpx = __pyx_1; __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":268 */ - __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":293 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;} ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->trace_hat = __pyx_5; __pyx_r = 0; @@ -813,8 +836,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":277 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":302 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -830,9 +853,9 @@ return __pyx_r; } -static PyObject *__pyx_k49p; +static PyObject *__pyx_k46p; -static char (__pyx_k49[]) = "Invalid number of iterations: should be positive"; +static char (__pyx_k46[]) = "Invalid number of iterations: should be positive"; static int __pyx_f_6cloess_13loess_control_10iterations___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_iterations); /*proto*/ static int __pyx_f_6cloess_13loess_control_10iterations___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_iterations) { @@ -844,30 +867,30 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_iterations); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":279 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_iterations, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":304 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_iterations, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;} __pyx_2 = __pyx_2 < 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":280 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;} - Py_INCREF(__pyx_k49p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k49p); - __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":305 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} + Py_INCREF(__pyx_k46p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k46p); + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":281 */ - __pyx_2 = PyInt_AsLong(__pyx_v_iterations); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":306 */ + __pyx_2 = PyInt_AsLong(__pyx_v_iterations); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; goto __pyx_L1;} ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->iterations = __pyx_2; __pyx_r = 0; @@ -890,8 +913,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":293 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":318 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -907,9 +930,9 @@ return __pyx_r; } -static PyObject *__pyx_k50p; +static PyObject *__pyx_k47p; -static char (__pyx_k50[]) = "Invalid value for the cell argument: should be positive"; +static char (__pyx_k47[]) = "Invalid value for the cell argument: should be positive"; static int __pyx_f_6cloess_13loess_control_4cell___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_cell); /*proto*/ static int __pyx_f_6cloess_13loess_control_4cell___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_cell) { @@ -922,30 +945,30 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_cell); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":295 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_cell, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":320 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_cell, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; goto __pyx_L1;} __pyx_2 = __pyx_2 <= 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":296 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;} - Py_INCREF(__pyx_k50p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k50p); - __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":321 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;} + Py_INCREF(__pyx_k47p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k47p); + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":297 */ - __pyx_5 = PyFloat_AsDouble(__pyx_v_cell); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":322 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_cell); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;} ((struct __pyx_obj_6cloess_loess_control *)__pyx_v_self)->_base->cell = __pyx_5; __pyx_r = 0; @@ -1000,122 +1023,122 @@ __pyx_v_iterations = Py_None; Py_INCREF(Py_None); __pyx_v_cell = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":301 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":326 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} Py_INCREF(__pyx_n_surface); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_surface); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_surface); __pyx_v_surface = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":302 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":327 */ __pyx_4 = __pyx_v_surface != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":303 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_surface, __pyx_v_surface) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":328 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_surface, __pyx_v_surface) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":305 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":330 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;} Py_INCREF(__pyx_n_statistics); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_statistics); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_statistics); __pyx_v_statistics = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":306 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":331 */ __pyx_4 = __pyx_v_statistics != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":307 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_statistics, __pyx_v_statistics) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":332 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_statistics, __pyx_v_statistics) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;} goto __pyx_L3; } __pyx_L3:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":309 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":334 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;} Py_INCREF(__pyx_n_trace_hat); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_trace_hat); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_trace_hat); __pyx_v_trace_hat = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":310 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":335 */ __pyx_4 = __pyx_v_trace_hat != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":311 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_trace_hat, __pyx_v_trace_hat) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":336 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_trace_hat, __pyx_v_trace_hat) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;} goto __pyx_L4; } __pyx_L4:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":313 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":338 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;} Py_INCREF(__pyx_n_iterations); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_iterations); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_iterations); __pyx_v_iterations = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":314 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":339 */ __pyx_4 = __pyx_v_iterations != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":315 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_iterations, __pyx_v_iterations) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":340 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_iterations, __pyx_v_iterations) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;} goto __pyx_L5; } __pyx_L5:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":317 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":342 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;} Py_INCREF(__pyx_n_cell); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_cell); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_cell); __pyx_v_cell = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":318 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":343 */ __pyx_4 = __pyx_v_cell != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":319 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":344 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;} goto __pyx_L6; } __pyx_L6:; @@ -1143,21 +1166,21 @@ static PyObject *__pyx_n_join; +static PyObject *__pyx_k53p; +static PyObject *__pyx_k54p; +static PyObject *__pyx_k55p; static PyObject *__pyx_k56p; static PyObject *__pyx_k57p; static PyObject *__pyx_k58p; static PyObject *__pyx_k59p; -static PyObject *__pyx_k60p; -static PyObject *__pyx_k61p; -static PyObject *__pyx_k62p; -static char (__pyx_k56[]) = "Control :"; -static char (__pyx_k57[]) = "Surface type : %s"; -static char (__pyx_k58[]) = "Statistics : %s"; -static char (__pyx_k59[]) = "Trace estimation : %s"; -static char (__pyx_k60[]) = "Cell size : %s"; -static char (__pyx_k61[]) = "Nb iterations : %s"; -static char (__pyx_k62[]) = "\n"; +static char (__pyx_k53[]) = "Control :"; +static char (__pyx_k54[]) = "Surface type : %s"; +static char (__pyx_k55[]) = "Statistics : %s"; +static char (__pyx_k56[]) = "Trace estimation : %s"; +static char (__pyx_k57[]) = "Cell size : %s"; +static char (__pyx_k58[]) = "Nb iterations : %s"; +static char (__pyx_k59[]) = "\n"; static PyObject *__pyx_f_6cloess_13loess_control___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_13loess_control___str__(PyObject *__pyx_v_self) { @@ -1172,25 +1195,25 @@ Py_INCREF(__pyx_v_self); __pyx_v_strg = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":323 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k57p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":348 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k54p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; goto __pyx_L1;} - __pyx_3 = PyNumber_Remainder(__pyx_k58p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k55p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} - __pyx_4 = PyNumber_Remainder(__pyx_k59p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k56p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;} - __pyx_5 = PyNumber_Remainder(__pyx_k60p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k57p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; goto __pyx_L1;} - __pyx_6 = PyNumber_Remainder(__pyx_k61p, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;} + __pyx_6 = PyNumber_Remainder(__pyx_k58p, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyList_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; goto __pyx_L1;} - Py_INCREF(__pyx_k56p); - PyList_SET_ITEM(__pyx_1, 0, __pyx_k56p); + __pyx_1 = PyList_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;} + Py_INCREF(__pyx_k53p); + PyList_SET_ITEM(__pyx_1, 0, __pyx_k53p); PyList_SET_ITEM(__pyx_1, 1, __pyx_2); PyList_SET_ITEM(__pyx_1, 2, __pyx_3); PyList_SET_ITEM(__pyx_1, 3, __pyx_4); @@ -1205,12 +1228,12 @@ __pyx_v_strg = __pyx_1; __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":329 */ - __pyx_2 = PyObject_GetAttr(__pyx_k62p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":354 */ + __pyx_2 = PyObject_GetAttr(__pyx_k59p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;} Py_INCREF(__pyx_v_strg); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -1234,14 +1257,91 @@ return __pyx_r; } +static PyObject *__pyx_f_6cloess_11loess_model_setup(struct __pyx_obj_6cloess_loess_model *__pyx_v_self,loess_model (*__pyx_v_base),long __pyx_v_npar) { + PyObject *__pyx_r; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":375 */ + __pyx_v_self->_base = __pyx_v_base; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":376 */ + __pyx_v_self->npar = __pyx_v_npar; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":386 */ + Py_INCREF(((PyObject *)__pyx_v_self)); + __pyx_r = ((PyObject *)__pyx_v_self); + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6cloess_11loess_model_9normalize___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6cloess_11loess_model_9normalize___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":399 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_bool); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->normalize); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); + __pyx_2 = 0; + __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_2; + __pyx_2 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("cloess.loess_model.normalize.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static int __pyx_f_6cloess_11loess_model_9normalize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_normalize); /*proto*/ +static int __pyx_f_6cloess_11loess_model_9normalize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_normalize) { + int __pyx_r; + int __pyx_1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_normalize); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":401 */ + __pyx_1 = PyInt_AsLong(__pyx_v_normalize); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->normalize = __pyx_1; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + __Pyx_AddTraceback("cloess.loess_model.normalize.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_normalize); + return __pyx_r; +} + static PyObject *__pyx_f_6cloess_11loess_model_4span___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_11loess_model_4span___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":370 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":407 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -1257,9 +1357,9 @@ return __pyx_r; } -static PyObject *__pyx_k63p; +static PyObject *__pyx_k60p; -static char (__pyx_k63[]) = "Span should be between 0 and 1!"; +static char (__pyx_k60[]) = "Span should be between 0 and 1!"; static int __pyx_f_6cloess_11loess_model_4span___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_span); /*proto*/ static int __pyx_f_6cloess_11loess_model_4span___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_span) { @@ -1272,36 +1372,36 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_span); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":372 */ - __pyx_2 = PyFloat_FromDouble(0.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":409 */ + __pyx_2 = PyFloat_FromDouble(0.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} __pyx_1 = __pyx_1 <= 0; Py_DECREF(__pyx_2); __pyx_2 = 0; if (!__pyx_1) { - __pyx_2 = PyFloat_FromDouble(1.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; goto __pyx_L1;} + __pyx_2 = PyFloat_FromDouble(1.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} __pyx_1 = __pyx_1 > 0; Py_DECREF(__pyx_2); __pyx_2 = 0; } if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":373 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} - Py_INCREF(__pyx_k63p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k63p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":410 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;} + Py_INCREF(__pyx_k60p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k60p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":374 */ - __pyx_5 = PyFloat_AsDouble(__pyx_v_span); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":411 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_span); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; goto __pyx_L1;} ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->span = __pyx_5; __pyx_r = 0; @@ -1324,8 +1424,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":383 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":420 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -1341,9 +1441,9 @@ return __pyx_r; } -static PyObject *__pyx_k64p; +static PyObject *__pyx_k61p; -static char (__pyx_k64[]) = "Degree should be between 0 and 2!"; +static char (__pyx_k61[]) = "Degree should be between 0 and 2!"; static int __pyx_f_6cloess_11loess_model_6degree___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_degree); /*proto*/ static int __pyx_f_6cloess_11loess_model_6degree___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_degree) { @@ -1355,30 +1455,30 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_degree); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":385 */ - __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":422 */ + __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} __pyx_1 = __pyx_1 < 0; Py_DECREF(__pyx_2); __pyx_2 = 0; if (!__pyx_1) { - __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} __pyx_1 = __pyx_1 > 0; Py_DECREF(__pyx_2); __pyx_2 = 0; } if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":386 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;} - Py_INCREF(__pyx_k64p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k64p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":423 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} + Py_INCREF(__pyx_k61p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k61p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; @@ -1397,70 +1497,14 @@ return __pyx_r; } -static PyObject *__pyx_f_6cloess_11loess_model_9normalize___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_11loess_model_9normalize___get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - Py_INCREF(__pyx_v_self); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":399 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_bool); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->normalize); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_r = __pyx_2; - __pyx_2 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("cloess.loess_model.normalize.__get__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static int __pyx_f_6cloess_11loess_model_9normalize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_normalize); /*proto*/ -static int __pyx_f_6cloess_11loess_model_9normalize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_normalize) { - int __pyx_r; - int __pyx_1; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_normalize); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":401 */ - __pyx_1 = PyInt_AsLong(__pyx_v_normalize); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;} - ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->normalize = __pyx_1; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - __Pyx_AddTraceback("cloess.loess_model.normalize.__set__"); - __pyx_r = -1; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_normalize); - return __pyx_r; -} - static PyObject *__pyx_f_6cloess_11loess_model_6family___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_11loess_model_6family___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":412 */ - __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":434 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -1479,9 +1523,9 @@ static PyObject *__pyx_n_symmetric; static PyObject *__pyx_n_gaussian; -static PyObject *__pyx_k67p; +static PyObject *__pyx_k64p; -static char (__pyx_k67[]) = "Invalid value for the 'family' argument: should be in ('symmetric', 'gaussian')."; +static char (__pyx_k64[]) = "Invalid value for the 'family' argument: should be in ('symmetric', 'gaussian')."; static int __pyx_f_6cloess_11loess_model_6family___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_family); /*proto*/ static int __pyx_f_6cloess_11loess_model_6family___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_family) { @@ -1494,38 +1538,38 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_family); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":414 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_family, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; goto __pyx_L1;} - __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":436 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_family, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; goto __pyx_L1;} + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} Py_INCREF(__pyx_n_symmetric); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_symmetric); Py_INCREF(__pyx_n_gaussian); PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_gaussian); - __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; goto __pyx_L1;} + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} __pyx_3 = !__pyx_3; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_3) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":415 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; goto __pyx_L1;} - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; goto __pyx_L1;} - Py_INCREF(__pyx_k67p); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k67p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":437 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + Py_INCREF(__pyx_k64p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k64p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":417 */ - __pyx_5 = PyString_AsString(__pyx_v_family); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":439 */ + __pyx_5 = PyString_AsString(__pyx_v_family); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;} ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->family = __pyx_5; __pyx_r = 0; @@ -1548,8 +1592,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":428 */ - __pyx_1 = __pyx_f_6cloess_boolarray_from_data(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->parametric); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":450 */ + __pyx_1 = __pyx_f_6cloess_boolarray_from_data(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->parametric); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -1565,11 +1609,10 @@ return __pyx_r; } -static PyObject *__pyx_n_array; +static PyObject *__pyx_n_atleast_1d; static PyObject *__pyx_n_copy; static PyObject *__pyx_n_True; static PyObject *__pyx_n_subok; -static PyObject *__pyx_n_int; static PyObject *__pyx_n_dtype; static PyObject *__pyx_n_min; @@ -1577,7 +1620,6 @@ static int __pyx_f_6cloess_11loess_model_16parametric_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_paramf); /*proto*/ static int __pyx_f_6cloess_11loess_model_16parametric_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_paramf) { PyArrayObject *__pyx_v_p_ndr; - long (*__pyx_v_p_dat); int __pyx_v_i; int __pyx_r; PyObject *__pyx_1 = 0; @@ -1585,64 +1627,71 @@ PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; - long __pyx_6; + PyObject *__pyx_6 = 0; + long __pyx_7; + int __pyx_8; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_paramf); __pyx_v_p_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":433 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":454 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_atleast_1d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} Py_INCREF(__pyx_v_paramf); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_paramf); - __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} - __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_int); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (PyDict_SetItem(__pyx_3, __pyx_n_dtype, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_paramf); + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_bool); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (PyDict_SetItem(__pyx_4, __pyx_n_dtype, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; - if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5); + __pyx_5 = 0; + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_6); __pyx_6 = 0; + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_p_ndr)); - __pyx_v_p_ndr = ((PyArrayObject *)__pyx_4); - __pyx_4 = 0; + __pyx_v_p_ndr = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":434 */ - __pyx_v_p_dat = ((long (*))__pyx_v_p_ndr->data); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":435 */ - __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} - __pyx_4 = PyNumber_Subtract(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_4); - __pyx_2 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":456 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); + PyTuple_SET_ITEM(__pyx_2, 1, __pyx_5); __pyx_4 = 0; - __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_6 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} + __pyx_5 = 0; + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_6; ++__pyx_v_i) { + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_7 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_7; ++__pyx_v_i) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":436 */ - (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->parametric[__pyx_v_i]) = (__pyx_v_p_dat[__pyx_v_i]); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":457 */ + __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; goto __pyx_L1;} + __pyx_4 = PyObject_GetItem(((PyObject *)__pyx_v_p_ndr), __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_8 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->parametric[__pyx_v_i]) = __pyx_8; } __pyx_r = 0; @@ -1653,6 +1702,7 @@ Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); __Pyx_AddTraceback("cloess.loess_model.parametric_flags.__set__"); __pyx_r = -1; __pyx_L0:; @@ -1668,8 +1718,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":447 */ - __pyx_1 = __pyx_f_6cloess_boolarray_from_data(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->drop_square); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":468 */ + __pyx_1 = __pyx_f_6cloess_boolarray_from_data(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->drop_square); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -1689,7 +1739,6 @@ static int __pyx_f_6cloess_11loess_model_17drop_square_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_drop_sq); /*proto*/ static int __pyx_f_6cloess_11loess_model_17drop_square_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_drop_sq) { PyArrayObject *__pyx_v_d_ndr; - long (*__pyx_v_d_dat); int __pyx_v_i; int __pyx_r; PyObject *__pyx_1 = 0; @@ -1697,64 +1746,71 @@ PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; - long __pyx_6; + PyObject *__pyx_6 = 0; + long __pyx_7; + int __pyx_8; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_drop_sq); __pyx_v_d_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":452 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":472 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_atleast_1d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} Py_INCREF(__pyx_v_drop_sq); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_drop_sq); - __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} - __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_int); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (PyDict_SetItem(__pyx_3, __pyx_n_dtype, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_drop_sq); + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_bool); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (PyDict_SetItem(__pyx_4, __pyx_n_dtype, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; - if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5); + __pyx_5 = 0; + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_6); __pyx_6 = 0; + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_d_ndr)); - __pyx_v_d_ndr = ((PyArrayObject *)__pyx_4); - __pyx_4 = 0; + __pyx_v_d_ndr = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":453 */ - __pyx_v_d_dat = ((long (*))__pyx_v_d_ndr->data); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":454 */ - __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_d_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} - __pyx_4 = PyNumber_Subtract(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_4); - __pyx_2 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":474 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_d_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); + PyTuple_SET_ITEM(__pyx_2, 1, __pyx_5); __pyx_4 = 0; - __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_6 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_5 = 0; + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_6; ++__pyx_v_i) { + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_7 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_7; ++__pyx_v_i) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":455 */ - (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->drop_square[__pyx_v_i]) = (__pyx_v_d_dat[__pyx_v_i]); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":475 */ + __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; goto __pyx_L1;} + __pyx_4 = PyObject_GetItem(((PyObject *)__pyx_v_d_ndr), __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_8 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + (((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->_base->drop_square[__pyx_v_i]) = __pyx_8; } __pyx_r = 0; @@ -1765,6 +1821,7 @@ Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); __Pyx_AddTraceback("cloess.loess_model.drop_square_flags.__set__"); __pyx_r = -1; __pyx_L0:; @@ -1813,146 +1870,146 @@ __pyx_v_parametric = Py_None; Py_INCREF(Py_None); __pyx_v_drop_square = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":458 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":478 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} Py_INCREF(__pyx_n_family); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_family); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_family); __pyx_v_family = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":459 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":479 */ __pyx_4 = __pyx_v_family != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":460 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_family, __pyx_v_family) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":480 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_family, __pyx_v_family) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":462 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":482 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; goto __pyx_L1;} Py_INCREF(__pyx_n_span); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_span); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_span); __pyx_v_span = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":463 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":483 */ __pyx_4 = __pyx_v_span != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":464 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_span, __pyx_v_span) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":484 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_span, __pyx_v_span) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; goto __pyx_L1;} goto __pyx_L3; } __pyx_L3:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":466 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":486 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;} Py_INCREF(__pyx_n_degree); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_degree); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_degree); __pyx_v_degree = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":467 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":487 */ __pyx_4 = __pyx_v_degree != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":468 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_degree, __pyx_v_degree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":488 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_degree, __pyx_v_degree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; goto __pyx_L1;} goto __pyx_L4; } __pyx_L4:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":470 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":490 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; goto __pyx_L1;} Py_INCREF(__pyx_n_normalize); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_normalize); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_normalize); __pyx_v_normalize = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":471 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":491 */ __pyx_4 = __pyx_v_normalize != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":472 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_normalize, __pyx_v_normalize) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":492 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_normalize, __pyx_v_normalize) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;} goto __pyx_L5; } __pyx_L5:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":474 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":494 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} Py_INCREF(__pyx_n_parametric); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_parametric); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_parametric); __pyx_v_parametric = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":475 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":495 */ __pyx_4 = __pyx_v_parametric != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":476 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_parametric) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":496 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_parametric) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} goto __pyx_L6; } __pyx_L6:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":478 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":498 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; goto __pyx_L1;} Py_INCREF(__pyx_n_drop_square); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_drop_square); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_drop_square); __pyx_v_drop_square = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":479 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":499 */ __pyx_4 = __pyx_v_drop_square != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":480 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_drop_square_flags, __pyx_v_drop_square) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":500 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_drop_square_flags, __pyx_v_drop_square) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; goto __pyx_L1;} goto __pyx_L7; } __pyx_L7:; @@ -1981,9 +2038,9 @@ static PyObject *__pyx_n_id; -static PyObject *__pyx_k80p; +static PyObject *__pyx_k77p; -static char (__pyx_k80[]) = "loess model parameters @%s"; +static char (__pyx_k77[]) = "loess model parameters @%s"; static PyObject *__pyx_f_6cloess_11loess_model___repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_11loess_model___repr__(PyObject *__pyx_v_self) { @@ -1993,15 +2050,15 @@ PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":483 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":503 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;} Py_INCREF(__pyx_v_self); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyNumber_Remainder(__pyx_k80p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k77p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_1; __pyx_1 = 0; @@ -2020,23 +2077,23 @@ return __pyx_r; } +static PyObject *__pyx_k78p; +static PyObject *__pyx_k79p; +static PyObject *__pyx_k80p; static PyObject *__pyx_k81p; static PyObject *__pyx_k82p; static PyObject *__pyx_k83p; static PyObject *__pyx_k84p; static PyObject *__pyx_k85p; -static PyObject *__pyx_k86p; -static PyObject *__pyx_k87p; -static PyObject *__pyx_k88p; -static char (__pyx_k81[]) = "Model parameters....."; -static char (__pyx_k82[]) = "family : %s"; -static char (__pyx_k83[]) = "span : %s"; -static char (__pyx_k84[]) = "degree : %s"; -static char (__pyx_k85[]) = "normalized : %s"; -static char (__pyx_k86[]) = "parametric : %s"; -static char (__pyx_k87[]) = "drop_square : %s"; -static char (__pyx_k88[]) = "\n"; +static char (__pyx_k78[]) = "Model parameters....."; +static char (__pyx_k79[]) = "family : %s"; +static char (__pyx_k80[]) = "span : %s"; +static char (__pyx_k81[]) = "degree : %s"; +static char (__pyx_k82[]) = "normalized : %s"; +static char (__pyx_k83[]) = "parametric : %s"; +static char (__pyx_k84[]) = "drop_square : %s"; +static char (__pyx_k85[]) = "\n"; static PyObject *__pyx_f_6cloess_11loess_model___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_11loess_model___str__(PyObject *__pyx_v_self) { @@ -2052,32 +2109,32 @@ Py_INCREF(__pyx_v_self); __pyx_v_strg = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":486 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k82p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":506 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k79p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; goto __pyx_L1;} - __pyx_3 = PyNumber_Remainder(__pyx_k83p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k80p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; goto __pyx_L1;} - __pyx_4 = PyNumber_Remainder(__pyx_k84p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k81p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_normalize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; goto __pyx_L1;} - __pyx_5 = PyNumber_Remainder(__pyx_k85p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_normalize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k82p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_parametric_flags); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; goto __pyx_L1;} - __pyx_6 = PySequence_GetSlice(__pyx_1, 0, ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_parametric_flags); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; goto __pyx_L1;} + __pyx_6 = PySequence_GetSlice(__pyx_1, 0, ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyNumber_Remainder(__pyx_k86p, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k83p, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; - __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_drop_square_flags); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;} - __pyx_7 = PySequence_GetSlice(__pyx_6, 0, ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_drop_square_flags); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;} + __pyx_7 = PySequence_GetSlice(__pyx_6, 0, ((struct __pyx_obj_6cloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; - __pyx_6 = PyNumber_Remainder(__pyx_k87p, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;} + __pyx_6 = PyNumber_Remainder(__pyx_k84p, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;} Py_DECREF(__pyx_7); __pyx_7 = 0; - __pyx_7 = PyList_New(7); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;} - Py_INCREF(__pyx_k81p); - PyList_SET_ITEM(__pyx_7, 0, __pyx_k81p); + __pyx_7 = PyList_New(7); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; goto __pyx_L1;} + Py_INCREF(__pyx_k78p); + PyList_SET_ITEM(__pyx_7, 0, __pyx_k78p); PyList_SET_ITEM(__pyx_7, 1, __pyx_2); PyList_SET_ITEM(__pyx_7, 2, __pyx_3); PyList_SET_ITEM(__pyx_7, 3, __pyx_4); @@ -2094,12 +2151,12 @@ __pyx_v_strg = __pyx_7; __pyx_7 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":494 */ - __pyx_2 = PyObject_GetAttr(__pyx_k88p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":514 */ + __pyx_2 = PyObject_GetAttr(__pyx_k85p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;} Py_INCREF(__pyx_v_strg); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -2130,8 +2187,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":510 */ - __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->fitted_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":530 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->fitted_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2153,8 +2210,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":518 */ - __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->fitted_residuals); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":538 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->fitted_residuals); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2176,8 +2233,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":527 */ - __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->pseudovalues); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":547 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->pseudovalues); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2199,8 +2256,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":535 */ - __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->diagonal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":555 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->diagonal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2222,8 +2279,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":543 */ - __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->robust); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":563 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->robust); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2239,20 +2296,14 @@ return __pyx_r; } -static PyObject *__pyx_n_nvar; - static PyObject *__pyx_f_6cloess_13loess_outputs_7divisor___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_13loess_outputs_7divisor___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; - int __pyx_2; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":548 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_nvar); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;} - __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = __pyx_f_6cloess_floatarray_from_data(__pyx_2,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->divisor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":568 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->npar,1,((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->divisor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2274,8 +2325,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":556 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":576 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2297,8 +2348,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":564 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":584 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2320,8 +2371,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":572 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":592 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2343,8 +2394,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":580 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->two_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":600 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->two_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2366,8 +2417,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":588 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":608 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_outputs *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2391,23 +2442,23 @@ static PyObject *__pyx_n_two_delta; static PyObject *__pyx_n_divisor; +static PyObject *__pyx_k86p; +static PyObject *__pyx_k87p; +static PyObject *__pyx_k88p; static PyObject *__pyx_k89p; static PyObject *__pyx_k90p; static PyObject *__pyx_k91p; static PyObject *__pyx_k92p; static PyObject *__pyx_k93p; -static PyObject *__pyx_k94p; -static PyObject *__pyx_k95p; -static PyObject *__pyx_k96p; -static char (__pyx_k89[]) = "Outputs................"; -static char (__pyx_k90[]) = "Fitted values : %s\n"; -static char (__pyx_k91[]) = "Fitted residuals : %s\n"; -static char (__pyx_k92[]) = "Eqv. nb of parameters : %s"; -static char (__pyx_k93[]) = "Residual error : %s"; -static char (__pyx_k94[]) = "Deltas : %s - %s"; -static char (__pyx_k95[]) = "Normalization factors : %s"; -static char (__pyx_k96[]) = "\n"; +static char (__pyx_k86[]) = "Outputs................"; +static char (__pyx_k87[]) = "Fitted values : %s\n"; +static char (__pyx_k88[]) = "Fitted residuals : %s\n"; +static char (__pyx_k89[]) = "Eqv. nb of parameters : %s"; +static char (__pyx_k90[]) = "Residual error : %s"; +static char (__pyx_k91[]) = "Deltas : %s - %s"; +static char (__pyx_k92[]) = "Normalization factors : %s"; +static char (__pyx_k93[]) = "\n"; static PyObject *__pyx_f_6cloess_13loess_outputs___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_13loess_outputs___str__(PyObject *__pyx_v_self) { @@ -2423,34 +2474,34 @@ Py_INCREF(__pyx_v_self); __pyx_v_strg = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":591 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k90p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":611 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k87p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_residuals); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; goto __pyx_L1;} - __pyx_3 = PyNumber_Remainder(__pyx_k91p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_residuals); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k88p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;} - __pyx_4 = PyNumber_Remainder(__pyx_k92p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k89p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;} - __pyx_5 = PyNumber_Remainder(__pyx_k93p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k90p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;} - __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_two_delta); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;} - __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_two_delta); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; goto __pyx_L1;} + __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1); PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6); __pyx_1 = 0; __pyx_6 = 0; - __pyx_1 = PyNumber_Remainder(__pyx_k94p, __pyx_7); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k91p, __pyx_7); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; goto __pyx_L1;} Py_DECREF(__pyx_7); __pyx_7 = 0; - __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_divisor); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; goto __pyx_L1;} - __pyx_7 = PyNumber_Remainder(__pyx_k95p, __pyx_6); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_divisor); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; goto __pyx_L1;} + __pyx_7 = PyNumber_Remainder(__pyx_k92p, __pyx_6); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; - __pyx_6 = PyList_New(7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;} - Py_INCREF(__pyx_k89p); - PyList_SET_ITEM(__pyx_6, 0, __pyx_k89p); + __pyx_6 = PyList_New(7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;} + Py_INCREF(__pyx_k86p); + PyList_SET_ITEM(__pyx_6, 0, __pyx_k86p); PyList_SET_ITEM(__pyx_6, 1, __pyx_2); PyList_SET_ITEM(__pyx_6, 2, __pyx_3); PyList_SET_ITEM(__pyx_6, 3, __pyx_4); @@ -2467,12 +2518,12 @@ __pyx_v_strg = __pyx_6; __pyx_6 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":598 */ - __pyx_2 = PyObject_GetAttr(__pyx_k96p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":618 */ + __pyx_2 = PyObject_GetAttr(__pyx_k93p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;} Py_INCREF(__pyx_v_strg); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -2497,212 +2548,52 @@ return __pyx_r; } -static PyObject *__pyx_f_6cloess_11loess_anova_3dfn___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_11loess_anova_3dfn___get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_f_6cloess_14conf_intervals_setup(struct __pyx_obj_6cloess_conf_intervals *__pyx_v_self,conf_inv __pyx_v_base,long __pyx_v_nest) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":610 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->dfn); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":633 */ + __pyx_v_self->_base = __pyx_v_base; - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("cloess.loess_anova.dfn.__get__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static PyObject *__pyx_f_6cloess_11loess_anova_3dfd___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_11loess_anova_3dfd___get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - Py_INCREF(__pyx_v_self); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":614 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->dfd); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; goto __pyx_L1;} - __pyx_r = __pyx_1; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":634 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_self->fit)); + __pyx_v_self->fit = ((PyArrayObject *)__pyx_1); __pyx_1 = 0; - goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("cloess.loess_anova.dfd.__get__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static PyObject *__pyx_f_6cloess_11loess_anova_7F_value___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_11loess_anova_7F_value___get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - Py_INCREF(__pyx_v_self); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":618 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->F_value); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;} - __pyx_r = __pyx_1; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":635 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.upper); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_self->upper)); + __pyx_v_self->upper = ((PyArrayObject *)__pyx_1); __pyx_1 = 0; - goto __pyx_L0; - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("cloess.loess_anova.F_value.__get__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static PyObject *__pyx_f_6cloess_11loess_anova_4Pr_F___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_11loess_anova_4Pr_F___get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - Py_INCREF(__pyx_v_self); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":622 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_anova *)__pyx_v_self)->_base->Pr_F); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;} - __pyx_r = __pyx_1; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":636 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_self->lower)); + __pyx_v_self->lower = ((PyArrayObject *)__pyx_1); __pyx_1 = 0; - goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("cloess.loess_anova.Pr_F.__get__"); + __Pyx_AddTraceback("cloess.conf_intervals.setup"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } -static PyObject *__pyx_n_pw_free_mem; - -static void __pyx_f_6cloess_14conf_intervals___dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_f_6cloess_14conf_intervals___dealloc__(PyObject *__pyx_v_self) { - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - Py_INCREF(__pyx_v_self); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":632 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_c_loess); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_pw_free_mem); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;} - Py_INCREF(__pyx_v_self); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self); - __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("cloess.conf_intervals.__dealloc__"); - __pyx_L0:; - Py_DECREF(__pyx_v_self); -} - -static PyObject *__pyx_f_6cloess_14conf_intervals_3fit___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_14conf_intervals_3fit___get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - Py_INCREF(__pyx_v_self); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":640 */ - __pyx_1 = PyInt_AsLong(((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->nest); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} - __pyx_2 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,1,((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->_base.fit); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} - __pyx_r = __pyx_2; - __pyx_2 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("cloess.conf_intervals.fit.__get__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static PyObject *__pyx_f_6cloess_14conf_intervals_5upper___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_14conf_intervals_5upper___get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - Py_INCREF(__pyx_v_self); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":648 */ - __pyx_1 = PyInt_AsLong(((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->nest); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; goto __pyx_L1;} - __pyx_2 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,1,((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->_base.upper); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; goto __pyx_L1;} - __pyx_r = __pyx_2; - __pyx_2 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("cloess.conf_intervals.upper.__get__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static PyObject *__pyx_f_6cloess_14conf_intervals_5lower___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6cloess_14conf_intervals_5lower___get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - Py_INCREF(__pyx_v_self); - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":656 */ - __pyx_1 = PyInt_AsLong(((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->nest); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;} - __pyx_2 = __pyx_f_6cloess_floatarray_from_data(__pyx_1,1,((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->_base.lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;} - __pyx_r = __pyx_2; - __pyx_2 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("cloess.conf_intervals.lower.__get__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - static PyObject *__pyx_n_r_; -static PyObject *__pyx_n_fit; -static PyObject *__pyx_n_upper; static PyObject *__pyx_n_T; -static PyObject *__pyx_k97p; +static PyObject *__pyx_k94p; -static char (__pyx_k97[]) = "Confidence intervals....\nLower b./ fit / upper b.\n%s"; +static char (__pyx_k94[]) = "Confidence intervals....\nLower b./ fit / upper b.\n%s"; static PyObject *__pyx_f_6cloess_14conf_intervals___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_14conf_intervals___str__(PyObject *__pyx_v_self) { @@ -2711,39 +2602,34 @@ PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - PyObject *__pyx_5 = 0; Py_INCREF(__pyx_v_self); __pyx_v_tmp_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":660 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_r_); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":640 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_r_); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} - __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fit); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} - __pyx_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_upper); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} - __pyx_5 = PyList_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} - PyList_SET_ITEM(__pyx_5, 0, __pyx_1); - PyList_SET_ITEM(__pyx_5, 1, __pyx_3); - PyList_SET_ITEM(__pyx_5, 2, __pyx_4); - __pyx_1 = 0; - __pyx_3 = 0; - __pyx_4 = 0; - __pyx_1 = PyObject_GetItem(__pyx_2, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} + __pyx_1 = PyList_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->lower)); + PyList_SET_ITEM(__pyx_1, 0, ((PyObject *)((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->lower)); + Py_INCREF(((PyObject *)((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->fit)); + PyList_SET_ITEM(__pyx_1, 1, ((PyObject *)((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->fit)); + Py_INCREF(((PyObject *)((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->upper)); + PyList_SET_ITEM(__pyx_1, 2, ((PyObject *)((struct __pyx_obj_6cloess_conf_intervals *)__pyx_v_self)->upper)); + __pyx_3 = PyObject_GetItem(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_T); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_T); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_tmp_ndr)); - __pyx_v_tmp_ndr = ((PyArrayObject *)__pyx_3); - __pyx_3 = 0; + __pyx_v_tmp_ndr = ((PyArrayObject *)__pyx_2); + __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":661 */ - __pyx_4 = PyNumber_Remainder(__pyx_k97p, ((PyObject *)__pyx_v_tmp_ndr)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; goto __pyx_L1;} - __pyx_r = __pyx_4; - __pyx_4 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":641 */ + __pyx_1 = PyNumber_Remainder(__pyx_k94p, ((PyObject *)__pyx_v_tmp_ndr)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); @@ -2752,8 +2638,6 @@ Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - Py_XDECREF(__pyx_5); __Pyx_AddTraceback("cloess.conf_intervals.__str__"); __pyx_r = 0; __pyx_L0:; @@ -2766,20 +2650,35 @@ static void __pyx_f_6cloess_15loess_predicted___dealloc__(PyObject *__pyx_v_self) { Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":674 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":655 */ pred_free_mem((&((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base)); Py_DECREF(__pyx_v_self); } +static PyObject *__pyx_f_6cloess_15loess_predicted_setup(struct __pyx_obj_6cloess_loess_predicted *__pyx_v_self,prediction __pyx_v_base,long __pyx_v_nest) { + PyObject *__pyx_r; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":658 */ + __pyx_v_self->_base = __pyx_v_base; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":659 */ + __pyx_v_self->nest = __pyx_v_nest; + + __pyx_r = Py_None; Py_INCREF(Py_None); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + static PyObject *__pyx_f_6cloess_15loess_predicted_6values___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_15loess_predicted_6values___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":682 */ - __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base.fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":693 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base.fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2801,8 +2700,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":691 */ - __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base.se_fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":702 */ + __pyx_1 = __pyx_f_6cloess_floatarray_from_data(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base.se_fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2824,8 +2723,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":699 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base.residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":710 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base.residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2847,8 +2746,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":708 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base.df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":719 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base.df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2864,15 +2763,15 @@ return __pyx_r; } -static PyObject *__pyx_k98p; +static PyObject *__pyx_k95p; -static char (__pyx_k98[]) = "The coverage precentage should be between 0 and 1!"; +static char (__pyx_k95[]) = "The coverage precentage should be between 0 and 1!"; static PyObject *__pyx_f_6cloess_15loess_predicted_confidence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6cloess_15loess_predicted_confidence[] = "Returns the pointwise confidence intervals for each predicted values,\nat the given confidence interval coverage.\n \n:Parameters:\n coverage : float\n Confidence level of the confidence intervals limits, as a fraction.\n "; static PyObject *__pyx_f_6cloess_15loess_predicted_confidence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_coverage = 0; - conf_inv __pyx_v__conf_intv; + conf_inv __pyx_v__confintv; PyObject *__pyx_r; PyObject *__pyx_1 = 0; int __pyx_2; @@ -2880,21 +2779,21 @@ PyObject *__pyx_4 = 0; double __pyx_5; static char *__pyx_argnames[] = {"coverage",0}; - __pyx_v_coverage = __pyx_k35; + __pyx_v_coverage = __pyx_k32; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_coverage)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_coverage); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":719 */ - __pyx_1 = PyFloat_FromDouble(0.5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":730 */ + __pyx_1 = PyFloat_FromDouble(0.5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; goto __pyx_L1;} __pyx_2 = __pyx_2 < 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":720 */ - __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; goto __pyx_L1;} - __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_v_coverage); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":731 */ + __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;} + __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_v_coverage); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_v_coverage); __pyx_v_coverage = __pyx_3; @@ -2903,49 +2802,44 @@ } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":721 */ - __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":732 */ + __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} __pyx_2 = __pyx_2 > 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":722 */ - __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; goto __pyx_L1;} - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; goto __pyx_L1;} - Py_INCREF(__pyx_k98p); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k98p); - __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":733 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} + Py_INCREF(__pyx_k95p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k95p); + __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} goto __pyx_L3; } __pyx_L3:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":723 */ - __pyx_5 = PyFloat_AsDouble(__pyx_v_coverage); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; goto __pyx_L1;} - pointwise((&((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base),((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest,__pyx_5,(&__pyx_v__conf_intv)); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":734 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_coverage); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; goto __pyx_L1;} + pointwise((&((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->_base),((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest,__pyx_5,(&__pyx_v__confintv)); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":724 */ - __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_conf_intervals), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6cloess_conf_intervals)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":735 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_conf_intervals), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6cloess_conf_intervals)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals)); ((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals = ((struct __pyx_obj_6cloess_conf_intervals *)__pyx_3); __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":725 */ - ((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals->_base = __pyx_v__conf_intv; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":736 */ + __pyx_1 = ((struct __pyx_vtabstruct_6cloess_conf_intervals *)((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals->__pyx_vtab)->setup(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals,__pyx_v__confintv,((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":726 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;} - Py_DECREF(((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals->nest); - ((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals->nest = __pyx_1; - __pyx_1 = 0; - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":727 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":737 */ Py_INCREF(((PyObject *)((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals)); __pyx_r = ((PyObject *)((struct __pyx_obj_6cloess_loess_predicted *)__pyx_v_self)->confidence_intervals); goto __pyx_L0; @@ -2969,19 +2863,19 @@ static PyObject *__pyx_n_residual_scale; static PyObject *__pyx_n_df; +static PyObject *__pyx_k96p; +static PyObject *__pyx_k97p; +static PyObject *__pyx_k98p; static PyObject *__pyx_k99p; static PyObject *__pyx_k100p; static PyObject *__pyx_k101p; -static PyObject *__pyx_k102p; -static PyObject *__pyx_k103p; -static PyObject *__pyx_k104p; -static char (__pyx_k99[]) = "Outputs................"; -static char (__pyx_k100[]) = "Predicted values : %s\n"; -static char (__pyx_k101[]) = "Predicted std error : %s\n"; -static char (__pyx_k102[]) = "Residual scale : %s"; -static char (__pyx_k103[]) = "Degrees of freedom : %s"; -static char (__pyx_k104[]) = "\n"; +static char (__pyx_k96[]) = "Outputs................"; +static char (__pyx_k97[]) = "Predicted values : %s\n"; +static char (__pyx_k98[]) = "Predicted std error : %s\n"; +static char (__pyx_k99[]) = "Residual scale : %s"; +static char (__pyx_k100[]) = "Degrees of freedom : %s"; +static char (__pyx_k101[]) = "\n"; static PyObject *__pyx_f_6cloess_15loess_predicted___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6cloess_15loess_predicted___str__(PyObject *__pyx_v_self) { @@ -2995,22 +2889,22 @@ Py_INCREF(__pyx_v_self); __pyx_v_strg = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":730 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k100p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":740 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k97p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_stderr); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} - __pyx_3 = PyNumber_Remainder(__pyx_k101p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_stderr); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k98p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} - __pyx_4 = PyNumber_Remainder(__pyx_k102p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k99p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; goto __pyx_L1;} - __pyx_5 = PyNumber_Remainder(__pyx_k103p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k100p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyList_New(5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; goto __pyx_L1;} - Py_INCREF(__pyx_k99p); - PyList_SET_ITEM(__pyx_1, 0, __pyx_k99p); + __pyx_1 = PyList_New(5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; goto __pyx_L1;} + Py_INCREF(__pyx_k96p); + PyList_SET_ITEM(__pyx_1, 0, __pyx_k96p); PyList_SET_ITEM(__pyx_1, 1, __pyx_2); PyList_SET_ITEM(__pyx_1, 2, __pyx_3); PyList_SET_ITEM(__pyx_1, 3, __pyx_4); @@ -3023,12 +2917,12 @@ __pyx_v_strg = __pyx_1; __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":737 */ - __pyx_2 = PyObject_GetAttr(__pyx_k104p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":747 */ + __pyx_2 = PyObject_GetAttr(__pyx_k101p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;} Py_INCREF(__pyx_v_strg); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -3057,9 +2951,9 @@ static PyObject *__pyx_n_iteritems; static PyObject *__pyx_n_update; -static PyObject *__pyx_k113p; +static PyObject *__pyx_k110p; -static char (__pyx_k113[]) = "Incompatible size between the response array (%i) and the predictor array (%i)"; +static char (__pyx_k110[]) = "Incompatible size between the response array (%i) and the predictor array (%i)"; static int __pyx_f_6cloess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_f_6cloess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -3086,7 +2980,7 @@ int __pyx_6; long __pyx_7; static char *__pyx_argnames[] = {"x","y","weights",0}; - __pyx_v_weights = __pyx_k36; + __pyx_v_weights = __pyx_k33; if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 3, 0, &__pyx_v_options) < 0) return -1; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_weights)) { Py_XDECREF(__pyx_args); @@ -3107,268 +3001,262 @@ __pyx_v_k = Py_None; Py_INCREF(Py_None); __pyx_v_v = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":759 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":769 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} Py_INCREF(__pyx_v_x); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_x); - __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} - __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; - if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_x_ndr)); __pyx_v_x_ndr = ((PyArrayObject *)__pyx_4); __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":760 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":770 */ __pyx_v_x_dat = ((double (*))__pyx_v_x_ndr->data); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":761 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;} - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":771 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;} Py_INCREF(((PyObject *)__pyx_v_x_ndr)); - PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_x_ndr)); - __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_x_ndr)); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_v_n); __pyx_v_n = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":762 */ - __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_x_ndr), __pyx_n_size); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; goto __pyx_L1;} - __pyx_2 = PyNumber_Divide(__pyx_4, __pyx_v_n); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":772 */ + __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_x_ndr), __pyx_n_size); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} + __pyx_1 = PyNumber_Divide(__pyx_4, __pyx_v_n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_v_p); - __pyx_v_p = __pyx_2; - __pyx_2 = 0; + __pyx_v_p = __pyx_1; + __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":763 */ - __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":773 */ + __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;} ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->npar = __pyx_5; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":764 */ - __pyx_5 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":774 */ + __pyx_5 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;} ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->nobs = __pyx_5; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":766 */ - __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_p, __pyx_1, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":776 */ + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_p, __pyx_2, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;} __pyx_6 = __pyx_6 > 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; if (__pyx_6) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":767 */ - __pyx_3 = PyNumber_Multiply(__pyx_v_n, __pyx_v_p); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":777 */ + __pyx_3 = PyNumber_Multiply(__pyx_v_n, __pyx_v_p); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); __pyx_3 = 0; - if (PyObject_SetAttr(((PyObject *)__pyx_v_x_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_x_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":769 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":779 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} Py_INCREF(__pyx_v_y); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_y); - __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_y); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (PyDict_SetItem(__pyx_4, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - __pyx_2 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_y_ndr)); - __pyx_v_y_ndr = ((PyArrayObject *)__pyx_2); - __pyx_2 = 0; + __pyx_v_y_ndr = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":770 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":780 */ __pyx_v_y_dat = ((double (*))__pyx_v_y_ndr->data); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":771 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_y_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_v_n, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":781 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_y_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_v_n, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;} __pyx_6 = __pyx_6 != 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_6) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":772 */ - __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} - __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":782 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;} Py_INCREF(((PyObject *)__pyx_v_y_ndr)); - PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_y_ndr)); + PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_y_ndr)); Py_INCREF(__pyx_v_n); - PyTuple_SET_ITEM(__pyx_4, 1, __pyx_v_n); - __pyx_2 = PyNumber_Remainder(__pyx_k113p, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); - __pyx_2 = 0; - __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_n); + __pyx_4 = PyNumber_Remainder(__pyx_k110p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_4); + __pyx_4 = 0; + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} goto __pyx_L3; } __pyx_L3:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":775 */ - __pyx_5 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;} - __pyx_7 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":785 */ + __pyx_5 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;} + __pyx_7 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;} loess_setup(__pyx_v_x_dat,__pyx_v_y_dat,__pyx_5,__pyx_7,(&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base)); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":777 */ - __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_inputs), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_inputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":787 */ + __pyx_4 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_inputs), 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_6cloess_loess_inputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs)); - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs = ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_2); - __pyx_2 = 0; + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs = ((struct __pyx_obj_6cloess_loess_inputs *)__pyx_4); + __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":778 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":788 */ ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.inputs); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":780 */ - __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_model), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6cloess_loess_model)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":790 */ + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_model), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_model)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model)); - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model = ((struct __pyx_obj_6cloess_loess_model *)__pyx_3); - __pyx_3 = 0; + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model = ((struct __pyx_obj_6cloess_loess_model *)__pyx_2); + __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":781 */ - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.model); + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":791 */ + __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;} + __pyx_1 = ((struct __pyx_vtabstruct_6cloess_loess_model *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model->__pyx_vtab)->setup(((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model,(&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.model),__pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":782 */ - __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model->npar = __pyx_5; - - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":784 */ - __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_control), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_6cloess_loess_control)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":795 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_control), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6cloess_loess_control)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control)); - ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control = ((struct __pyx_obj_6cloess_loess_control *)__pyx_1); - __pyx_1 = 0; + ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control = ((struct __pyx_obj_6cloess_loess_control *)__pyx_3); + __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":785 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":796 */ ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.control); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":787 */ - __pyx_4 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_kd_tree), 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_6cloess_loess_kd_tree)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":798 */ + __pyx_4 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_kd_tree), 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_6cloess_loess_kd_tree)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree)); ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree = ((struct __pyx_obj_6cloess_loess_kd_tree *)__pyx_4); __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":788 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":799 */ ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->kd_tree->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.kd_tree); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":790 */ - __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_outputs), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_outputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":801 */ + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_outputs), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6cloess_loess_outputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs)); ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs = ((struct __pyx_obj_6cloess_loess_outputs *)__pyx_2); __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":791 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":802 */ ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->_base = (&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.outputs); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":792 */ - __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; goto __pyx_L1;} - __pyx_6 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":803 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;} + __pyx_6 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->activated = __pyx_6; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":793 */ - __pyx_7 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":804 */ + __pyx_7 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; goto __pyx_L1;} ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->nobs = __pyx_7; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":794 */ - __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":805 */ + __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;} ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->npar = __pyx_5; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":796 */ - __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":807 */ + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;} Py_DECREF(__pyx_v_modelopt); - __pyx_v_modelopt = __pyx_1; - __pyx_1 = 0; + __pyx_v_modelopt = __pyx_3; + __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":797 */ - __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":808 */ + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} Py_DECREF(__pyx_v_controlopt); __pyx_v_controlopt = __pyx_4; __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":798 */ - __pyx_2 = PyObject_GetAttr(__pyx_v_options, __pyx_n_iteritems); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} - __pyx_3 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":809 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_options, __pyx_n_iteritems); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyObject_GetIter(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_3 = PyObject_GetIter(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; for (;;) { - __pyx_4 = PyIter_Next(__pyx_1); + __pyx_4 = PyIter_Next(__pyx_3); if (!__pyx_4) { - if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} break; } - __pyx_2 = PyObject_GetIter(__pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + __pyx_2 = PyObject_GetIter(__pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_3 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + __pyx_1 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} Py_DECREF(__pyx_v_k); - __pyx_v_k = __pyx_3; - __pyx_3 = 0; - __pyx_4 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + __pyx_v_k = __pyx_1; + __pyx_1 = 0; + __pyx_4 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} Py_DECREF(__pyx_v_v); __pyx_v_v = __pyx_4; __pyx_4 = 0; - if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":799 */ - __pyx_3 = PyTuple_New(6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":810 */ + __pyx_1 = PyTuple_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;} Py_INCREF(__pyx_n_family); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_family); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_family); Py_INCREF(__pyx_n_span); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_n_span); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_span); Py_INCREF(__pyx_n_degree); - PyTuple_SET_ITEM(__pyx_3, 2, __pyx_n_degree); + PyTuple_SET_ITEM(__pyx_1, 2, __pyx_n_degree); Py_INCREF(__pyx_n_normalize); - PyTuple_SET_ITEM(__pyx_3, 3, __pyx_n_normalize); + PyTuple_SET_ITEM(__pyx_1, 3, __pyx_n_normalize); Py_INCREF(__pyx_n_parametric); - PyTuple_SET_ITEM(__pyx_3, 4, __pyx_n_parametric); + PyTuple_SET_ITEM(__pyx_1, 4, __pyx_n_parametric); Py_INCREF(__pyx_n_drop_square); - PyTuple_SET_ITEM(__pyx_3, 5, __pyx_n_drop_square); - __pyx_6 = PySequence_Contains(__pyx_3, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; + PyTuple_SET_ITEM(__pyx_1, 5, __pyx_n_drop_square); + __pyx_6 = PySequence_Contains(__pyx_1, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_6) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":801 */ - if (PyObject_SetItem(__pyx_v_modelopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":812 */ + if (PyObject_SetItem(__pyx_v_modelopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;} goto __pyx_L6; } - __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;} + __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;} Py_INCREF(__pyx_n_surface); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_surface); Py_INCREF(__pyx_n_statistics); @@ -3379,33 +3267,33 @@ PyTuple_SET_ITEM(__pyx_4, 3, __pyx_n_iterations); Py_INCREF(__pyx_n_cell); PyTuple_SET_ITEM(__pyx_4, 4, __pyx_n_cell); - __pyx_6 = PySequence_Contains(__pyx_4, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;} + __pyx_6 = PySequence_Contains(__pyx_4, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; if (__pyx_6) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":804 */ - if (PyObject_SetItem(__pyx_v_controlopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":815 */ + if (PyObject_SetItem(__pyx_v_controlopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} goto __pyx_L6; } __pyx_L6:; } - Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":805 */ - __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control), __pyx_n_update); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;} - __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;} - __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_3, __pyx_v_controlopt); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":816 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->control), __pyx_n_update); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_v_controlopt); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":806 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model), __pyx_n_update); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;} - __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;} - __pyx_3 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_2, __pyx_v_modelopt); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":817 */ + __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model), __pyx_n_update); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + __pyx_1 = PyEval_CallObjectWithKeywords(__pyx_3, __pyx_2, __pyx_v_modelopt); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = 0; goto __pyx_L0; @@ -3440,20 +3328,42 @@ PyObject *__pyx_r; PyObject *__pyx_1 = 0; int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; static char *__pyx_argnames[] = {0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":809 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":820 */ loess_fit((&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base)); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":810 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;} - __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":821 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;} + __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->activated = __pyx_2; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":811 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":822 */ + __pyx_2 = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.status.err_status; + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":823 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + __pyx_3 = PyString_FromString(((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":824 */ __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; @@ -3461,6 +3371,8 @@ goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); __Pyx_AddTraceback("cloess.loess.fit"); __pyx_r = 0; __pyx_L0:; @@ -3470,15 +3382,15 @@ static PyObject *__pyx_n_nobs; +static PyObject *__pyx_k122p; +static PyObject *__pyx_k123p; static PyObject *__pyx_k125p; static PyObject *__pyx_k126p; -static PyObject *__pyx_k128p; -static PyObject *__pyx_k129p; -static char (__pyx_k125[]) = "Number of Observations : %d"; -static char (__pyx_k126[]) = "Equivalent Number of Parameters: %.1f"; -static char (__pyx_k128[]) = "Residual Standard Error : %.4f"; -static char (__pyx_k129[]) = "Residual Scale Estimate : %.4f"; +static char (__pyx_k122[]) = "Number of Observations : %d"; +static char (__pyx_k123[]) = "Equivalent Number of Parameters: %.1f"; +static char (__pyx_k125[]) = "Residual Standard Error : %.4f"; +static char (__pyx_k126[]) = "Residual Scale Estimate : %.4f"; static PyObject *__pyx_f_6cloess_5loess_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6cloess_5loess_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -3490,47 +3402,47 @@ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":814 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs), __pyx_n_nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k125p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":827 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->inputs), __pyx_n_nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k122p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":815 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k126p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":828 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k123p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;} - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":816 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model), __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_n_gaussian, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":829 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->model), __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_n_gaussian, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; goto __pyx_L1;} __pyx_3 = __pyx_3 == 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_3) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":817 */ - __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} - __pyx_1 = PyNumber_Remainder(__pyx_k128p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":830 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k125p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;} goto __pyx_L2; } /*else*/ { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":819 */ - __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;} - __pyx_1 = PyNumber_Remainder(__pyx_k129p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":832 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k126p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} } __pyx_L2:; @@ -3549,17 +3461,17 @@ static PyObject *__pyx_n_ravel; static PyObject *__pyx_n_divmod; -static PyObject *__pyx_k134p; -static PyObject *__pyx_k135p; +static PyObject *__pyx_k131p; +static PyObject *__pyx_k132p; -static char (__pyx_k134[]) = "Can't predict without input data !"; -static char (__pyx_k135[]) = "Incompatible data size: there should be as many rows as parameters"; +static char (__pyx_k131[]) = "Can't predict without input data !"; +static char (__pyx_k132[]) = "Incompatible data size: there should be as many rows as parameters"; static PyObject *__pyx_f_6cloess_5loess_predict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6cloess_5loess_predict[] = "\n newdata: ndarray\n A (m,p) ndarray specifying the values of the predictors at which the \n evaluation is to be carried out.\n stderr: Boolean\n Logical flag for computing standard errors at newdata.\n "; static PyObject *__pyx_f_6cloess_5loess_predict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_newdata = 0; - PyObject *__pyx_v_stderr = 0; + PyObject *__pyx_v_stderror = 0; PyArrayObject *__pyx_v_p_ndr; double (*__pyx_v_p_dat); prediction __pyx_v__prediction; @@ -3571,154 +3483,192 @@ PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; - static char *__pyx_argnames[] = {"newdata","stderr",0}; - __pyx_v_stderr = __pyx_k37; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_newdata, &__pyx_v_stderr)) return 0; + static char *__pyx_argnames[] = {"newdata","stderror",0}; + __pyx_v_stderror = __pyx_k34; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_newdata, &__pyx_v_stderror)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_newdata); - Py_INCREF(__pyx_v_stderr); + Py_INCREF(__pyx_v_stderror); __pyx_v_p_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_notOK = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":834 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":847 */ __pyx_1 = (((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->activated == 0); if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":835 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":848 */ loess_fit((&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base)); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":836 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;} - __pyx_1 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":849 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;} + __pyx_1 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->outputs->activated = __pyx_1; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":850 */ + __pyx_1 = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.status.err_status; + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":851 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} + __pyx_3 = PyString_FromString(((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":838 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} - __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":853 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} Py_INCREF(__pyx_v_newdata); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_newdata); - __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} - __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_newdata); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - if (PyDict_SetItem(__pyx_4, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} - __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_3, __pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_ravel); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_ravel); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_2 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_p_ndr)); - __pyx_v_p_ndr = ((PyArrayObject *)__pyx_2); - __pyx_2 = 0; + __pyx_v_p_ndr = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":839 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":854 */ __pyx_v_p_dat = ((double (*))__pyx_v_p_ndr->data); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":841 */ - __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; goto __pyx_L1;} - __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_4, __pyx_5, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":856 */ + __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; goto __pyx_L1;} + __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_3, __pyx_5, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; goto __pyx_L1;} __pyx_1 = __pyx_1 == 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":842 */ - __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;} - Py_INCREF(__pyx_k134p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k134p); - __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":857 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} + Py_INCREF(__pyx_k131p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k131p); + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;} - goto __pyx_L3; + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} + goto __pyx_L4; } - __pyx_L3:; + __pyx_L4:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":843 */ - __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_divmod); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} - __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":858 */ + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_divmod); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} Py_INCREF(((PyObject *)__pyx_v_p_ndr)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_p_ndr)); - __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; + PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_p_ndr)); + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_3 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->npar); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3); - __pyx_4 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->npar); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2); __pyx_3 = 0; - __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + __pyx_2 = 0; + __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_3 = PyObject_GetIter(__pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_5 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} - __pyx_1 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + __pyx_2 = PyObject_GetIter(__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_1 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_v_m = __pyx_1; - __pyx_2 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + __pyx_4 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} Py_DECREF(__pyx_v_notOK); - __pyx_v_notOK = __pyx_2; - __pyx_2 = 0; - if (__Pyx_EndUnpack(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_v_notOK = __pyx_4; + __pyx_4 = 0; + if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":844 */ - __pyx_1 = PyObject_IsTrue(__pyx_v_notOK); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":859 */ + __pyx_1 = PyObject_IsTrue(__pyx_v_notOK); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":845 */ - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;} - __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;} - Py_INCREF(__pyx_k135p); - PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k135p); - __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":860 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} + Py_INCREF(__pyx_k132p); + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k132p); + __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - __Pyx_Raise(__pyx_2, 0, 0); - Py_DECREF(__pyx_2); __pyx_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;} - goto __pyx_L4; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} + goto __pyx_L5; } - __pyx_L4:; + __pyx_L5:; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":848 */ - __pyx_1 = PyInt_AsLong(__pyx_v_stderr); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":863 */ + __pyx_1 = PyInt_AsLong(__pyx_v_stderror); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; goto __pyx_L1;} predict(__pyx_v_p_dat,__pyx_v_m,(&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base),(&__pyx_v__prediction),__pyx_1); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":849 */ - __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_predicted), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6cloess_loess_predicted)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":864 */ + __pyx_1 = ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.status.err_status; + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":865 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} + __pyx_3 = PyString_FromString(((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3); + __pyx_3 = 0; + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":866 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6cloess_loess_predicted), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6cloess_loess_predicted)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted)); ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted = ((struct __pyx_obj_6cloess_loess_predicted *)__pyx_3); __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":850 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":867 */ ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted->_base = __pyx_v__prediction; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":851 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":868 */ ((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted->nest = __pyx_v_m; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":852 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":870 */ Py_INCREF(((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted)); __pyx_r = ((PyObject *)((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->predicted); goto __pyx_L0; @@ -3737,7 +3687,7 @@ Py_DECREF(__pyx_v_notOK); Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_newdata); - Py_DECREF(__pyx_v_stderr); + Py_DECREF(__pyx_v_stderror); return __pyx_r; } @@ -3745,21 +3695,290 @@ static void __pyx_f_6cloess_5loess___dealloc__(PyObject *__pyx_v_self) { Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":855 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":873 */ loess_free_mem((&((struct __pyx_obj_6cloess_loess *)__pyx_v_self)->_base)); Py_DECREF(__pyx_v_self); } +static PyObject *__pyx_n_isinstance; +static PyObject *__pyx_n_type; +static PyObject *__pyx_n_outputs; +static PyObject *__pyx_n_abs; + +static PyObject *__pyx_k133p; + +static char (__pyx_k133[]) = "Arguments should be valid loess objects!got '%s' instead"; + +static int __pyx_f_6cloess_5anova___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_6cloess_5anova___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_loess_one = 0; + PyObject *__pyx_v_loess_two = 0; + double __pyx_v_one_d1; + double __pyx_v_one_d2; + double __pyx_v_one_s; + double __pyx_v_two_d1; + double __pyx_v_two_d2; + double __pyx_v_two_s; + double __pyx_v_rssdiff; + double __pyx_v_d1diff; + double __pyx_v_tmp; + double __pyx_v_df1; + double __pyx_v_df2; + PyObject *__pyx_v_out_one; + PyObject *__pyx_v_out_two; + PyObject *__pyx_v_F_value; + int __pyx_r; + int __pyx_1; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + int __pyx_5; + PyObject *__pyx_6 = 0; + double __pyx_7; + static char *__pyx_argnames[] = {"loess_one","loess_two",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_loess_one, &__pyx_v_loess_two)) return -1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_loess_one); + Py_INCREF(__pyx_v_loess_two); + __pyx_v_out_one = Py_None; Py_INCREF(Py_None); + __pyx_v_out_two = Py_None; Py_INCREF(Py_None); + __pyx_v_F_value = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":887 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + Py_INCREF(__pyx_v_loess_one); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_loess_one); + Py_INCREF(((PyObject*)__pyx_ptype_6cloess_loess)); + PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_6cloess_loess)); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_1 = (!__pyx_5); + if (!__pyx_1) { + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + Py_INCREF(__pyx_v_loess_two); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_loess_two); + Py_INCREF(((PyObject*)__pyx_ptype_6cloess_loess)); + PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_6cloess_loess)); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_1 = (!__pyx_5); + } + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":888 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;} + Py_INCREF(__pyx_v_loess_one); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_loess_one); + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_3 = PyNumber_Remainder(__pyx_k133p, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_6, 0, 0); + Py_DECREF(__pyx_6); __pyx_6 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":891 */ + __pyx_3 = PyObject_GetAttr(__pyx_v_loess_one, __pyx_n_outputs); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;} + Py_DECREF(__pyx_v_out_one); + __pyx_v_out_one = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":892 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_loess_two, __pyx_n_outputs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; goto __pyx_L1;} + Py_DECREF(__pyx_v_out_two); + __pyx_v_out_two = __pyx_2; + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":894 */ + __pyx_4 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_one_delta); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_v_one_d1 = __pyx_7; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":895 */ + __pyx_6 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_two_delta); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_v_one_d2 = __pyx_7; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":896 */ + __pyx_3 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_s); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_v_one_s = __pyx_7; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":898 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_one_delta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_v_two_d1 = __pyx_7; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":899 */ + __pyx_4 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_two_delta); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_v_two_d2 = __pyx_7; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":900 */ + __pyx_6 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_s); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_v_two_s = __pyx_7; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":902 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + __pyx_2 = PyFloat_FromDouble((((__pyx_v_one_s * __pyx_v_one_s) * __pyx_v_one_d1) - ((__pyx_v_two_s * __pyx_v_two_s) * __pyx_v_two_d1))); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2); + __pyx_2 = 0; + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_v_rssdiff = __pyx_7; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":903 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} + __pyx_3 = PyFloat_FromDouble((__pyx_v_one_d1 - __pyx_v_two_d1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_v_d1diff = __pyx_7; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":904 */ + __pyx_3 = PyFloat_FromDouble((__pyx_v_d1diff * __pyx_v_d1diff)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + __pyx_4 = PyFloat_FromDouble((__pyx_v_one_d2 - __pyx_v_two_d2)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_6, 0, __pyx_4); + __pyx_4 = 0; + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_2 = PyNumber_Divide(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_7 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + ((struct __pyx_obj_6cloess_anova *)__pyx_v_self)->dfn = __pyx_7; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":905 */ + __pyx_v_df1 = ((struct __pyx_obj_6cloess_anova *)__pyx_v_self)->dfn; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":907 */ + __pyx_6 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_enp); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_enp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_6, __pyx_3, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;} + __pyx_5 = __pyx_5 > 0; + Py_DECREF(__pyx_6); __pyx_6 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__pyx_5) { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":908 */ + ((struct __pyx_obj_6cloess_anova *)__pyx_v_self)->dfd = ((__pyx_v_one_d1 * __pyx_v_one_d1) / __pyx_v_one_d2); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":909 */ + __pyx_v_tmp = __pyx_v_one_s; + goto __pyx_L3; + } + /*else*/ { + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":911 */ + ((struct __pyx_obj_6cloess_anova *)__pyx_v_self)->dfd = ((__pyx_v_two_d1 * __pyx_v_two_d1) / __pyx_v_two_d2); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":912 */ + __pyx_v_tmp = __pyx_v_two_s; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":913 */ + __pyx_v_df2 = ((struct __pyx_obj_6cloess_anova *)__pyx_v_self)->dfd; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":914 */ + __pyx_4 = PyFloat_FromDouble(((__pyx_v_rssdiff / __pyx_v_d1diff) / (__pyx_v_tmp * __pyx_v_tmp))); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; goto __pyx_L1;} + Py_DECREF(__pyx_v_F_value); + __pyx_v_F_value = __pyx_4; + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":916 */ + __pyx_2 = PyFloat_FromDouble(__pyx_v_df1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + __pyx_6 = PyNumber_Multiply(__pyx_v_F_value, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = PyFloat_FromDouble(__pyx_v_df2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + __pyx_4 = PyFloat_FromDouble(__pyx_v_df1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + __pyx_2 = PyNumber_Multiply(__pyx_v_F_value, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = PyNumber_Add(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = PyNumber_Divide(__pyx_6, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + ((struct __pyx_obj_6cloess_anova *)__pyx_v_self)->Pr_F = (1. - ibeta(__pyx_7,(__pyx_v_df1 / 2),(__pyx_v_df2 / 2))); + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":917 */ + __pyx_7 = PyFloat_AsDouble(__pyx_v_F_value); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;} + ((struct __pyx_obj_6cloess_anova *)__pyx_v_self)->F_value = __pyx_7; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_6); + __Pyx_AddTraceback("cloess.anova.__init__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_out_one); + Py_DECREF(__pyx_v_out_two); + Py_DECREF(__pyx_v_F_value); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_loess_one); + Py_DECREF(__pyx_v_loess_two); + return __pyx_r; +} + static __Pyx_InternTabEntry __pyx_intern_tab[] = { {&__pyx_n_C, "C"}, {&__pyx_n_False, "False"}, {&__pyx_n_T, "T"}, {&__pyx_n_True, "True"}, {&__pyx_n_ValueError, "ValueError"}, + {&__pyx_n_abs, "abs"}, {&__pyx_n_approximate, "approximate"}, {&__pyx_n_array, "array"}, {&__pyx_n_astype, "astype"}, + {&__pyx_n_atleast_1d, "atleast_1d"}, {&__pyx_n_bool, "bool"}, {&__pyx_n_c_loess, "c_loess"}, {&__pyx_n_c_numpy, "c_numpy"}, @@ -3777,30 +3996,29 @@ {&__pyx_n_enp, "enp"}, {&__pyx_n_exact, "exact"}, {&__pyx_n_family, "family"}, - {&__pyx_n_fit, "fit"}, {&__pyx_n_fitted_residuals, "fitted_residuals"}, {&__pyx_n_fitted_values, "fitted_values"}, {&__pyx_n_gaussian, "gaussian"}, {&__pyx_n_get, "get"}, {&__pyx_n_id, "id"}, - {&__pyx_n_int, "int"}, {&__pyx_n_interpolate, "interpolate"}, + {&__pyx_n_isinstance, "isinstance"}, {&__pyx_n_iterations, "iterations"}, {&__pyx_n_iteritems, "iteritems"}, {&__pyx_n_join, "join"}, {&__pyx_n_len, "len"}, {&__pyx_n_lower, "lower"}, {&__pyx_n_min, "min"}, + {&__pyx_n_narray, "narray"}, {&__pyx_n_ndim, "ndim"}, {&__pyx_n_nobs, "nobs"}, {&__pyx_n_normalize, "normalize"}, {&__pyx_n_numpy, "numpy"}, - {&__pyx_n_nvar, "nvar"}, {&__pyx_n_one_delta, "one_delta"}, {&__pyx_n_order, "order"}, + {&__pyx_n_outputs, "outputs"}, {&__pyx_n_parametric, "parametric"}, {&__pyx_n_parametric_flags, "parametric_flags"}, - {&__pyx_n_pw_free_mem, "pw_free_mem"}, {&__pyx_n_r_, "r_"}, {&__pyx_n_ravel, "ravel"}, {&__pyx_n_residual_scale, "residual_scale"}, @@ -3815,30 +4033,33 @@ {&__pyx_n_symmetric, "symmetric"}, {&__pyx_n_trace_hat, "trace_hat"}, {&__pyx_n_two_delta, "two_delta"}, + {&__pyx_n_type, "type"}, {&__pyx_n_update, "update"}, - {&__pyx_n_upper, "upper"}, {&__pyx_n_values, "values"}, {0, 0} }; static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_k35p, __pyx_k35, sizeof(__pyx_k35)}, {&__pyx_k38p, __pyx_k38, sizeof(__pyx_k38)}, - {&__pyx_k41p, __pyx_k41, sizeof(__pyx_k41)}, + {&__pyx_k39p, __pyx_k39, sizeof(__pyx_k39)}, {&__pyx_k42p, __pyx_k42, sizeof(__pyx_k42)}, {&__pyx_k45p, __pyx_k45, sizeof(__pyx_k45)}, - {&__pyx_k48p, __pyx_k48, sizeof(__pyx_k48)}, - {&__pyx_k49p, __pyx_k49, sizeof(__pyx_k49)}, - {&__pyx_k50p, __pyx_k50, sizeof(__pyx_k50)}, + {&__pyx_k46p, __pyx_k46, sizeof(__pyx_k46)}, + {&__pyx_k47p, __pyx_k47, sizeof(__pyx_k47)}, + {&__pyx_k53p, __pyx_k53, sizeof(__pyx_k53)}, + {&__pyx_k54p, __pyx_k54, sizeof(__pyx_k54)}, + {&__pyx_k55p, __pyx_k55, sizeof(__pyx_k55)}, {&__pyx_k56p, __pyx_k56, sizeof(__pyx_k56)}, {&__pyx_k57p, __pyx_k57, sizeof(__pyx_k57)}, {&__pyx_k58p, __pyx_k58, sizeof(__pyx_k58)}, {&__pyx_k59p, __pyx_k59, sizeof(__pyx_k59)}, {&__pyx_k60p, __pyx_k60, sizeof(__pyx_k60)}, {&__pyx_k61p, __pyx_k61, sizeof(__pyx_k61)}, - {&__pyx_k62p, __pyx_k62, sizeof(__pyx_k62)}, - {&__pyx_k63p, __pyx_k63, sizeof(__pyx_k63)}, {&__pyx_k64p, __pyx_k64, sizeof(__pyx_k64)}, - {&__pyx_k67p, __pyx_k67, sizeof(__pyx_k67)}, + {&__pyx_k77p, __pyx_k77, sizeof(__pyx_k77)}, + {&__pyx_k78p, __pyx_k78, sizeof(__pyx_k78)}, + {&__pyx_k79p, __pyx_k79, sizeof(__pyx_k79)}, {&__pyx_k80p, __pyx_k80, sizeof(__pyx_k80)}, {&__pyx_k81p, __pyx_k81, sizeof(__pyx_k81)}, {&__pyx_k82p, __pyx_k82, sizeof(__pyx_k82)}, @@ -3861,16 +4082,14 @@ {&__pyx_k99p, __pyx_k99, sizeof(__pyx_k99)}, {&__pyx_k100p, __pyx_k100, sizeof(__pyx_k100)}, {&__pyx_k101p, __pyx_k101, sizeof(__pyx_k101)}, - {&__pyx_k102p, __pyx_k102, sizeof(__pyx_k102)}, - {&__pyx_k103p, __pyx_k103, sizeof(__pyx_k103)}, - {&__pyx_k104p, __pyx_k104, sizeof(__pyx_k104)}, - {&__pyx_k113p, __pyx_k113, sizeof(__pyx_k113)}, + {&__pyx_k110p, __pyx_k110, sizeof(__pyx_k110)}, + {&__pyx_k122p, __pyx_k122, sizeof(__pyx_k122)}, + {&__pyx_k123p, __pyx_k123, sizeof(__pyx_k123)}, {&__pyx_k125p, __pyx_k125, sizeof(__pyx_k125)}, {&__pyx_k126p, __pyx_k126, sizeof(__pyx_k126)}, - {&__pyx_k128p, __pyx_k128, sizeof(__pyx_k128)}, - {&__pyx_k129p, __pyx_k129, sizeof(__pyx_k129)}, - {&__pyx_k134p, __pyx_k134, sizeof(__pyx_k134)}, - {&__pyx_k135p, __pyx_k135, sizeof(__pyx_k135)}, + {&__pyx_k131p, __pyx_k131, sizeof(__pyx_k131)}, + {&__pyx_k132p, __pyx_k132, sizeof(__pyx_k132)}, + {&__pyx_k133p, __pyx_k133, sizeof(__pyx_k133)}, {0, 0, 0} }; @@ -4403,9 +4622,12 @@ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ }; +static struct __pyx_vtabstruct_6cloess_loess_model __pyx_vtable_6cloess_loess_model; static PyObject *__pyx_tp_new_6cloess_loess_model(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_6cloess_loess_model *p = (struct __pyx_obj_6cloess_loess_model *)o; + *(struct __pyx_vtabstruct_6cloess_loess_model **)&p->__pyx_vtab = __pyx_vtabptr_6cloess_loess_model; return o; } @@ -4421,13 +4643,13 @@ return 0; } -static PyObject *__pyx_getprop_6cloess_11loess_model_span(PyObject *o, void *x) { - return __pyx_f_6cloess_11loess_model_4span___get__(o); +static PyObject *__pyx_getprop_6cloess_11loess_model_normalize(PyObject *o, void *x) { + return __pyx_f_6cloess_11loess_model_9normalize___get__(o); } -static int __pyx_setprop_6cloess_11loess_model_span(PyObject *o, PyObject *v, void *x) { +static int __pyx_setprop_6cloess_11loess_model_normalize(PyObject *o, PyObject *v, void *x) { if (v) { - return __pyx_f_6cloess_11loess_model_4span___set__(o, v); + return __pyx_f_6cloess_11loess_model_9normalize___set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); @@ -4435,13 +4657,13 @@ } } -static PyObject *__pyx_getprop_6cloess_11loess_model_degree(PyObject *o, void *x) { - return __pyx_f_6cloess_11loess_model_6degree___get__(o); +static PyObject *__pyx_getprop_6cloess_11loess_model_span(PyObject *o, void *x) { + return __pyx_f_6cloess_11loess_model_4span___get__(o); } -static int __pyx_setprop_6cloess_11loess_model_degree(PyObject *o, PyObject *v, void *x) { +static int __pyx_setprop_6cloess_11loess_model_span(PyObject *o, PyObject *v, void *x) { if (v) { - return __pyx_f_6cloess_11loess_model_6degree___set__(o, v); + return __pyx_f_6cloess_11loess_model_4span___set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); @@ -4449,13 +4671,13 @@ } } -static PyObject *__pyx_getprop_6cloess_11loess_model_normalize(PyObject *o, void *x) { - return __pyx_f_6cloess_11loess_model_9normalize___get__(o); +static PyObject *__pyx_getprop_6cloess_11loess_model_degree(PyObject *o, void *x) { + return __pyx_f_6cloess_11loess_model_6degree___get__(o); } -static int __pyx_setprop_6cloess_11loess_model_normalize(PyObject *o, PyObject *v, void *x) { +static int __pyx_setprop_6cloess_11loess_model_degree(PyObject *o, PyObject *v, void *x) { if (v) { - return __pyx_f_6cloess_11loess_model_9normalize___set__(o, v); + return __pyx_f_6cloess_11loess_model_6degree___set__(o, v); } else { PyErr_SetString(PyExc_NotImplementedError, "__del__"); @@ -4511,9 +4733,9 @@ }; static struct PyGetSetDef __pyx_getsets_6cloess_loess_model[] = { - {"span", __pyx_getprop_6cloess_11loess_model_span, __pyx_setprop_6cloess_11loess_model_span, __pyx_k9, 0}, - {"degree", __pyx_getprop_6cloess_11loess_model_degree, __pyx_setprop_6cloess_11loess_model_degree, __pyx_k10, 0}, - {"normalize", __pyx_getprop_6cloess_11loess_model_normalize, __pyx_setprop_6cloess_11loess_model_normalize, __pyx_k11, 0}, + {"normalize", __pyx_getprop_6cloess_11loess_model_normalize, __pyx_setprop_6cloess_11loess_model_normalize, __pyx_k9, 0}, + {"span", __pyx_getprop_6cloess_11loess_model_span, __pyx_setprop_6cloess_11loess_model_span, __pyx_k10, 0}, + {"degree", __pyx_getprop_6cloess_11loess_model_degree, __pyx_setprop_6cloess_11loess_model_degree, __pyx_k11, 0}, {"family", __pyx_getprop_6cloess_11loess_model_family, __pyx_setprop_6cloess_11loess_model_family, __pyx_k12, 0}, {"parametric_flags", __pyx_getprop_6cloess_11loess_model_parametric_flags, __pyx_setprop_6cloess_11loess_model_parametric_flags, __pyx_k13, 0}, {"drop_square_flags", __pyx_getprop_6cloess_11loess_model_drop_square_flags, __pyx_setprop_6cloess_11loess_model_drop_square_flags, __pyx_k14, 0}, @@ -4836,226 +5058,60 @@ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ }; +static struct __pyx_vtabstruct_6cloess_conf_intervals __pyx_vtable_6cloess_conf_intervals; -static PyObject *__pyx_tp_new_6cloess_loess_anova(PyTypeObject *t, PyObject *a, PyObject *k) { - PyObject *o = (*t->tp_alloc)(t, 0); - return o; -} - -static void __pyx_tp_dealloc_6cloess_loess_anova(PyObject *o) { - (*o->ob_type->tp_free)(o); -} - -static int __pyx_tp_traverse_6cloess_loess_anova(PyObject *o, visitproc v, void *a) { - return 0; -} - -static int __pyx_tp_clear_6cloess_loess_anova(PyObject *o) { - return 0; -} - -static PyObject *__pyx_getprop_6cloess_11loess_anova_dfn(PyObject *o, void *x) { - return __pyx_f_6cloess_11loess_anova_3dfn___get__(o); -} - -static PyObject *__pyx_getprop_6cloess_11loess_anova_dfd(PyObject *o, void *x) { - return __pyx_f_6cloess_11loess_anova_3dfd___get__(o); -} - -static PyObject *__pyx_getprop_6cloess_11loess_anova_F_value(PyObject *o, void *x) { - return __pyx_f_6cloess_11loess_anova_7F_value___get__(o); -} - -static PyObject *__pyx_getprop_6cloess_11loess_anova_Pr_F(PyObject *o, void *x) { - return __pyx_f_6cloess_11loess_anova_4Pr_F___get__(o); -} - -static struct PyMethodDef __pyx_methods_6cloess_loess_anova[] = { - {0, 0, 0, 0} -}; - -static struct PyGetSetDef __pyx_getsets_6cloess_loess_anova[] = { - {"dfn", __pyx_getprop_6cloess_11loess_anova_dfn, 0, 0, 0}, - {"dfd", __pyx_getprop_6cloess_11loess_anova_dfd, 0, 0, 0}, - {"F_value", __pyx_getprop_6cloess_11loess_anova_F_value, 0, 0, 0}, - {"Pr_F", __pyx_getprop_6cloess_11loess_anova_Pr_F, 0, 0, 0}, - {0, 0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_loess_anova = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - 0, /*nb_divide*/ - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - 0, /*nb_coerce*/ - 0, /*nb_int*/ - 0, /*nb_long*/ - 0, /*nb_float*/ - 0, /*nb_oct*/ - 0, /*nb_hex*/ - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - 0, /*nb_inplace_divide*/ - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ -}; - -static PySequenceMethods __pyx_tp_as_sequence_loess_anova = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_loess_anova = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_loess_anova = { - 0, /*bf_getreadbuffer*/ - 0, /*bf_getwritebuffer*/ - 0, /*bf_getsegcount*/ - 0, /*bf_getcharbuffer*/ -}; - -PyTypeObject __pyx_type_6cloess_loess_anova = { - PyObject_HEAD_INIT(0) - 0, /*ob_size*/ - "cloess.loess_anova", /*tp_name*/ - sizeof(struct __pyx_obj_6cloess_loess_anova), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_6cloess_loess_anova, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - &__pyx_tp_as_number_loess_anova, /*tp_as_number*/ - &__pyx_tp_as_sequence_loess_anova, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_loess_anova, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_loess_anova, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_6cloess_loess_anova, /*tp_traverse*/ - __pyx_tp_clear_6cloess_loess_anova, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_6cloess_loess_anova, /*tp_methods*/ - 0, /*tp_members*/ - __pyx_getsets_6cloess_loess_anova, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_6cloess_loess_anova, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ -}; - static PyObject *__pyx_tp_new_6cloess_conf_intervals(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); struct __pyx_obj_6cloess_conf_intervals *p = (struct __pyx_obj_6cloess_conf_intervals *)o; - p->nest = Py_None; Py_INCREF(Py_None); + *(struct __pyx_vtabstruct_6cloess_conf_intervals **)&p->__pyx_vtab = __pyx_vtabptr_6cloess_conf_intervals; + p->lower = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->fit = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->upper = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6cloess_conf_intervals(PyObject *o) { struct __pyx_obj_6cloess_conf_intervals *p = (struct __pyx_obj_6cloess_conf_intervals *)o; - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++o->ob_refcnt; - __pyx_f_6cloess_14conf_intervals___dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --o->ob_refcnt; - PyErr_Restore(etype, eval, etb); - } - Py_XDECREF(p->nest); + Py_XDECREF(((PyObject *)p->lower)); + Py_XDECREF(((PyObject *)p->fit)); + Py_XDECREF(((PyObject *)p->upper)); (*o->ob_type->tp_free)(o); } static int __pyx_tp_traverse_6cloess_conf_intervals(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_6cloess_conf_intervals *p = (struct __pyx_obj_6cloess_conf_intervals *)o; - if (p->nest) { - e = (*v)(p->nest, a); if (e) return e; + if (p->lower) { + e = (*v)(((PyObject*)p->lower), a); if (e) return e; } + if (p->fit) { + e = (*v)(((PyObject*)p->fit), a); if (e) return e; + } + if (p->upper) { + e = (*v)(((PyObject*)p->upper), a); if (e) return e; + } return 0; } static int __pyx_tp_clear_6cloess_conf_intervals(PyObject *o) { struct __pyx_obj_6cloess_conf_intervals *p = (struct __pyx_obj_6cloess_conf_intervals *)o; - Py_XDECREF(p->nest); - p->nest = Py_None; Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->lower)); + p->lower = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->fit)); + p->fit = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->upper)); + p->upper = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); return 0; } -static PyObject *__pyx_getprop_6cloess_14conf_intervals_fit(PyObject *o, void *x) { - return __pyx_f_6cloess_14conf_intervals_3fit___get__(o); -} - -static PyObject *__pyx_getprop_6cloess_14conf_intervals_upper(PyObject *o, void *x) { - return __pyx_f_6cloess_14conf_intervals_5upper___get__(o); -} - -static PyObject *__pyx_getprop_6cloess_14conf_intervals_lower(PyObject *o, void *x) { - return __pyx_f_6cloess_14conf_intervals_5lower___get__(o); -} - static struct PyMethodDef __pyx_methods_6cloess_conf_intervals[] = { {0, 0, 0, 0} }; -static struct PyGetSetDef __pyx_getsets_6cloess_conf_intervals[] = { - {"fit", __pyx_getprop_6cloess_14conf_intervals_fit, 0, __pyx_k26, 0}, - {"upper", __pyx_getprop_6cloess_14conf_intervals_upper, 0, __pyx_k27, 0}, - {"lower", __pyx_getprop_6cloess_14conf_intervals_lower, 0, __pyx_k28, 0}, +static struct PyMemberDef __pyx_members_6cloess_conf_intervals[] = { + {"lower", T_OBJECT, offsetof(struct __pyx_obj_6cloess_conf_intervals, lower), READONLY, 0}, + {"fit", T_OBJECT, offsetof(struct __pyx_obj_6cloess_conf_intervals, fit), READONLY, 0}, + {"upper", T_OBJECT, offsetof(struct __pyx_obj_6cloess_conf_intervals, upper), READONLY, 0}, {0, 0, 0, 0, 0} }; @@ -5156,8 +5212,8 @@ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6cloess_conf_intervals, /*tp_methods*/ - 0, /*tp_members*/ - __pyx_getsets_6cloess_conf_intervals, /*tp_getset*/ + __pyx_members_6cloess_conf_intervals, /*tp_members*/ + 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -5174,10 +5230,12 @@ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ }; +static struct __pyx_vtabstruct_6cloess_loess_predicted __pyx_vtable_6cloess_loess_predicted; static PyObject *__pyx_tp_new_6cloess_loess_predicted(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); struct __pyx_obj_6cloess_loess_predicted *p = (struct __pyx_obj_6cloess_loess_predicted *)o; + *(struct __pyx_vtabstruct_6cloess_loess_predicted **)&p->__pyx_vtab = __pyx_vtabptr_6cloess_loess_predicted; p->confidence_intervals = ((struct __pyx_obj_6cloess_conf_intervals *)Py_None); Py_INCREF(Py_None); return o; } @@ -5241,10 +5299,10 @@ }; static struct PyGetSetDef __pyx_getsets_6cloess_loess_predicted[] = { - {"values", __pyx_getprop_6cloess_15loess_predicted_values, 0, __pyx_k29, 0}, - {"stderr", __pyx_getprop_6cloess_15loess_predicted_stderr, 0, __pyx_k30, 0}, - {"residual_scale", __pyx_getprop_6cloess_15loess_predicted_residual_scale, 0, __pyx_k31, 0}, - {"df", __pyx_getprop_6cloess_15loess_predicted_df, 0, __pyx_k32, 0}, + {"values", __pyx_getprop_6cloess_15loess_predicted_values, 0, __pyx_k26, 0}, + {"stderr", __pyx_getprop_6cloess_15loess_predicted_stderr, 0, __pyx_k27, 0}, + {"residual_scale", __pyx_getprop_6cloess_15loess_predicted_residual_scale, 0, __pyx_k28, 0}, + {"df", __pyx_getprop_6cloess_15loess_predicted_df, 0, __pyx_k29, 0}, {0, 0, 0, 0, 0} }; @@ -5572,6 +5630,151 @@ 0, /*tp_weaklist*/ }; +static PyObject *__pyx_tp_new_6cloess_anova(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + return o; +} + +static void __pyx_tp_dealloc_6cloess_anova(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6cloess_anova(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_6cloess_anova(PyObject *o) { + return 0; +} + +static struct PyMethodDef __pyx_methods_6cloess_anova[] = { + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_6cloess_anova[] = { + {"dfn", T_DOUBLE, offsetof(struct __pyx_obj_6cloess_anova, dfn), READONLY, 0}, + {"dfd", T_DOUBLE, offsetof(struct __pyx_obj_6cloess_anova, dfd), READONLY, 0}, + {"F_value", T_DOUBLE, offsetof(struct __pyx_obj_6cloess_anova, F_value), READONLY, 0}, + {"Pr_F", T_DOUBLE, offsetof(struct __pyx_obj_6cloess_anova, Pr_F), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_anova = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_anova = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_anova = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_anova = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6cloess_anova = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "cloess.anova", /*tp_name*/ + sizeof(struct __pyx_obj_6cloess_anova), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6cloess_anova, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_anova, /*tp_as_number*/ + &__pyx_tp_as_sequence_anova, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_anova, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_anova, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6cloess_anova, /*tp_traverse*/ + __pyx_tp_clear_6cloess_anova, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6cloess_anova, /*tp_methods*/ + __pyx_members_6cloess_anova, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_f_6cloess_5anova___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6cloess_anova, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + static struct PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; @@ -5590,36 +5793,45 @@ if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; - if (PyType_Ready(&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_inputs", (PyObject *)&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_inputs", (PyObject *)&__pyx_type_6cloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;} __pyx_ptype_6cloess_loess_inputs = &__pyx_type_6cloess_loess_inputs; - if (PyType_Ready(&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_control", (PyObject *)&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_control", (PyObject *)&__pyx_type_6cloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;} __pyx_ptype_6cloess_loess_control = &__pyx_type_6cloess_loess_control; - if (PyType_Ready(&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_kd_tree", (PyObject *)&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_kd_tree", (PyObject *)&__pyx_type_6cloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; goto __pyx_L1;} __pyx_ptype_6cloess_loess_kd_tree = &__pyx_type_6cloess_loess_kd_tree; - if (PyType_Ready(&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_model", (PyObject *)&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; goto __pyx_L1;} + __pyx_vtabptr_6cloess_loess_model = &__pyx_vtable_6cloess_loess_model; + *(void(**)())&__pyx_vtable_6cloess_loess_model.setup = (void(*)())__pyx_f_6cloess_11loess_model_setup; + if (PyType_Ready(&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_6cloess_loess_model.tp_dict, __pyx_vtabptr_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_model", (PyObject *)&__pyx_type_6cloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} __pyx_ptype_6cloess_loess_model = &__pyx_type_6cloess_loess_model; - if (PyType_Ready(&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_outputs", (PyObject *)&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_outputs", (PyObject *)&__pyx_type_6cloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;} __pyx_ptype_6cloess_loess_outputs = &__pyx_type_6cloess_loess_outputs; - if (PyType_Ready(&__pyx_type_6cloess_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_anova", (PyObject *)&__pyx_type_6cloess_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; goto __pyx_L1;} - __pyx_ptype_6cloess_loess_anova = &__pyx_type_6cloess_loess_anova; + __pyx_vtabptr_6cloess_conf_intervals = &__pyx_vtable_6cloess_conf_intervals; + *(void(**)())&__pyx_vtable_6cloess_conf_intervals.setup = (void(*)())__pyx_f_6cloess_14conf_intervals_setup; __pyx_type_6cloess_conf_intervals.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6cloess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "conf_intervals", (PyObject *)&__pyx_type_6cloess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_6cloess_conf_intervals.tp_dict, __pyx_vtabptr_6cloess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "conf_intervals", (PyObject *)&__pyx_type_6cloess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; goto __pyx_L1;} __pyx_ptype_6cloess_conf_intervals = &__pyx_type_6cloess_conf_intervals; + __pyx_vtabptr_6cloess_loess_predicted = &__pyx_vtable_6cloess_loess_predicted; + *(void(**)())&__pyx_vtable_6cloess_loess_predicted.setup = (void(*)())__pyx_f_6cloess_15loess_predicted_setup; __pyx_type_6cloess_loess_predicted.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6cloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_predicted", (PyObject *)&__pyx_type_6cloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_6cloess_loess_predicted.tp_dict, __pyx_vtabptr_6cloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_predicted", (PyObject *)&__pyx_type_6cloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;} __pyx_ptype_6cloess_loess_predicted = &__pyx_type_6cloess_loess_predicted; __pyx_type_6cloess_loess.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess", (PyObject *)&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess", (PyObject *)&__pyx_type_6cloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; goto __pyx_L1;} __pyx_ptype_6cloess_loess = &__pyx_type_6cloess_loess; + if (PyType_Ready(&__pyx_type_6cloess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "anova", (PyObject *)&__pyx_type_6cloess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; goto __pyx_L1;} + __pyx_ptype_6cloess_anova = &__pyx_type_6cloess_anova; __pyx_ptype_7c_numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (!__pyx_ptype_7c_numpy_dtype) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; goto __pyx_L1;} __pyx_ptype_7c_numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (!__pyx_ptype_7c_numpy_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 81; goto __pyx_L1;} __pyx_ptype_7c_numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject)); if (!__pyx_ptype_7c_numpy_flatiter) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 90; goto __pyx_L1;} @@ -5630,27 +5842,34 @@ if (PyObject_SetAttr(__pyx_m, __pyx_n_numpy, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":15 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":9 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (PyObject_SetAttr(__pyx_m, __pyx_n_narray, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":12 */ import_array(); - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":48 */ - __pyx_k34; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":73 */ + __pyx_k31; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":710 */ - __pyx_1 = PyFloat_FromDouble(0.95); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;} - __pyx_k35 = __pyx_1; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":721 */ + __pyx_1 = PyFloat_FromDouble(0.95); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;} + __pyx_k32 = __pyx_1; __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":753 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":763 */ Py_INCREF(Py_None); - __pyx_k36 = Py_None; + __pyx_k33 = Py_None; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":821 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;} - __pyx_k37 = __pyx_2; + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":834 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; goto __pyx_L1;} + __pyx_k34 = __pyx_2; __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":854 */ + /* "/home/backtopop/workspace/pyloess_c/src/cloess.pyx":883 */ return; __pyx_L1:; Py_XDECREF(__pyx_1); @@ -5940,6 +6159,25 @@ return 0; } +static int __Pyx_SetVtable(PyObject *dict, void *vtable) { + PyObject *pycobj = 0; + int result; + + pycobj = PyCObject_FromVoidPtr(vtable, 0); + if (!pycobj) + goto bad; + if (PyDict_SetItemString(dict, "__pyx_vtable__", pycobj) < 0) + goto bad; + result = 0; + goto done; + +bad: + result = -1; +done: + Py_XDECREF(pycobj); + return result; +} + static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size) { Modified: trunk/Lib/sandbox/pyloess/sandbox/src/cloess.h =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/cloess.h 2007-03-16 20:42:51 UTC (rev 2849) +++ trunk/Lib/sandbox/pyloess/sandbox/src/cloess.h 2007-03-19 23:50:21 UTC (rev 2850) @@ -4,15 +4,18 @@ // from loess.c void loess_setup(double *x, double *y, int n, int p, loess *lo); -void loess_fit(loess *lo); +char loess_fit(loess *lo); void loess_free_mem(loess *lo); void loess_summary(loess *lo); // from misc.c -void anova(loess *one, loess *two, anova_struct *out); -void pointwise(prediction *pre, int m, double coverage, conf_inv *ci); +void pointwise(prediction *pre, int m, double coverage, conf_inv *ci); void pw_free_mem(conf_inv *ci); +double pf(double q, double df1, double df2); +double ibeta(double x, double a, double b); //// // from predict.c void predict(double *eval, int m, loess *lo, prediction *pre, int se); void pred_free_mem(prediction *pre); +// + Modified: trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx 2007-03-16 20:42:51 UTC (rev 2849) +++ trunk/Lib/sandbox/pyloess/sandbox/src/cloess.pyx 2007-03-19 23:50:21 UTC (rev 2850) @@ -6,26 +6,18 @@ NPY_INT, NPY_DOUBLE, NPY_OWNDATA, NPY_ALIGNED, NPY_FORTRAN, \ PyArray_SimpleNewFromData import numpy +narray = numpy.array -#narray = _N.array -#ndouble = _N.float -#nbool = _N.bool - # NumPy must be initialized c_numpy.import_array() cimport c_loess - cdef floatarray_from_data(int rows, int cols, double *data): cdef ndarray a_ndr cdef npy_intp size size = rows*cols a_ndr = PyArray_SimpleNewFromData(1, &size, NPY_DOUBLE, data) -# a_ndr = numpy.empty((rows*cols,), dtype=numpy.float) -# a_dat = a_ndr.data -# for i from 0 <= i < a_ndr.size: -# a_dat[i] = data[i] if cols > 1: a_ndr.shape = (rows, cols) return a_ndr @@ -34,17 +26,50 @@ cdef ndarray a_ndr cdef npy_intp size size = rows*cols -# cdef int *a_dat -# a_ndr = numpy.empty((rows*cols,), dtype=numpy.int) a_ndr = PyArray_SimpleNewFromData(1, &size, NPY_DOUBLE, data) -# a_dat = a_ndr.data -# for i from 0 <= i < a_ndr.size: -# a_dat[i] = data[i] if cols > 1: a_ndr.shape = (rows, cols) return a_ndr.astype(numpy.bool) +##cimport modelflags +##import modelflags +# +#cdef list_to_clist(object p_list): +# cdef int i, imax +# p_list = list(p_list) +# imax = min(8, len(p_list)) +# for i from 0 <= i < imax: +# c_list[i] = p_list[i] +# return c_list[0] +#cdef object clist_to_list(int c_list[8]): +# cdef int i, imax +# p_list = [False] * 8 +# imax = min(8, len(p_list)) +# for i from 0 <= i < imax: +# p_list[i] = c_list[i] +# return p_list +# +# +#class modelflags: +# def __init__(self): +# self.str_list = [False] * 8 +# self.c_list = list_to_clist(self.str_list) +# def __getitem__(self, idx): +# return self.str_list[idx] +# def __setitem__(self, idx, val): +# cdef int tmpval +# tmpval = val +# self.c_list[idx] = tmpval +# self.str_list[idx] = bool(val) +# def __str__(self): +# return str(self.str_list) +# +##class modelflags(c_modelflags): +## def __init__(self): +## c_modelflags.__init__(self) +## + """ :Keywords: x : ndarray @@ -334,35 +359,47 @@ ######--------------------------------------------------------------------------- cdef class loess_kd_tree: cdef c_loess.c_loess_kd_tree *_base -# #......... -# property parameter: -# def __get__(self): -# return self._base.parameter -# #......... -# property a: -# def __get__(self): -# return self._base.a -# #......... -# property vval: -# def __get__(self): -# return self._base.vert -# #......... -# property xi: -# def __get__(self): -# return self._base.xi -# #......... -# property vert: -# def __get__(self): -# return self._base.vert -# return -# + ######--------------------------------------------------------------------------- ##---- ---- loess model --- ######--------------------------------------------------------------------------- cdef class loess_model: cdef c_loess.c_loess_model *_base cdef long npar +# cdef public double span +# cdef public int degree +# cdef public char *family +# cdef public parametric_mflags, drop_square_mflags #......... + cdef setup(self, c_loess.c_loess_model *base, long npar): + self._base = base + self.npar = npar +# self.parametric_flags = modelflags() +# self.parametric_flags.c_list[0] = base.parametric[0] +# self.drop_square_flags = modelflags() +# self.drop_square_flags.c_list[0] = base.drop_square[0] +# self.span = self._base.span +# self.degree = self._base.degree +# self.family = self._base.family +# self.parametric_flags = boolarray_from_data(self.npar, 1, self._base.parametric) +# self.drop_square_flags = boolarray_from_data(self.npar, 1, self._base.drop_square) + return self + #......... + property normalize: + """ + normalize : boolean [True] + Determines whether the independent variables should be normalized. + If True, the normalization is performed by setting the 10% trimmed + standard deviation to one. If False, no normalization is carried out. + This option is only useful for more than one variable. For spatial + coordinates predictors or variables with a common scale, it should be + set to False. + """ + def __get__(self): + return bool(self._base.normalize) + def __set__(self, normalize): + self._base.normalize = normalize + #......... property span: """Smoothing factor, as a fraction of the number of points to take into account. By default, span=0.75.""" @@ -385,21 +422,6 @@ if degree < 0 or degree > 2: raise ValueError("Degree should be between 0 and 2!") #......... - property normalize: - """ - normalize : boolean [True] - Determines whether the independent variables should be normalized. - If True, the normalization is performed by setting the 10% trimmed - standard deviation to one. If False, no normalization is carried out. - This option is only useful for more than one variable. For spatial - coordinates predictors or variables with a common scale, it should be - set to False. - """ - def __get__(self): - return bool(self._base.normalize) - def __set__(self, normalize): - self._base.normalize = normalize - #......... property family: """ family : string ["gaussian"] @@ -428,12 +450,11 @@ return boolarray_from_data(self.npar, 1, self._base.parametric) def __set__(self, paramf): cdef ndarray p_ndr - cdef long *p_dat cdef int i - p_ndr = numpy.array(paramf, copy=False, subok=True, dtype=numpy.int) - p_dat = p_ndr.data - for i from 0 <= i < min(self.npar, p_ndr.size - 1): - self._base.parametric[i] = p_dat[i] + p_ndr = numpy.atleast_1d(narray(paramf, copy=False, subok=True, + dtype=numpy.bool)) + for i from 0 <= i < min(self.npar, p_ndr.size): + self._base.parametric[i] = p_ndr[i] #......... property drop_square_flags: """ @@ -447,12 +468,11 @@ return boolarray_from_data(self.npar, 1, self._base.drop_square) def __set__(self, drop_sq): cdef ndarray d_ndr - cdef long *d_dat cdef int i - d_ndr = numpy.array(drop_sq, copy=False, subok=True, dtype=numpy.int) - d_dat = d_ndr.data - for i from 0 <= i < min(self.npar, d_ndr.size - 1): - self._base.drop_square[i] = d_dat[i] + d_ndr = numpy.atleast_1d(narray(drop_sq, copy=False, subok=True, + dtype=numpy.bool)) + for i from 0 <= i < min(self.npar, d_ndr.size): + self._base.drop_square[i] = d_ndr[i] #........ def update(self, **modelargs): family = modelargs.get('family', None) @@ -545,7 +565,7 @@ property divisor: "Equivalent number of parameters." def __get__(self): - return floatarray_from_data(self.nvar, 1, self._base.divisor) + return floatarray_from_data(self.npar, 1, self._base.divisor) #......... property enp: """ @@ -585,7 +605,7 @@ Trace of the operator hat matrix. """ def __get__(self): - return self._base.trace_hat # "" + return self._base.trace_hat #......... def __str__(self): strg = ["Outputs................", @@ -598,63 +618,23 @@ return '\n'.join(strg) -#####--------------------------------------------------------------------------- -#---- ---- loess anova --- -#####--------------------------------------------------------------------------- -cdef class loess_anova: - cdef c_loess.c_anova *_base - cdef long nest - #......... - property dfn: - def __get__(self): - return self._base.dfn - #......... - property dfd: - def __get__(self): - return self._base.dfd - #......... - property F_value: - def __get__(self): - return self._base.F_value - #......... - property Pr_F: - def __get__(self): - return self._base.Pr_F #####--------------------------------------------------------------------------- #---- ---- loess confidence --- #####--------------------------------------------------------------------------- cdef class conf_intervals: cdef c_loess.c_conf_inv _base - cdef nest + cdef readonly ndarray lower, fit, upper #......... - def __dealloc__(self): - c_loess.pw_free_mem(self) +# def __dealloc__(self): +# c_loess.pw_free_mem(self._base) #......... - property fit: - """ - fit : ndarray - The (m,) ndarray of estimated values - """ - def __get__(self): - return floatarray_from_data(self.nest, 1, self._base.fit) + cdef setup(self, c_loess.c_conf_inv base, long nest): + self._base = base + self.fit = floatarray_from_data(nest, 1, base.fit) + self.upper = floatarray_from_data(nest, 1, base.upper) + self.lower = floatarray_from_data(nest, 1, base.lower) #......... - property upper: - """ - upper : ndarray - The (m,) ndarray of the upper limits of the pointwise confidence intervals. - """ - def __get__(self): - return floatarray_from_data(self.nest, 1, self._base.upper) - #......... - property lower: - """ - lower : ndarray - The (m,) ndarray of the lower limits of the pointwise confidence intervals. - """ - def __get__(self): - return floatarray_from_data(self.nest, 1, self._base.lower) - #......... def __str__(self): cdef ndarray tmp_ndr tmp_ndr = numpy.r_[[self.lower,self.fit,self.upper]].T @@ -668,11 +648,42 @@ cdef c_loess.c_prediction _base cdef readonly long nest cdef readonly conf_intervals confidence_intervals - +# cdef readonly ndarray values, stderr +# cdef readonly double residual_scale, df #......... def __dealloc__(self): c_loess.pred_free_mem(&self._base) #......... + cdef setup(self, c_loess.c_prediction base, long nest): + self._base = base + self.nest = nest +# cdef setup(self, c_loess.c_loess loess_base, object newdata, stderror): +# cdef ndarray p_ndr +# cdef double *p_dat +# cdef c_loess.c_prediction _prediction +# cdef int i, m +# # +# # Note : we need a copy as we may have to normalize +# p_ndr = narray(newdata, copy=True, subok=True, order='C').ravel() +# p_dat = p_ndr.data +# # Test the compatibility of sizes ....... +# if p_ndr.size == 0: +# raise ValueError("Can't predict without input data !") +# (m, notOK) = divmod(len(p_ndr), loess_base.inputs.p) +# if notOK: +# raise ValueError( +# "Incompatible data size: there should be as many rows as parameters") +# #..... +# c_loess.c_predict(p_dat, m, &loess_base, &_prediction, stderror) +# if loess_base.status.err_status: +# raise ValueError(loess_base.status.err_msg) +# self._base = _prediction +# self.nest = m +## self.values = floatarray_from_data(m, 1, _prediction.fit) +## self.stderr = floatarray_from_data(m, 1, _prediction.se_fit) +## self.residual_scale = _prediction.residual_scale +## self.df = _prediction.df + #......... property values: """ values : ndarray @@ -705,7 +716,7 @@ confidence intervals for the evaluated surface. """ def __get__(self): - return self._base.df + return self._base.df #......... def confidence(self, coverage=0.95): """Returns the pointwise confidence intervals for each predicted values, @@ -715,15 +726,14 @@ coverage : float Confidence level of the confidence intervals limits, as a fraction. """ - cdef c_loess.c_conf_inv _conf_intv + cdef c_loess.c_conf_inv _confintv if coverage < 0.5: coverage = 1. - coverage if coverage > 1. : raise ValueError("The coverage precentage should be between 0 and 1!") - c_loess.pointwise(&self._base, self.nest, coverage, &_conf_intv) + c_loess.c_pointwise(&self._base, self.nest, coverage, &_confintv) self.confidence_intervals = conf_intervals() - self.confidence_intervals._base = _conf_intv - self.confidence_intervals.nest = self.nest + self.confidence_intervals.setup(_confintv, self.nest) return self.confidence_intervals #......... def __str__(self): @@ -756,7 +766,7 @@ cdef double *x_dat, *y_dat cdef int i # Get the predictor array - x_ndr = numpy.array(x, copy=True, subok=True, order='C') + x_ndr = narray(x, copy=True, subok=True, order='C') x_dat = x_ndr.data n = len(x_ndr) p = x_ndr.size / n @@ -766,7 +776,7 @@ if p > 1: x_ndr.shape = (n*p,) # Get the response array ...... - y_ndr = numpy.array(y, copy=False, subok=True, order='C') + y_ndr = narray(y, copy=False, subok=True, order='C') y_dat = y_ndr.data if y_ndr.size != n: raise ValueError("Incompatible size between the response array (%i)"\ @@ -778,8 +788,9 @@ self.inputs._base = &self._base.inputs # self.model = loess_model() - self.model._base = &self._base.model - self.model.npar = p + self.model.setup(&self._base.model, p) +# self.model._base = &self._base.model +# self.model.npar = p # self.control = loess_control() self.control._base = &self._base.control @@ -808,6 +819,8 @@ def fit(self): c_loess.loess_fit(&self._base) self.outputs.activated = True + if self._base.status.err_status: + raise ValueError(self._base.status.err_msg) return #...................................................... def summary(self): @@ -818,7 +831,7 @@ else: print "Residual Scale Estimate : %.4f" % self.outputs.s #...................................................... - def predict(self, newdata, stderr=False): + def predict(self, newdata, stderror=False): """ newdata: ndarray A (m,p) ndarray specifying the values of the predictors at which the @@ -834,8 +847,10 @@ if self.outputs.activated == 0: c_loess.loess_fit(&self._base) self.outputs.activated = True + if self._base.status.err_status: + raise ValueError(self._base.status.err_msg) # Note : we need a copy as we may have to normalize - p_ndr = numpy.array(newdata, copy=True, subok=True, order='C').ravel() + p_ndr = narray(newdata, copy=True, subok=True, order='C').ravel() p_dat = p_ndr.data # Test the compatibility of sizes ....... if p_ndr.size == 0: @@ -845,10 +860,13 @@ raise ValueError( "Incompatible data size: there should be as many rows as parameters") #..... - c_loess.predict(p_dat, m, &self._base, &_prediction, stderr) + c_loess.c_predict(p_dat, m, &self._base, &_prediction, stderror) + if self._base.status.err_status: + raise ValueError(self._base.status.err_msg) self.predicted = loess_predicted() self.predicted._base = _prediction self.predicted.nest = m +# self.predicted.setup(_prediction, m) return self.predicted #......... def __dealloc__(self): @@ -856,27 +874,46 @@ #...................................................... -#cdef prediction(loess loess_obj, object newdata, object stderr): -# cdef c_loess.c_prediction _base -# cdef ndarray p_ndr -# cdef double *p_dat -# cdef int i, m -# cdef loess_prediction result -# # -# p_ndr = numpy.array(newdata, copy=False, subok=True, order='F') #.ravel() -## p_ndr = PyArray_FROMANY(newdata, NPY_DOUBLE, 1, self.model.npar, NPY_FORTRAN) -# p_dat = p_ndr.data -# m = len(p_ndr) -# c_loess.predict(p_dat, m, &loess_obj._base, &_base, stderr) -# result = loess_predicted() -# result._base = _base -# result.nest = m -# return result +#####--------------------------------------------------------------------------- +#---- ---- loess anova --- +#####--------------------------------------------------------------------------- +cdef class anova: + cdef readonly double dfn, dfd, F_value, Pr_F + # + def __init__(self, loess_one, loess_two): + cdef double one_d1, one_d2, one_s, two_d1, two_d2, two_s, rssdiff,\ + d1diff, tmp, df1, df2 + # + if not isinstance(loess_one, loess) or not isinstance(loess_two, loess): + raise ValueError("Arguments should be valid loess objects!"\ + "got '%s' instead" % type(loess_one)) + # + out_one = loess_one.outputs + out_two = loess_two.outputs + # + one_d1 = out_one.one_delta + one_d2 = out_one.two_delta + one_s = out_one.s + # + two_d1 = out_two.one_delta + two_d2 = out_two.two_delta + two_s = out_two.s + # + rssdiff = abs(one_s * one_s * one_d1 - two_s * two_s * two_d1) + d1diff = abs(one_d1 - two_d1) + self.dfn = d1diff * d1diff / abs(one_d2 - two_d2) + df1 = self.dfn + # + if out_one.enp > out_two.enp: + self.dfd = one_d1 * one_d1 / one_d2 + tmp = one_s + else: + self.dfd = two_d1 * two_d1 / two_d2 + tmp = two_s + df2 = self.dfd + F_value = (rssdiff / d1diff) / (tmp * tmp) + + self.Pr_F = 1. - c_loess.ibeta(F_value*df1/(df2+F_value*df1), df1/2, df2/2) + self.F_value = F_value - -#def anova(loess_one, loess_two): -# cdef c_loess.c_anova result -# -# c_loess.anova(loess_one._base, loess_two._base, &result) -# \ No newline at end of file Modified: trunk/Lib/sandbox/pyloess/sandbox/src/loess.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/loess.c 2007-03-16 20:42:51 UTC (rev 2849) +++ trunk/Lib/sandbox/pyloess/sandbox/src/loess.c 2007-03-19 23:50:21 UTC (rev 2850) @@ -2,10 +2,14 @@ #include "loess.h" #include #include +#include static char *surf_stat; +int error_status = 0; +char *error_message = NULL; + void loess_setup(double *x, double *y, long n, long p, loess *lo) { @@ -59,13 +63,17 @@ size_info[0] = lo->inputs.p; size_info[1] = lo->inputs.n; + + //Reset the default error status... + error_status = 0; + lo->status.err_status = 0; + lo->status.err_msg = NULL; iterations = (!strcmp(lo->model.family, "gaussian")) ? 0 : lo->control.iterations; if(!strcmp(lo->control.trace_hat, "wait.to.decide")) { if(!strcmp(lo->control.surface, "interpolate")) - lo->control.trace_hat = (lo->inputs.n < 500) ? "exact" : -"approximate"; + lo->control.trace_hat = (lo->inputs.n < 500) ? "exact" : "approximate"; else lo->control.trace_hat = "exact"; } @@ -96,6 +104,11 @@ lo->kd_tree.xi, lo->kd_tree.vert, lo->kd_tree.vval); + + if(error_status){ + lo->status.err_status = error_status; + lo->status.err_msg = error_message; + } } void @@ -115,7 +128,7 @@ setLf, nonparametric = 0, *order_parametric, *order_drop_sqr, zero = 0, max_kd, *a_tmp, *param_tmp; int cut, comp(); - char *new_stat; + char *new_stat, *mess; void condition(); D = size_info[0]; @@ -167,6 +180,7 @@ } else for(i = 0; i < D; i++) divisor[i] = 1; + j = D - 1; for(i = 0; i < D; i++) { sum_drop_sqr = sum_drop_sqr + drop_square[i]; @@ -176,6 +190,7 @@ else order_parametric[nonparametric++] = i; } + //Reorder the predictors w/ the non-parametric first for(i = 0; i < D; i++) { order_drop_sqr[i] = 2 - drop_square[order_parametric[i]]; k = i * N; @@ -183,20 +198,29 @@ for(j = 0; j < N; j++) x[k + j] = x_tmp[p + j]; } + + // Misc. checks ............................. if((*degree) == 1 && sum_drop_sqr) { - fprintf(stderr, "Specified the square of a factor predictor to be"\ - "dropped when degree = 1"); - exit(1); + error_status = 1; + error_message = "Specified the square of a factor predictor to be "\ + "dropped when degree = 1"; + return; } + if(D == 1 && sum_drop_sqr) { - fprintf(stderr, "Specified the square of a predictor to be dropped"\ - "with only one numeric predictor"); - exit(1); + error_status = 1; + error_message = "Specified the square of a predictor to be dropped "\ + "with only one numeric predictor"; + return; } + if(sum_parametric == D) { - fprintf(stderr, "Specified parametric for all predictors"); - exit(1); + error_status = 1; + error_message = "Specified parametric for all predictors"; + return; } + + // Start the iterations ..................... for(j = 0; j <= (*iterations); j++) { new_stat = j ? "none" : *statistics; for(i = 0; i < N; i++) @@ -221,8 +245,7 @@ } if((*iterations) > 0) { F77_SUB(lowesp)(&N, y, fitted_values, weights, robust, temp, -pseudovalues); - + pseudovalues); loess_raw(pseudovalues, x, weights, weights, &D, &N, span, degree, &nonparametric, order_drop_sqr, &sum_drop_sqr, &new_cell, &surf_stat, temp, param_tmp, a_tmp, xi_tmp, @@ -241,7 +264,8 @@ pseudo_resid[i] * pseudo_resid[i]; *enp = (*one_delta) + 2 * (*trace_hat_out) - N; *s = sqrt(sum_squares / (*one_delta)); - + + //Clean the mess and leave .................. free(x); free(x_tmp); free(temp); Modified: trunk/Lib/sandbox/pyloess/sandbox/src/loess.h =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/loess.h 2007-03-16 20:42:51 UTC (rev 2849) +++ trunk/Lib/sandbox/pyloess/sandbox/src/loess.h 2007-03-19 23:50:21 UTC (rev 2850) @@ -5,6 +5,11 @@ #define FALSE 0 typedef struct { + int err_status; + char *err_msg; + } loess_errstatus; + +typedef struct { long n; long p; double *y; @@ -57,6 +62,7 @@ loess_control control; loess_kd_tree kd_tree; loess_outputs outputs; + loess_errstatus status; } loess; typedef struct { Modified: trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c 2007-03-16 20:42:51 UTC (rev 2849) +++ trunk/Lib/sandbox/pyloess/sandbox/src/loessc.c 2007-03-19 23:50:21 UTC (rev 2850) @@ -3,14 +3,17 @@ #include #include -#define min(x,y) ((x) < (y) ? (x) : (y)) -#define max(x,y) ((x) > (y) ? (x) : (y)) -#define GAUSSIAN 1 -#define SYMMETRIC 0 +#define min(x,y) ((x) < (y) ? (x) : (y)) +#define max(x,y) ((x) > (y) ? (x) : (y)) +#define GAUSSIAN 1 +#define SYMMETRIC 0 static int *iv, liv, lv, tau; static double *v; +extern char *error_message; +extern int error_status; + loess_raw(double *y, double *x, double *weights, double *robust, int *d, int*n, double *span, int *degree, int *nonparametric, int *drop_square, int *sum_drop_sqr, double *cell, char **surf_stat, @@ -32,7 +35,7 @@ } else if (!strcmp(*surf_stat, "direct/none")) { F77_SUB(lowesf)(x, y, robust, iv, &liv, &lv, v, n, x, - &zero, &zero, surface); + &zero, &zero, surface); } else if (!strcmp(*surf_stat, "interpolate/1.approx")) { F77_SUB(lowesb)(x, y, weights, diagonal, &one, iv, &liv, &lv, v); @@ -261,47 +264,121 @@ { char *mess, mess2[50]; switch(*i){ -case 100: mess="wrong version number in lowesd. Probably typo in caller."; break; -case 101: mess="d>dMAX in ehg131. Need to recompile with increased dimensions."; break; -case 102: mess="liv too small. (Discovered by lowesd)"; break; -case 103: mess="lv too small. (Discovered by lowesd)"; break; -case 104: mess="span too small. fewer data values than degrees of freedom."; break; -case 105: mess="k>d2MAX in ehg136. Need to recompile with increased dimensions."; break; -case 106: mess="lwork too small"; break; -case 107: mess="invalid value for kernel"; break; -case 108: mess="invalid value for ideg"; break; -case 109: mess="lowstt only applies when kernel=1."; break; -case 110: mess="not enough extra workspace for robustness calculation"; break; -case 120: mess="zero-width neighborhood. make span bigger"; break; -case 121: mess="all data on boundary of neighborhood. make span bigger"; break; -case 122: mess="extrapolation not allowed with blending"; break; -case 123: mess="ihat=1 (diag L) in l2fit only makes sense if z=x (eval=data)."; break; -case 171: mess="lowesd must be called first."; break; -case 172: mess="lowesf must not come between lowesb and lowese, lowesr, or lowesl."; break; -case 173: mess="lowesb must come before lowese, lowesr, or lowesl."; break; -case 174: mess="lowesb need not be called twice."; break; -case 175: mess="need setLf=.true. for lowesl."; break; -case 180: mess="nv>nvmax in cpvert."; break; -case 181: mess="nt>20 in eval."; break; -case 182: mess="svddc failed in l2fit."; break; -case 183: mess="didnt find edge in vleaf."; break; -case 184: mess="zero-width cell found in vleaf."; break; -case 185: mess="trouble descending to leaf in vleaf."; break; -case 186: mess="insufficient workspace for lowesf."; break; -case 187: mess="insufficient stack space"; break; -case 188: mess="lv too small for computing explicit L"; break; -case 191: mess="computed trace L was negative; something is wrong!"; break; -case 192: mess="computed delta was negative; something is wrong!"; break; -case 193: mess="workspace in loread appears to be corrupted"; break; -case 194: mess="trouble in l2fit/l2tr"; break; -case 195: mess="only constant, linear, or quadratic local models allowed"; break; -case 196: mess="degree must be at least 1 for vertex influence matrix"; break; -case 999: mess="not yet implemented"; break; -default: sprintf(mess=mess2,"Assert failed; error code %d\n",*i); break; +case 100: + mess="Wrong version number in lowesd. Probably typo in caller."; + break; +case 101: + mess="d>dMAX in ehg131. Need to recompile with increased dimensions."; + break; +case 102: + mess="liv too small. (Discovered by lowesd)"; + break; +case 103: + mess="lv too small. (Discovered by lowesd)"; + break; +case 104: + mess="Span too small. Fewer data values than degrees of freedom."; + break; +case 105: + mess="k>d2MAX in ehg136. Need to recompile with increased dimensions."; + break; +case 106: + mess="lwork too small"; + break; +case 107: + mess="Invalid value for kernel"; + break; +case 108: + mess="Invalid value for ideg"; + break; +case 109: + mess="lowstt only applies when kernel=1."; + break; +case 110: + mess="Not enough extra workspace for robustness calculation"; + break; +case 120: + mess="Zero-width neighborhood. Make span bigger"; + break; +case 121: + mess="All data on boundary of neighborhood. make span bigger"; + break; +case 122: + mess="Extrapolation not allowed with blending"; + break; +case 123: + mess="ihat=1 (diag L) in l2fit only makes sense if z=x (eval=data)."; + break; +case 171: + mess="lowesd must be called first."; + break; +case 172: + mess="lowesf must not come between lowesb and lowese, lowesr, or lowesl."; + break; +case 173: + mess="lowesb must come before lowese, lowesr, or lowesl."; + break; +case 174: + mess="lowesb need not be called twice."; + break; +case 175: + mess="Need setLf=.true. for lowesl."; + break; +case 180: + mess="nv>nvmax in cpvert."; + break; +case 181: + mess="nt>20 in eval."; + break; +case 182: + mess="svddc failed in l2fit."; + break; +case 183: + mess="Did not find edge in vleaf."; + break; +case 184: + mess="Zero-width cell found in vleaf."; + break; +case 185: + mess="Trouble descending to leaf in vleaf."; + break; +case 186: + mess="Insufficient workspace for lowesf."; + break; +case 187: + mess="Insufficient stack space."; + break; +case 188: + mess="lv too small for computing explicit L."; + break; +case 191: + mess="Computed trace L was negative; something is wrong!"; + break; +case 192: + mess="Computed delta was negative; something is wrong!"; + break; +case 193: + mess="Workspace in loread appears to be corrupted."; + break; +case 194: + mess="Trouble in l2fit/l2tr"; + break; +case 195: + mess="Only constant, linear, or quadratic local models allowed"; + break; +case 196: + mess="degree must be at least 1 for vertex influence matrix"; + break; +case 999: + mess="not yet implemented"; + break; +default: + sprintf(mess=mess2,"Assert failed; error code %d\n",*i); + break; } - printf(mess); - return(i); -// Recover(mess,NULL_ENTRY); /* in /usr/s/current/src/qpe/debug.c */ +// printf(mess); + error_status = 1; + error_message = mess; } void @@ -315,7 +392,9 @@ strcat(mess,num); } strcat(mess,"\n"); - Warning(mess,NULL_ENTRY); +// printf(mess); + error_status = 1; + error_message = mess; } void @@ -329,5 +408,7 @@ strcat(mess,num); } strcat(mess,"\n"); - Warning(mess,NULL_ENTRY); +// printf(mess); + error_status = 1; + error_message = mess; } Modified: trunk/Lib/sandbox/pyloess/sandbox/src/loessf.f =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/loessf.f 2007-03-16 20:42:51 UTC (rev 2849) +++ trunk/Lib/sandbox/pyloess/sandbox/src/loessf.f 2007-03-19 23:50:21 UTC (rev 2850) @@ -39,6 +39,8 @@ 5 continue return end +C----------------------------------------------------------------------C +C cpvert subroutine ehg125(p,nv,v,vhit,nvmax,d,k,t,r,s,f,l,u) logical i1,i2,match integer d,execnt,h,i,i3,j,k,m,mm,nv,nvmax,p,r,s @@ -104,6 +106,8 @@ end if return end +C----------------------------------------------------------------------- +C descend integer function ehg138(i,z,a,xi,lo,hi,ncmax) logical i1 integer d,execnt,i,j,nc,ncmax @@ -131,6 +135,9 @@ 4 ehg138=j return end + +C----------------------------------------------------------------------C +C select q-th smallest by partial sorting subroutine ehg106(il,ir,k,nk,p,pi,n) integer execnt,i,ii,il,ir,j,k,l,n,nk,r integer pi(n) @@ -198,6 +205,9 @@ c bottom of while loop 4 return end + +C----------------------------------------------------------------------C +C l2fit,l2tr computational kernel subroutine ehg127(q,n,d,nf,f,x,psi,y,rw,kernel,k,dist,eta,b,od,w,r +cond,sing,sigma,u,e,dgamma,qraux,work,tol,dd,tdeg,cdeg,s) integer column,d,dd,execnt,i,i3,i9,info,inorm2,j,jj,jpvt,k,kernel, @@ -384,6 +394,9 @@ 27 continue return end + +C----------------------------------------------------------------------C +C lowesb after workspace expansion subroutine ehg131(x,y,rw,trl,diagl,kernel,k,n,d,nc,ncmax,vc,nv,nvm +ax,nf,f,a,c,hi,lo,pi,psi,v,vhit,vval,xi,dist,eta,b,ntol,fd,w,vval2 +,rcond,sing,dd,tdeg,cdeg,lq,lf,setlf) @@ -437,6 +450,9 @@ +g,cdeg,lq,lf,setlf,vval) return end + +C----------------------------------------------------------------------C +C lowese after workspace expansion subroutine ehg133(n,d,vc,nvmax,nc,ncmax,a,c,hi,lo,v,vval,xi,m,z,s) integer d,execnt,i,i1,m,nc,ncmax,nv,nvmax,vc integer a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax) @@ -464,6 +480,9 @@ iw(i)=j return end + +C----------------------------------------------------------------------C +C delta1,2 from trL subroutine ehg141(trl,n,deg,k,d,nsing,dk,delta1,delta2) integer d,deg,dk,k,n,nsing external ehg176 @@ -514,6 +533,9 @@ delta2=n-trl*dexp(c1*z**c2*(1-z)**c3*c4) return end + +C----------------------------------------------------------------------C +C exact delta subroutine lowesc(n,l,ll,trl,delta1,delta2) integer execnt,i,j,n double precision delta1,delta2,trl @@ -554,6 +576,9 @@ 10 continue return end + +C----------------------------------------------------------------------C +C compute derived k-d tree information subroutine ehg169(d,vc,nc,ncmax,nv,nvmax,v,a,xi,c,hi,lo) integer d,execnt,i,j,k,mc,mv,nc,ncmax,nv,nvmax,p,vc integer a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax),novhit(1) @@ -606,6 +631,9 @@ end if return end + +C----------------------------------------------------------------------C +C loeval for delta DOUBLE PRECISION function ehg176(z) DOUBLE PRECISION z(*) integer d,vc,nv,nc @@ -707,6 +735,9 @@ data vval(1,10) /-4.1032D-2/ ehg176=ehg128(z,d,nc,vc,a,xi,lo,hi,c,v,nv,vval) end + +C----------------------------------------------------------------------C +C approximate delta subroutine lowesa(trl,n,d,tau,nsing,delta1,delta2) integer d,dka,dkb,execnt,n,nsing,tau double precision alpha,d1a,d1b,d2a,d2b,delta1,delta2,trl @@ -721,6 +752,9 @@ delta2=(1-alpha)*d2a+alpha*d2b return end + +C----------------------------------------------------------------------C +C lowesl after workspace expansion subroutine ehg191(m,z,l,d,n,nf,nv,ncmax,vc,a,xi,lo,hi,c,v,nvmax,vv +al2,lf,lq) integer lq1,d,execnt,i,i1,i2,j,m,n,nc,ncmax,nf,nv,nvmax,p,vc @@ -764,6 +798,9 @@ 3 continue return end + +C----------------------------------------------------------------------C +C trL approximation subroutine ehg196(tau,d,f,trl) integer d,dka,dkb,execnt,tau double precision alpha,f,trl,trla,trlb @@ -777,6 +814,9 @@ trl=(1-alpha)*trla+alpha*trlb return end + +C----------------------------------------------------------------------C +C for deg 1,2 subroutine ehg197(deg,tau,d,f,dk,trl) integer d,deg,dk,tau double precision trl, f @@ -787,6 +827,9 @@ trl = dk*(1+max(0.d0,(g1-f)/f)) return end + +C----------------------------------------------------------------------C +C lowesr after workspace expansion subroutine ehg192(y,d,n,nf,nv,nvmax,vval,lf,lq) integer d,execnt,i,i1,i2,j,n,nf,nv,nvmax integer lq(nvmax,nf) @@ -810,6 +853,10 @@ 5 continue return end + + +C----------------------------------------------------------------------C +C eval DOUBLE PRECISION function ehg128(z,d,ncmax,vc,a,xi,lo,hi,c,v,nvmax +,vval) logical i10,i2,i3,i4,i5,i6,i7,i8,i9 @@ -1147,6 +1194,10 @@ ehg128=s return end + + +C----------------------------------------------------------------------C +C integer function ifloor(x) DOUBLE PRECISION x ifloor=x @@ -1271,6 +1322,9 @@ 4 continue return end + +C----------------------------------------------------------------------C +C l2tr subroutine ehg139(v,nvmax,nv,n,d,nf,f,x,pi,psi,y,rw,trl,kernel,k,d +ist,phi,eta,b,od,w,diagl,vval2,ncmax,vc,a,xi,lo,hi,c,vhit,rcond,si +ng,dd,tdeg,cdeg,lq,lf,setlf,s) @@ -1434,6 +1488,9 @@ end if return end + + +C----------------------------------------------------------------------C subroutine dqrdc(x,ldx,n,p,qraux,jpvt,work,job) integer ldx,n,p,job integer jpvt(1) @@ -1641,6 +1698,8 @@ 200 continue return end + +C---------------------------------------------------------------------C integer function idamax(n,dx,incx) c c finds the index of element having max. absolute value. @@ -1678,6 +1737,9 @@ 30 continue return end + +C----------------------------------------------------------------------C +C build kd tree subroutine lowesb(xx,yy,ww,diagl,infl,iv,liv,lv,wv) logical infl,setlf integer execnt @@ -1722,6 +1784,9 @@ end if return end + +C----------------------------------------------------------------------C +C setup workspace subroutine lowesd(versio,iv,liv,lv,v,d,n,f,ideg,nvmax,setlf) logical setlf integer bound,d,execnt,i,i1,i2,ideg,j,liv,lv,n,ncmax,nf,nvmax,vc,v @@ -1822,6 +1887,9 @@ v(4)=1.d0 return end + +C----------------------------------------------------------------------C +C evaluate smooth at z subroutine lowese(iv,liv,lv,wv,m,z,s) integer execnt,m integer iv(*) @@ -1840,6 +1908,9 @@ +8)),iv(iv(9)),iv(iv(10)),wv(iv(11)),wv(iv(13)),wv(iv(12)),m,z,s) return end + +C----------------------------------------------------------------------C +C slow smooth at z subroutine lowesf(xx,yy,ww,iv,liv,lv,wv,m,z,l,ihat,s) logical i1 integer execnt,ihat,m,n @@ -1866,6 +1937,9 @@ +(4),iv(30),iv(33),iv(32),iv(41),s) return end + +C----------------------------------------------------------------------C +C explicit hat matrix mapping y to z subroutine lowesl(iv,liv,lv,wv,m,z,l) integer execnt,m,n integer iv(*) @@ -1888,6 +1962,9 @@ +24)),wv(iv(34)),iv(iv(25))) return end + +C----------------------------------------------------------------------C +C rebuild with new data values (does not change y) subroutine lowesr(yy,iv,liv,lv,wv) integer execnt integer iv(*) @@ -1906,6 +1983,9 @@ +)),iv(iv(25))) return end + +C----------------------------------------------------------------------C +C robustness weights subroutine lowesw(res,n,rw,pi) integer identi,execnt,i,i1,n,nh integer pi(n) @@ -1957,6 +2037,9 @@ end if return end + +C----------------------------------------------------------------------C +C pseudovalues subroutine lowesp(n,y,yhat,pwgts,rwgts,pi,ytilde) integer identi,execnt,i2,i3,i5,m,n integer pi(n) @@ -2009,6 +2092,9 @@ 8 continue return end + +C----------------------------------------------------------------------C +C rbuild subroutine ehg124(ll,uu,d,n,nv,nc,ncmax,vc,x,pi,a,xi,lo,hi,c,v,vhi +t,nvmax,fc,fd,dd) logical i1,i2,i3,leaf @@ -2117,6 +2203,9 @@ c bottom of while loop 4 return end + +C----------------------------------------------------------------------C +C spread subroutine ehg129(l,u,d,x,pi,n,sigma) integer d,execnt,i,k,l,n,u integer pi(n) @@ -2143,6 +2232,9 @@ 3 continue return end + +C----------------------------------------------------------------------C +C vleaf subroutine ehg137(z,kappa,leaf,nleaf,d,nv,nvmax,ncmax,vc,a,xi,lo,h +i,c,v) integer d,execnt,nc,ncmax,nleaf,p,stackt Modified: trunk/Lib/sandbox/pyloess/sandbox/src/misc.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/misc.c 2007-03-16 20:42:51 UTC (rev 2849) +++ trunk/Lib/sandbox/pyloess/sandbox/src/misc.c 2007-03-19 23:50:21 UTC (rev 2850) @@ -65,7 +65,7 @@ double pf(double q, double df1, double df2) { - double ibeta(); + double ibeta(); return(ibeta(q*df1/(df2+q*df1), df1/2, df2/2)); } Modified: trunk/Lib/sandbox/pyloess/sandbox/src/predict.c =================================================================== --- trunk/Lib/sandbox/pyloess/sandbox/src/predict.c 2007-03-16 20:42:51 UTC (rev 2849) +++ trunk/Lib/sandbox/pyloess/sandbox/src/predict.c 2007-03-19 23:50:21 UTC (rev 2850) @@ -3,23 +3,34 @@ #include #include + +extern char *error_message; +extern int error_status; + void predict(double *eval, int m, loess *lo, prediction *pre, int se) { - int size_info[3]; - void pred_(); + int size_info[3]; + void pred_(); pre->fit = (double *) malloc(m * sizeof(double)); pre->se_fit = (double *) malloc(m * sizeof(double)); pre->residual_scale = lo->outputs.s; pre->df = (lo->outputs.one_delta * lo->outputs.one_delta) / -lo->outputs.two_delta; + lo->outputs.two_delta; size_info[0] = lo->inputs.p; size_info[1] = lo->inputs.n; size_info[2] = m; + + error_status = 0; + lo->status.err_status = 0; + lo->status.err_msg = NULL; - pred_(lo->inputs.y, lo->inputs.x, eval, size_info, &lo->outputs.s, + pred_(lo->inputs.y, + lo->inputs.x, eval, + size_info, + &lo->outputs.s, lo->inputs.weights, lo->outputs.robust, &lo->model.span, @@ -39,6 +50,11 @@ &se, pre->fit, pre->se_fit); + + if(error_status){ + lo->status.err_status = error_status; + lo->status.err_msg = error_message; + } } void @@ -52,7 +68,7 @@ double *x, *x_tmp, *x_evaluate, *L, new_cell, z, tmp, *fit_tmp, *temp, sum, mean; int N, D, M, sum_drop_sqr = 0, sum_parametric = 0, - nonparametric = 0, *order_parametric, *order_drop_sqr; + nonparametric = 0, *order_parametric, *order_drop_sqr; int i, j, k, p, cut, comp(); D = size_info[0]; @@ -83,85 +99,85 @@ p = k + j; x_tmp[p] = x_[p] / divisor[i]; } - } - } - j = D - 1; - for(i = 0; i < D; i++) { + } + } + j = D - 1; + for(i = 0; i < D; i++) { sum_drop_sqr = sum_drop_sqr + drop_square[i]; sum_parametric = sum_parametric + parametric[i]; if(parametric[i]) order_parametric[j--] = i; - else + else order_parametric[nonparametric++] = i; - } + } for(i = 0; i < D; i++) { order_drop_sqr[i] = 2 - drop_square[order_parametric[i]]; - k = i * M; - p = order_parametric[i] * M; + k = i * M; + p = order_parametric[i] * M; for(j = 0; j < M; j++) - x_evaluate[k + j] = new_x[p + j]; - k = i * N; - p = order_parametric[i] * N; + x_evaluate[k + j] = new_x[p + j]; + k = i * N; + p = order_parametric[i] * N; for(j = 0; j < N; j++) x[k + j] = x_tmp[p + j]; } - for(i = 0; i < N; i++) - robust[i] = weights[i] * robust[i]; + for(i = 0; i < N; i++) + robust[i] = weights[i] * robust[i]; - if(!strcmp(*surface, "direct")) { - if(*se) { - loess_dfitse(y, x, x_evaluate, weights, robust, + if(!strcmp(*surface, "direct")) { + if(*se) { + loess_dfitse(y, x, x_evaluate, weights, robust, !strcmp(*family, "gaussian"), span, degree, &nonparametric, order_drop_sqr, &sum_drop_sqr, &D, &N, &M, fit, L); } - else { - loess_dfit(y, x, x_evaluate, robust, span, degree, + else { + loess_dfit(y, x, x_evaluate, robust, span, degree, &nonparametric, order_drop_sqr, &sum_drop_sqr, - &D, &N, &M, fit); + &D, &N, &M, fit); } } - else { - loess_ifit(parameter, a, xi, vert, vval, &M, x_evaluate, fit); - if(*se) { + else { + loess_ifit(parameter, a, xi, vert, vval, &M, x_evaluate, fit); + if(*se) { new_cell = (*span) * (*cell); fit_tmp = (double *) malloc(M * sizeof(double)); - loess_ise(y, x, x_evaluate, weights, span, degree, - &nonparametric, order_drop_sqr, &sum_drop_sqr, - &new_cell, &D, &N, &M, fit_tmp, L); - free(fit_tmp); + loess_ise(y, x, x_evaluate, weights, span, degree, + &nonparametric, order_drop_sqr, &sum_drop_sqr, + &new_cell, &D, &N, &M, fit_tmp, L); + free(fit_tmp); } } - if(*se) { - for(i = 0; i < N; i++) { - k = i * M; - for(j = 0; j < M; j++) { - p = k + j; - L[p] = L[p] / weights[i]; - L[p] = L[p] * L[p]; + if(*se) { + for(i = 0; i < N; i++) { + k = i * M; + for(j = 0; j < M; j++) { + p = k + j; + L[p] = L[p] / weights[i]; + L[p] = L[p] * L[p]; } - } - for(i = 0; i < M; i++) { - tmp = 0; - for(j = 0; j < N; j++) - tmp = tmp + L[i + j * M]; - se_fit[i] = (*s) * sqrt(tmp); - } - } - free(x); - free(x_tmp); - free(x_evaluate); - free(L); - free(order_parametric); - free(order_drop_sqr); - free(temp); + } + for(i = 0; i < M; i++) { + tmp = 0; + for(j = 0; j < N; j++) + tmp = tmp + L[i + j * M]; + se_fit[i] = (*s) * sqrt(tmp); + } + } + free(x); + free(x_tmp); + free(x_evaluate); + free(L); + free(order_parametric); + free(order_drop_sqr); + free(temp); } void pred_free_mem(prediction *pre) { - free(pre->fit); - free(pre->se_fit); + free(pre->fit); + free(pre->se_fit); } From scipy-svn at scipy.org Tue Mar 20 10:42:23 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 20 Mar 2007 09:42:23 -0500 (CDT) Subject: [Scipy-svn] r2851 - trunk/Lib/sandbox/timeseries Message-ID: <20070320144223.1971F39C034@new.scipy.org> Author: mattknox_ca Date: 2007-03-20 09:42:18 -0500 (Tue, 20 Mar 2007) New Revision: 2851 Added: trunk/Lib/sandbox/timeseries/const.py Log: separate name space for frequency constants Added: trunk/Lib/sandbox/timeseries/const.py =================================================================== --- trunk/Lib/sandbox/timeseries/const.py 2007-03-19 23:50:21 UTC (rev 2850) +++ trunk/Lib/sandbox/timeseries/const.py 2007-03-20 14:42:18 UTC (rev 2851) @@ -0,0 +1,21 @@ +""" +A collection of tools for timeseries + +:author: Pierre GF Gerard-Marchant & Matt Knox +:contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com +:version: $Id: tcore.py 2836 2007-03-07 16:58:14Z mattknox_ca $ +""" +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author: mattknox_ca $)" +__version__ = '1.0' +__revision__ = "$Revision: 2836 $" +__date__ = '$Date: 2007-03-07 11:58:14 -0500 (Wed, 07 Mar 2007) $' + +from cseries import freq_constants + +"""add constants in cseries.freq_constants dictionary to global namespace +for this module""" + +__all__ = [list(freq_constants)] + +_g = globals() +_g.update(freq_constants) From scipy-svn at scipy.org Tue Mar 20 10:44:15 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 20 Mar 2007 09:44:15 -0500 (CDT) Subject: [Scipy-svn] r2852 - in trunk/Lib/sandbox/timeseries: . src tests Message-ID: <20070320144415.A609A39C28E@new.scipy.org> Author: mattknox_ca Date: 2007-03-20 09:44:08 -0500 (Tue, 20 Mar 2007) New Revision: 2852 Modified: trunk/Lib/sandbox/timeseries/__init__.py trunk/Lib/sandbox/timeseries/setup.py trunk/Lib/sandbox/timeseries/src/cseries.c trunk/Lib/sandbox/timeseries/tcore.py trunk/Lib/sandbox/timeseries/tdates.py trunk/Lib/sandbox/timeseries/tests/test_dates.py trunk/Lib/sandbox/timeseries/tests/test_timeseries.py trunk/Lib/sandbox/timeseries/tseries.py Log: major update. Ported Date class to C, removed a lot of stuff from tcore Modified: trunk/Lib/sandbox/timeseries/__init__.py =================================================================== --- trunk/Lib/sandbox/timeseries/__init__.py 2007-03-20 14:42:18 UTC (rev 2851) +++ trunk/Lib/sandbox/timeseries/__init__.py 2007-03-20 14:44:08 UTC (rev 2852) @@ -1,34 +1,42 @@ -"""TimeSeries - -Support for time series in numpy/scipy - -:author: Pierre GF Gerard-Marchant & Matt Knox -:contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com -:version: $Id$ -""" +"""TimeSeries +Support for time series in numpy/scipy -__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" -__version__ = '1.0' -__revision__ = "$Revision$" -__date__ = '$Date$' - -import tcore -from tcore import * -import tdates -from tdates import * -import tseries -from tseries import * -import tmulti -from tmulti import * +:author: Pierre GF Gerard-Marchant & Matt Knox +:contact: pierregm_at_uga_dot_edu - mattknox_ca_at_hotmail_dot_com +:version: $Id$ +""" + + +__author__ = "Pierre GF Gerard-Marchant & Matt Knox ($Author$)" +__version__ = '1.0' +__revision__ = "$Revision$" +__date__ = '$Date$' + +# initialize python callbacks for C code +import cseries as cs +import parser +from parser import DateFromString, DateTimeFromString +cs.set_callback_DateFromString(DateFromString) +cs.set_callback_DateTimeFromString(DateTimeFromString) + +import tcore +from tcore import * +import const +import tdates +from tdates import * +import tseries +from tseries import * +import tmulti +from tmulti import * import reportlib -from reportlib import * -from addons import filters, interpolate +from reportlib import * +from addons import filters, interpolate - -__all__ = ['tdates', 'tseries','tmulti','reportlib','filters','interpolate'] -__all__ += tdates.__all__ -__all__ += tseries.__all__ + +__all__ = ['const', 'tdates','parser','tseries','tmulti','reportlib','filters', + 'interpolate','DateFromString','DateTimeFromString'] +__all__ += tdates.__all__ +__all__ += tseries.__all__ __all__ += tmulti.__all__ __all__ += reportlib.__all__ - Modified: trunk/Lib/sandbox/timeseries/setup.py =================================================================== --- trunk/Lib/sandbox/timeseries/setup.py 2007-03-20 14:42:18 UTC (rev 2851) +++ trunk/Lib/sandbox/timeseries/setup.py 2007-03-20 14:44:08 UTC (rev 2852) @@ -25,5 +25,5 @@ if __name__ == "__main__": from numpy.distutils.core import setup #setup.update(nmasetup) - config = configuration(top_path='').todict() + config = configuration(top_path='').todict() setup(**config) \ No newline at end of file Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-20 14:42:18 UTC (rev 2851) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-20 14:44:08 UTC (rev 2852) @@ -1,8 +1,6 @@ #include #include #include -#include -#include #include #include "arrayobject.h" @@ -41,15 +39,16 @@ #define FR_SEC 9000 /* Secondly */ #define FR_UND -10000 /* Undefined */ -#define ADD_INT_TO_DICT(dict, key, val) \ - {PyObject *pyval = PyInt_FromLong(val); \ - PyDict_SetItemString(dict, key, pyval); \ - Py_DECREF(pyval); } +#define INT_ERR_CODE -999 -#define DINFO_ERR -99 +#define HIGHFREQ_ORIG 719163 -#define CHECK_ASFREQ(result) if ((result) == DINFO_ERR) return NULL +#define CHECK_ASFREQ(result) if ((result) == INT_ERR_CODE) return NULL +static int get_freq_group(int freq) { + return (freq/1000)*1000; +} + struct asfreq_info{ int from_week_end; //day the week ends on in the "from" frequency int to_week_end; //day the week ends on in the "to" frequency @@ -61,6 +60,129 @@ static struct asfreq_info NULL_AF_INFO; +/********************************************************* +** Python callbacks. These functions must be called by ** +** the module __init__ script ** +*********************************************************/ +static PyObject * +set_callback(PyObject *args, PyObject **callback) +{ + PyObject *result = NULL; + PyObject *temp; + + if (PyArg_ParseTuple(args, "O:set_callback", &temp)) { + + if (!PyCallable_Check(temp)) { + PyErr_SetString(PyExc_TypeError, "parameter must be callable"); + return NULL; + } + + Py_XINCREF(temp); // Add a reference to new callback + Py_XDECREF(*callback); // Dispose of previous callback + *callback = temp; // Remember new callback + // Boilerplate to return "None" + Py_INCREF(Py_None); + result = Py_None; + } + return result; +} + +static PyObject *DateFromString = NULL; +static char set_callback_DateFromString_doc[] = +"set DateFromString function python callback"; +static PyObject * +set_callback_DateFromString(PyObject *dummy, PyObject *args) { + return set_callback(args, &DateFromString); +} + +static PyObject *DateTimeFromString = NULL; +static char set_callback_DateTimeFromString_doc[] = +"set DateTimeFromString function python callback"; +static PyObject * +set_callback_DateTimeFromString(PyObject *dummy, PyObject *args) { + return set_callback(args, &DateTimeFromString); +} + +/*********************************************************/ + +static char * +str_uppercase(char *str) { + if (str) { + int i, len=strlen(str); + char *result; + if((result = malloc((len + 1)*sizeof(char))) == NULL) { + return (char *)PyErr_NoMemory(); + } + strcpy(result, str); + + for (i=0;i 4) { + if (day_of_week > 4) { //change to Monday after weekend - absdate += (7 - dinfo.day_of_week); + absdate += (7 - day_of_week); } return DtoB_weekday(absdate); } -static long DtoB_WeekendToFriday(struct date_info dinfo) { +static long DtoB_WeekendToFriday(long absdate, int day_of_week) { - long absdate = dinfo.absdate; - if (dinfo.day_of_week > 4) { + if (day_of_week > 4) { //change to friday before weekend - absdate -= (dinfo.day_of_week - 4); + absdate -= (day_of_week - 4); } return DtoB_weekday(absdate); } static long absdate_from_ymd(int y, int m, int d) { struct date_info tempDate; - if (dInfoCalc_SetFromDateAndTime(&tempDate, y, m, d, 0, 0, 0, GREGORIAN_CALENDAR)) return DINFO_ERR; + if (dInfoCalc_SetFromDateAndTime(&tempDate, y, m, d, 0, 0, 0, GREGORIAN_CALENDAR)) return INT_ERR_CODE; return tempDate.absdate; } @@ -483,7 +596,7 @@ struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, - GREGORIAN_CALENDAR)) return DINFO_ERR; + GREGORIAN_CALENDAR)) return INT_ERR_CODE; if (dinfo.month > af_info->to_a_year_end) { return (long)(dinfo.year + 1); } else { return (long)(dinfo.year); } } @@ -493,7 +606,7 @@ struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, - GREGORIAN_CALENDAR)) return DINFO_ERR; + GREGORIAN_CALENDAR)) return INT_ERR_CODE; return (long)((dinfo.year - 1) * 4 + dinfo.quarter); } @@ -501,7 +614,7 @@ struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, - GREGORIAN_CALENDAR)) return DINFO_ERR; + GREGORIAN_CALENDAR)) return INT_ERR_CODE; return (long)((dinfo.year - 1) * 12 + dinfo.month); } @@ -513,12 +626,12 @@ struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, - GREGORIAN_CALENDAR)) return DINFO_ERR; + GREGORIAN_CALENDAR)) return INT_ERR_CODE; if (relation == 'B') { - return DtoB_WeekendToFriday(dinfo); + return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } else { - return DtoB_WeekendToMonday(dinfo); + return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } } @@ -526,7 +639,7 @@ struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, - GREGORIAN_CALENDAR)) return DINFO_ERR; + GREGORIAN_CALENDAR)) return INT_ERR_CODE; if (dinfo.day_of_week > 4) { return -1; @@ -539,9 +652,9 @@ static long asfreq_DtoD(long fromDate, char relation, struct asfreq_info *af_info) { return fromDate; } static long asfreq_DtoHIGHFREQ(long fromDate, char relation, long periodsPerDay) { - if (fromDate >= minval_D_toHighFreq) { - if (relation == 'B') { return (fromDate - minval_D_toHighFreq)*(periodsPerDay) + 1; } - else { return (fromDate - minval_D_toHighFreq + 1)*(periodsPerDay); } + if (fromDate >= HIGHFREQ_ORIG) { + if (relation == 'B') { return (fromDate - HIGHFREQ_ORIG)*(periodsPerDay) + 1; } + else { return (fromDate - HIGHFREQ_ORIG + 1)*(periodsPerDay); } } else { return -1; } } @@ -555,7 +668,7 @@ //************ FROM SECONDLY *************** static long asfreq_StoD(long fromDate, char relation, struct asfreq_info *af_info) - { return (fromDate - 1)/(60*60*24) + minval_D_toHighFreq; } + { return (fromDate - 1)/(60*60*24) + HIGHFREQ_ORIG; } static long asfreq_StoA(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoA(asfreq_StoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } @@ -577,7 +690,7 @@ //************ FROM MINUTELY *************** static long asfreq_TtoD(long fromDate, char relation, struct asfreq_info *af_info) - { return (fromDate - 1)/(60*24) + minval_D_toHighFreq; } + { return (fromDate - 1)/(60*24) + HIGHFREQ_ORIG; } static long asfreq_TtoA(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoA(asfreq_TtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } @@ -602,7 +715,7 @@ //************ FROM HOURLY *************** static long asfreq_HtoD(long fromDate, char relation, struct asfreq_info *af_info) - { return (fromDate - 1)/24 + minval_D_toHighFreq; } + { return (fromDate - 1)/24 + HIGHFREQ_ORIG; } static long asfreq_HtoA(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoA(asfreq_HtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } static long asfreq_HtoQ(long fromDate, char relation, struct asfreq_info *af_info) @@ -671,10 +784,10 @@ struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_WtoD(fromDate, relation, af_info), - GREGORIAN_CALENDAR)) return DINFO_ERR; + GREGORIAN_CALENDAR)) return INT_ERR_CODE; - if (relation == 'B') { return DtoB_WeekendToMonday(dinfo); } - else { return DtoB_WeekendToFriday(dinfo); } + if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } + else { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } } static long asfreq_WtoH(long fromDate, char relation, struct asfreq_info *af_info) @@ -697,11 +810,11 @@ if (relation == 'B') { MtoD_ym(fromDate, &y, &m); - if ((absdate = absdate_from_ymd(y, m, 1)) == DINFO_ERR) return DINFO_ERR; + if ((absdate = absdate_from_ymd(y, m, 1)) == INT_ERR_CODE) return INT_ERR_CODE; return absdate; } else { MtoD_ym(fromDate+1, &y, &m); - if ((absdate = absdate_from_ymd(y, m, 1)) == DINFO_ERR) return DINFO_ERR; + if ((absdate = absdate_from_ymd(y, m, 1)) == INT_ERR_CODE) return INT_ERR_CODE; return absdate-1; } } @@ -723,10 +836,10 @@ struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_MtoD(fromDate, relation, &NULL_AF_INFO), - GREGORIAN_CALENDAR)) return DINFO_ERR; + GREGORIAN_CALENDAR)) return INT_ERR_CODE; - if (relation == 'B') { return DtoB_WeekendToMonday(dinfo); } - else { return DtoB_WeekendToFriday(dinfo); } + if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } + else { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } } static long asfreq_MtoH(long fromDate, char relation, struct asfreq_info *af_info) @@ -749,11 +862,11 @@ if (relation == 'B') { QtoD_ym(fromDate, &y, &m); - if ((absdate = absdate_from_ymd(y, m, 1)) == DINFO_ERR) return DINFO_ERR; + if ((absdate = absdate_from_ymd(y, m, 1)) == INT_ERR_CODE) return INT_ERR_CODE; return absdate; } else { QtoD_ym(fromDate+1, &y, &m); - if ((absdate = absdate_from_ymd(y, m, 1)) == DINFO_ERR) return DINFO_ERR; + if ((absdate = absdate_from_ymd(y, m, 1)) == INT_ERR_CODE) return INT_ERR_CODE; return absdate - 1; } } @@ -777,10 +890,10 @@ struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_QtoD(fromDate, relation, &NULL_AF_INFO), - GREGORIAN_CALENDAR)) return DINFO_ERR; + GREGORIAN_CALENDAR)) return INT_ERR_CODE; - if (relation == 'B') { return DtoB_WeekendToMonday(dinfo); } - else { return DtoB_WeekendToFriday(dinfo); } + if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } + else { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } } @@ -808,7 +921,7 @@ final_adj = -1; } absdate = absdate_from_ymd(year, month, 1); - if (absdate == DINFO_ERR) return DINFO_ERR; + if (absdate == INT_ERR_CODE) return INT_ERR_CODE; return absdate + final_adj; } @@ -836,7 +949,7 @@ static long asfreq_AtoB(long fromDate, char relation, struct asfreq_info *af_info) { - long absdate, year; + long year; int month = (af_info->from_a_year_end + 1) % 12; struct date_info dailyDate; @@ -848,8 +961,8 @@ if (dInfoCalc_SetFromDateAndTime(&dailyDate, year,month,1, 0, 0, 0, - GREGORIAN_CALENDAR)) return DINFO_ERR; - return DtoB_WeekendToMonday(dailyDate); + GREGORIAN_CALENDAR)) return INT_ERR_CODE; + return DtoB_WeekendToMonday(dailyDate.absdate, dailyDate.day_of_week); } else { long absdate; @@ -858,15 +971,15 @@ if (dInfoCalc_SetFromDateAndTime(&dailyDate, year,month,1, 0, 0, 0, - GREGORIAN_CALENDAR)) return DINFO_ERR; + GREGORIAN_CALENDAR)) return INT_ERR_CODE; absdate = dailyDate.absdate - 1; if(dInfoCalc_SetFromAbsDate(&dailyDate, absdate, - GREGORIAN_CALENDAR)) return DINFO_ERR; + GREGORIAN_CALENDAR)) return INT_ERR_CODE; - return DtoB_WeekendToFriday(dailyDate); + return DtoB_WeekendToFriday(dailyDate.absdate, dailyDate.day_of_week); } } @@ -884,9 +997,11 @@ // return a pointer to appropriate conversion function static long (*get_asfreq_func(int fromFreq, int toFreq, int forConvert))(long, char, struct asfreq_info*) { - int fromGroup = (fromFreq/1000)*1000; - int toGroup = (toFreq/1000)*1000; + int fromGroup = get_freq_group(fromFreq); + int toGroup = get_freq_group(toFreq); + if (fromGroup == FR_UND) { fromGroup = FR_DAY; } + switch(fromGroup) { case FR_ANN: @@ -1038,9 +1153,11 @@ int maxBusDaysPerYear, maxBusDaysPerQuarter, maxBusDaysPerMonth; int maxDaysPerYear, maxDaysPerQuarter, maxDaysPerMonth; - int fromGroup = (fromFreq/1000)*1000; - int toGroup = (toFreq/1000)*1000; + int fromGroup = get_freq_group(fromFreq); + int toGroup = get_freq_group(toFreq); + if (fromGroup == FR_UND) { fromGroup = FR_DAY; } + maxBusDaysPerYear = 262; maxBusDaysPerQuarter = 66; maxBusDaysPerMonth = 23; @@ -1145,8 +1262,8 @@ static void get_asfreq_info(int fromFreq, int toFreq, struct asfreq_info *af_info) { - int fromGroup = (fromFreq/1000)*1000; - int toGroup = (toFreq/1000)*1000; + int fromGroup = get_freq_group(fromFreq); + int toGroup = get_freq_group(toFreq); switch(fromGroup) { @@ -1170,10 +1287,1250 @@ } -static char cseries_convert_doc[] = ""; +static int dInfo_year(struct date_info *dateObj) { return dateObj->year; } +static int dInfo_quarter(struct date_info *dateObj) { return dateObj->quarter; } +static int dInfo_month(struct date_info *dateObj) { return dateObj->month; } +static int dInfo_day(struct date_info *dateObj) { return dateObj->day; } +static int dInfo_day_of_year(struct date_info *dateObj) { return dateObj->day_of_year; } +static int dInfo_day_of_week(struct date_info *dateObj) { return dateObj->day_of_week; } +static int dInfo_week(struct date_info *dateObj) { return dInfoCalc_ISOWeek(dateObj); } +static int dInfo_hour(struct date_info *dateObj) { return dateObj->hour; } +static int dInfo_minute(struct date_info *dateObj) { return dateObj->minute; } +static int dInfo_second(struct date_info *dateObj) { return (int)dateObj->second; } + +static double getAbsTime(int freq, long dailyDate, long originalDate) { + + long startOfDay, periodsPerDay; + + switch(freq) + { + case FR_HR: + periodsPerDay = 24; + break; + case FR_MIN: + periodsPerDay = 24*60; + break; + case FR_SEC: + periodsPerDay = 24*60*60; + break; + default: + return 0; + } + + startOfDay = asfreq_DtoHIGHFREQ(dailyDate, 'B', periodsPerDay); + return (24*60*60)*((double)(originalDate - startOfDay))/((double)periodsPerDay); +} + +/************************************************************ +** Date type definition +************************************************************/ + +typedef struct { + PyObject_HEAD + int freq; /* frequency of date */ + int value; /* integer representation of date */ + PyObject* cached_vals; +} DateObject; + +/* Forward declarations */ +static PyTypeObject DateType; +#define DateObject_Check(op) PyObject_TypeCheck(op, &DateType) + +static void +DateObject_dealloc(DateObject* self) { + Py_XDECREF(self->cached_vals); + self->ob_type->tp_free((PyObject*)self); +} + + +static PyObject *freq_dict, *freq_dict_rev, *freq_constants; + +#define DICT_SETINT_STRKEY(dict, key, val) \ + {PyObject *pyval = PyInt_FromLong(val); \ + PyDict_SetItemString(dict, key, pyval); \ + Py_DECREF(pyval); } + +#define ADD_FREQ_CONSTANT(const_name, val) \ + DICT_SETINT_STRKEY(freq_constants, const_name, val) + +#define INIT_FREQ(const_name, key, aliases) \ + {PyObject *pykey = PyInt_FromLong(key); \ + PyDict_SetItem(freq_dict, pykey, aliases); \ + PyDict_SetItemString(freq_constants, const_name, pykey); \ + Py_DECREF(pykey); \ + Py_DECREF(aliases); } + + +static int init_freq_group(int num_items, int num_roots, int group_const, + char item_abbrevs[][2][10], char group_prefixes[][10], + char item_const_names[][10]) { + + int i; + + for (i = 0; i < num_items; i++) { + + PyObject *aliases; + int j, size, k; + + if (i == 0) { k = 3; } else { k = 2; } + + size = num_roots * k; + + aliases = PyTuple_New(size); + + for (j = 0; j < num_roots; j++) { + PyObject *alias_v1, *alias_v2; + char *root, *alt; + + if ((root = malloc((26) * sizeof(char))) == NULL) return INT_ERR_CODE; + if ((alt = malloc((26) * sizeof(char))) == NULL) return INT_ERR_CODE; + + strcpy(root, group_prefixes[j]); + strcpy(alt, group_prefixes[j]); + + if (i == 0) { + PyObject *alias = PyString_FromString(root); + PyTuple_SET_ITEM(aliases, j*k + 2, alias); + } + + strcat(root, "-"); + strcat(root, item_abbrevs[i][0]); + strcat(alt, "-"); + strcat(alt, item_abbrevs[i][1]); + + alias_v1 = PyString_FromString(root); + alias_v2 = PyString_FromString(alt); + + free(root); + free(alt); + + PyTuple_SET_ITEM(aliases, j*k, alias_v1); + PyTuple_SET_ITEM(aliases, j*k + 1, alias_v2); + } + + INIT_FREQ(item_const_names[i], group_const+i, aliases); + } + + return 0; +} + +/* take a dictionary with integer keys and tuples of strings for values, + and populate a dictionary with all the strings as keys and integers + for values */ +static int reverse_dict(PyObject *source, PyObject *dest) { + + PyObject *key, *value; + + int pos = 0; + + while (PyDict_Next(source, &pos, &key, &value)) { + PyObject *tuple_iter; + PyObject *item; + + if((tuple_iter = PyObject_GetIter(value)) == NULL) return INT_ERR_CODE; + + while (item = PyIter_Next(tuple_iter)) { + PyDict_SetItem(dest, item, key); + Py_DECREF(item); + } + Py_DECREF(tuple_iter); + } + return 0; +} + +static int build_freq_dict() { + + char ANN_prefixes[8][10] = { "A", "Y", "ANN", "ANNUAL", "ANNUALLY", + "YR", "YEAR", "YEARLY" }; + char WK_prefixes[4][10] = { "W", "WK", "WEEK", "WEEKLY" }; + + /* Note: order of this array must match up with how the Annual + frequency constants are lined up */ + char month_names[12][2][10] = { + { "DEC", "DECEMBER" }, + { "JAN", "JANUARY" }, + { "FEB", "FEBRUARY" }, + { "MAR", "MARCH" }, + { "APR", "APRIL" }, + { "MAY", "MAY" }, + { "JUN", "JUNE" }, + { "JUL", "JULY" }, + { "AUG", "AUGUST" }, + { "SEP", "SEPTEMBER" }, + { "OCT", "OCTOBER" }, + { "NOV", "NOVEMBER" }}; + + char ANN_const_names[12][10] = { + "FR_ANNDEC", + "FR_ANNJAN", + "FR_ANNFEB", + "FR_ANNMAR", + "FR_ANNAPR", + "FR_ANNMAY", + "FR_ANNJUN", + "FR_ANNJUL", + "FR_ANNAUG", + "FR_ANNSEP", + "FR_ANNOCT", + "FR_ANNNOV"}; + + char day_names[7][2][10] = { + { "SUN", "SUNDAY" }, + { "MON", "MONDAY" }, + { "TUE", "TUESDAY" }, + { "WED", "WEDNESDAY" }, + { "THU", "THURSDAY" }, + { "FRI", "FRIDAY" }, + { "SAT", "SATURDAY" }}; + + char WK_const_names[7][10] = { + "FR_WKSUN", + "FR_WKMON", + "FR_WKTUE", + "FR_WKWED", + "FR_WKTHU", + "FR_WKFRI", + "FR_WKSAT"}; + + PyObject *aliases; + + freq_dict = PyDict_New(); + freq_dict_rev = PyDict_New(); + freq_constants = PyDict_New(); + + aliases = Py_BuildValue("(ssss)", "Q", "QTR", "QUARTER", "QUARTERLY"); + INIT_FREQ("FR_QTR", FR_QTR, aliases); + + aliases = Py_BuildValue("(ssss)", "M", "MTH", "MONTH", "MONTHLY"); + INIT_FREQ("FR_MTH", FR_MTH, aliases); + + aliases = Py_BuildValue("(ssss)", "B", "BUS", "BUSINESS", "BUSINESSLY"); + INIT_FREQ("FR_BUS", FR_BUS, aliases); + + aliases = Py_BuildValue("(ssss)", "D", "DAY", "DLY", "DAILY"); + INIT_FREQ("FR_DAY", FR_DAY, aliases); + + aliases = Py_BuildValue("(sssss)", "H", "HR", "HOUR", "HRLY", "HOURLY"); + INIT_FREQ("FR_HR", FR_HR, aliases); + + aliases = Py_BuildValue("(ssss)", "T", "MIN", "MINUTE", "MINUTELY"); + INIT_FREQ("FR_MIN", FR_MIN, aliases); + + aliases = Py_BuildValue("(ssss)", "S", "SEC", "SECOND", "SECONDLY"); + INIT_FREQ("FR_SEC", FR_SEC, aliases); + + aliases = Py_BuildValue("(ssss)", "U", "UND", "UNDEF", "UNDEFINED"); + INIT_FREQ("FR_UND", FR_UND, aliases); + + ADD_FREQ_CONSTANT("FR_ANN", FR_ANN); + + if(init_freq_group(12, 8, FR_ANN, + month_names, ANN_prefixes, ANN_const_names) == INT_ERR_CODE) { + return INT_ERR_CODE; + } + + ADD_FREQ_CONSTANT("FR_WK", FR_WK); + + if(init_freq_group(7, 4, FR_WK, + day_names, WK_prefixes, WK_const_names) == INT_ERR_CODE) { + return INT_ERR_CODE; + } + + if(reverse_dict(freq_dict, freq_dict_rev) == INT_ERR_CODE) { + return INT_ERR_CODE; + } + + return 0; +} + + +/* take user specified frequency and convert to int representation + of the frequency */ +static int check_freq(PyObject *freq_spec) { + + if (PyInt_Check(freq_spec)) { + return (int)PyInt_AsLong(freq_spec); + } else if (PyString_Check(freq_spec)) { + char *freq_str, *freq_str_uc; + PyObject *freq_val; + + freq_str = PyString_AsString(freq_spec); + if((freq_str_uc = str_uppercase(freq_str)) == NULL) {return INT_ERR_CODE;} + + freq_val = PyDict_GetItemString(freq_dict_rev, freq_str_uc); + + free(freq_str_uc); + + if (freq_val == NULL) { + PyErr_SetString(PyExc_ValueError, "invalid frequency specification"); + return INT_ERR_CODE; + } else { + int ret_val = (int)PyInt_AsLong(freq_val); + return ret_val; + } + } else if (freq_spec == Py_None) { + return FR_UND; + } else { + int retval = (int)PyInt_AsLong(freq_spec); + if (PyErr_Occurred()) { + PyErr_SetString(PyExc_ValueError, "invalid frequency specification"); + return INT_ERR_CODE; + } else { return retval; } + } + +} + static PyObject * -cseries_convert(PyObject *self, PyObject *args) +DateObject_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { + + DateObject *self; + + self = (DateObject*)type->tp_alloc(type, 0); + if (self != NULL) { + // initialize attributes that need initializing in here + self->freq = FR_UND; + self->value = -1; + } + + return (PyObject *)self; +} + +/* for use in C code */ +static DateObject * +DateObject_New() { + PyObject *dummy; + return (DateObject*)DateObject_new(&DateType, dummy, dummy); +} + +#define INIT_ERR(errortype, errmsg) PyErr_SetString(errortype,errmsg);return -1 + +static int +DateObject_init(DateObject *self, PyObject *args, PyObject *kwds) { + + PyObject *freq=NULL, *value=NULL, *datetime=NULL, *string=NULL; + char *INSUFFICIENT_MSG = "insufficient parameters to initialize Date"; + + int def_info=INT_ERR_CODE; + + int year=def_info, month=def_info, day=def_info, quarter=def_info, + hour=def_info, minute=def_info, second=def_info; + + int free_dt=0; + + static char *kwlist[] = {"freq", "value", "string", + "year", "month", "day", "quarter", + "hour", "minute", "second", + "datetime", NULL}; + + if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOiiiiiiiO", kwlist, + &freq, &value, &string, + &year, &month, &day, &quarter, + &hour, &minute, &second, + &datetime)) return -1; + + if (PyObject_HasAttrString(freq, "freq")) { + PyObject *freq_attr = PyObject_GetAttrString(freq, "freq"); + self->freq = PyInt_AS_LONG(freq_attr); + Py_DECREF(freq_attr); + } else { + if((self->freq = check_freq(freq)) == INT_ERR_CODE) return -1; + } + + if ((value && PyString_Check(value)) || string) { + + PyObject *string_arg = PyTuple_New(1); + int freq_group = get_freq_group(self->freq); + + free_dt = 1; + + if (!string) { + string = value; + } + + PyTuple_SET_ITEM(string_arg, 0, string); + Py_INCREF(string); + + if (freq_group == FR_HR || + freq_group == FR_MIN || + freq_group == FR_SEC) + { datetime = PyEval_CallObject(DateTimeFromString, string_arg); } + else { datetime = PyEval_CallObject(DateFromString, string_arg); } + + Py_DECREF(string_arg); + + value = NULL; + } + + if (value) { + self->value = PyInt_AsLong(value); + } else { + + int freq_group = get_freq_group(self->freq); + + if (datetime) { + year=PyDateTime_GET_YEAR(datetime); + month=PyDateTime_GET_MONTH(datetime); + day=PyDateTime_GET_DAY(datetime); + hour=PyDateTime_DATE_GET_HOUR(datetime); + minute=PyDateTime_DATE_GET_MINUTE(datetime); + second=PyDateTime_DATE_GET_SECOND(datetime); + } + + if (!datetime) { + + // First, some basic checks..... + if (year == def_info) { + INIT_ERR(PyExc_ValueError, INSUFFICIENT_MSG); + } + if (self->freq == FR_BUS || + self->freq == FR_DAY || + self->freq == FR_WK || + self->freq == FR_UND) { + if (month == def_info || day == def_info) { + INIT_ERR(PyExc_ValueError, INSUFFICIENT_MSG); + } + + // if FR_BUS, check for week day + + } else if (self->freq == FR_MTH) { + if (month == def_info) { + INIT_ERR(PyExc_ValueError, INSUFFICIENT_MSG); + } + } else if (self->freq == FR_QTR) { + if (quarter == def_info && month == def_info) { + INIT_ERR(PyExc_ValueError, INSUFFICIENT_MSG); + } else if (month != def_info) { + quarter = (int)asfreq_MtoQ(month, '-', &NULL_AF_INFO); + } + } else if (self->freq == FR_SEC) { + if (month == def_info || + day == def_info || + second == def_info) { + INIT_ERR(PyExc_ValueError, INSUFFICIENT_MSG); + } + if (hour == def_info) { + hour = second/3600; + minute = (second % 3600)/60; + second = second % 60; + } else if (minute == def_info) { + INIT_ERR(PyExc_ValueError, INSUFFICIENT_MSG); + } + } else if (self->freq == FR_MIN) { + if (month == def_info || + day == def_info || + minute == def_info) { + INIT_ERR(PyExc_ValueError, INSUFFICIENT_MSG); + } + if (hour == def_info) { + hour = minute/60; + minute = minute % 60; + } + } else if (self->freq == FR_HR) { + if (month == def_info || + day == def_info || + hour == def_info) { + INIT_ERR(PyExc_ValueError, INSUFFICIENT_MSG); + } + } + + } + + if (self->freq == FR_SEC) { + long absdays, delta; + absdays = absdate_from_ymd(year, month, day); + delta = (absdays - HIGHFREQ_ORIG); + self->value = (int)(delta*86400 + hour*3600 + minute*60 + second + 1); + } else if (self->freq == FR_MIN) { + long absdays, delta; + absdays = absdate_from_ymd(year, month, day); + delta = (absdays - HIGHFREQ_ORIG); + self->value = (int)(delta*1440 + hour*60 + minute + 1); + } else if (self->freq == FR_HR) { + long absdays, delta; + absdays = absdate_from_ymd(year, month, day); + delta = (absdays - HIGHFREQ_ORIG); + self->value = (int)(delta*24 + hour + 1); + } else if (self->freq == FR_DAY) { + self->value = (int)absdate_from_ymd(year, month, day); + } else if (self->freq == FR_UND) { + self->value = (int)absdate_from_ymd(year, month, day); + } else if (self->freq == FR_BUS) { + long weeks, days; + days = absdate_from_ymd(year, month, day); + weeks = days/7; + self->value = (int)(days - weeks*2); + } else if (freq_group == FR_WK) { + int adj_ordinal; + int ordinal = (int)absdate_from_ymd(year, month, day); + int day_adj = (7 - (self->freq - FR_WK)) % 7; + + adj_ordinal = ordinal + ((7 - day_adj) - ordinal % 7) % 7; + self->value = adj_ordinal/7; + } else if (self->freq == FR_MTH) { + self->value = (year-1)*12 + month; + } else if (self->freq == FR_QTR) { + self->value = (year-1)*4 + quarter; + } else if (freq_group == FR_ANN) { + self->value = year; + } + + } + + if (free_dt) { Py_DECREF(datetime); } + + return 0; +} + +static PyMemberDef DateObject_members[] = { + {"freq", T_INT, offsetof(DateObject, freq), 0, + "frequency"}, + {"value", T_INT, offsetof(DateObject, value), 0, + "integer representation of the Date"}, + {NULL} /* Sentinel */ +}; + +static char DateObject_toordinal_doc[] = +"Return the proleptic Gregorian ordinal of the date, where January 1 of\n" +"year 1 has ordinal 1"; +static PyObject * +DateObject_toordinal(DateObject* self) { + if (self->freq == FR_DAY) { + return PyInt_FromLong(self->value); + } else { + long (*toDaily)(long, char, struct asfreq_info*) = NULL; + struct asfreq_info af_info; + + toDaily = get_asfreq_func(self->freq, FR_DAY, 0); + get_asfreq_info(self->freq, FR_DAY, &af_info); + + return PyInt_FromLong(toDaily(self->value, 'A', &af_info)); + } +} + +static char DateObject_asfreq_doc[] = +"Returns a date converted to a specified frequency.\n\n" +":Parameters:\n" +" - freq : string/int\n" +" Frequency to convert the Date to. Accepts any valid frequency\n" +" specification (string or integer)\n" +" - relation :string *['After']*\n" +" Applies only when converting a lower frequency Date to a higher\n" +" frequency Date, or when converting a weekend Date to a business\n" +" frequency Date. Valid values are 'before', 'after', 'b', and 'a'."; +static PyObject * +DateObject_asfreq(DateObject *self, PyObject *args, PyObject *kwds) +{ + + PyObject *freq=NULL; + char *relation_raw=NULL; + char *relation_uc; + char relation; + int invalid_relation=0; + int toFreq; + int result_val; + DateObject *result = DateObject_New(); + + static char *kwlist[] = {"freq", "relation", NULL}; + + long (*asfreq_func)(long, char, struct asfreq_info*) = NULL; + struct asfreq_info af_info; + + if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|s", kwlist, + &freq, &relation_raw)) return NULL; + + if(relation_raw) { + if (strlen(relation_raw) > 0) { + if((relation_uc = str_uppercase(relation_raw)) == NULL) + {return PyErr_NoMemory();} + + if (strcmp(relation_uc, "BEFORE") == 0 || + strcmp(relation_uc, "B") == 0 || + strcmp(relation_uc, "AFTER") == 0 || + strcmp(relation_uc, "A") == 0) { + relation = relation_uc[0]; + } else { invalid_relation=1; } + } else { + invalid_relation=1; + } + + if (invalid_relation) { + PyErr_SetString(PyExc_ValueError,"Invalid relation specification"); + return NULL; + } + } else { + relation = 'A'; + } + + if ((toFreq = check_freq(freq)) == INT_ERR_CODE) return NULL; + + get_asfreq_info(self->freq, toFreq, &af_info); + asfreq_func = get_asfreq_func(self->freq, toFreq, 0); + + result_val = asfreq_func(self->value, relation, &af_info); + + result->freq = toFreq; + result->value = result_val; + + return (PyObject*)result; + +} + +static char DateObject_strfmt_doc[] = +"Returns string representation of Date object according to format specified.\n\n" +":Parameters:\n" +" - fmt : string\n" +" Formatting string. Uses the same directives as in the time.strftime\n" +" function in the standard Python time module. In addition, a %q directive\n" +" directive is recognized which represents the 'quarter' of the date"; +static PyObject * +DateObject_strfmt(DateObject *self, PyObject *args) +{ + + char *orig_fmt_str, *fmt_str; + char *result; + + char extra_fmts[1][2][10] = {{"%q", "^`XZ`^"}}; + int extra_fmts_found[1] = {0}; + int extra_fmts_found_one = 0; + struct tm c_date; + struct date_info tempDate; + long absdate; + double abstime; + int i, result_len, special_found=0; + PyObject *py_result; + + long (*toDaily)(long, char, struct asfreq_info*) = NULL; + struct asfreq_info af_info; + + if (!PyArg_ParseTuple(args, "s:strfmt(fmt)", &orig_fmt_str)) return NULL; + + toDaily = get_asfreq_func(self->freq, FR_DAY, 0); + get_asfreq_info(self->freq, FR_DAY, &af_info); + + absdate = toDaily(self->value, 'A', &af_info); + abstime = getAbsTime(self->freq, absdate, self->value); + + if(dInfoCalc_SetFromAbsDateTime(&tempDate, absdate, abstime, + GREGORIAN_CALENDAR)) return NULL; + + // populate standard C date struct with info from our date_info struct + c_date.tm_sec = (int)tempDate.second; + c_date.tm_min = tempDate.minute; + c_date.tm_hour = tempDate.hour; + c_date.tm_mday = tempDate.day; + c_date.tm_mon = tempDate.month - 1; + c_date.tm_year = tempDate.year - 1900; + c_date.tm_wday = tempDate.day_of_week; + c_date.tm_yday = tempDate.day_of_year; + c_date.tm_isdst = -1; + + result_len = strlen(orig_fmt_str) + 50; + if ((result = malloc(result_len * sizeof(char))) == NULL) {return PyErr_NoMemory();} + + fmt_str = orig_fmt_str; + + // replace any special format characters with their place holder + for(i=0; i < 1; i++) { + char *special_loc; + if ((special_loc = strstr(fmt_str,extra_fmts[i][0])) != NULL) { + char *tmp_str = fmt_str; + fmt_str = str_replace(fmt_str, extra_fmts[i][0], + extra_fmts[i][1]); + /* only free the previous loop value if this is not the first + special format string found */ + if (extra_fmts_found_one) { free(tmp_str); } + + if (fmt_str == NULL) {return NULL;} + + extra_fmts_found[i] = 1; + extra_fmts_found_one = 1; + } + } + + strftime(result, result_len, fmt_str, &c_date); + if (extra_fmts_found_one) { free(fmt_str); } + + // replace any place holders with the appropriate value + for(i=0; i < 1; i++) { + if (extra_fmts_found[i]) { + char *tmp_str = result; + char *extra_str; + + if(strcmp(extra_fmts[i][0], "%q") == 0) { + if ((extra_str = malloc(2 * sizeof(char))) == NULL) { + free(tmp_str); + return PyErr_NoMemory(); + } + + sprintf(extra_str, "%i", tempDate.quarter); + } else { + PyErr_SetString(PyExc_RuntimeError,"Unrecogized fmt string"); + return NULL; + } + + result = str_replace(result, extra_fmts[i][1], extra_str); + free(tmp_str); + if (result == NULL) { return NULL; } + } + } + + py_result = PyString_FromString(result); + free(result); + + return py_result; +} + +static PyObject * +DateObject___str__(DateObject* self) +{ + + int freq_group = get_freq_group(self->freq); + PyObject *string_arg, *retval; + + if (freq_group == FR_ANN) { string_arg = Py_BuildValue("(s)", "%Y"); } + else if (freq_group == FR_QTR) { string_arg = Py_BuildValue("(s)", "%YQ%q"); } + else if (freq_group == FR_MTH) { string_arg = Py_BuildValue("(s)", "%b-%Y"); } + else if (freq_group == FR_DAY || + freq_group == FR_BUS || + freq_group == FR_WK || + freq_group == FR_UND) { string_arg = Py_BuildValue("(s)", "%d-%b-%Y"); } + else if (freq_group == FR_HR) { string_arg = Py_BuildValue("(s)", "%d-%b-%Y %H:00"); } + else if (freq_group == FR_MIN) { string_arg = Py_BuildValue("(s)", "%d-%b-%Y %H:%M"); } + else if (freq_group == FR_SEC) { string_arg = Py_BuildValue("(s)", "%d-%b-%Y %H:%M:%S"); } + + if (string_arg == NULL) { return NULL; } + + retval = DateObject_strfmt(self, string_arg); + Py_DECREF(string_arg); + + return retval; +} + +static PyObject * +DateObject_freqstr(DateObject *self, void *closure) { + PyObject *key = PyInt_FromLong(self->freq); + PyObject *freq_aliases = PyDict_GetItem(freq_dict, key); + PyObject *main_alias = PyTuple_GET_ITEM(freq_aliases, 0); + Py_DECREF(key); + Py_INCREF(main_alias); + return main_alias; +} + + +static PyObject * +DateObject___repr__(DateObject* self) +{ + PyObject *py_str_rep, *py_freqstr, *py_repr; + char *str_rep, *freqstr, *repr; + int repr_len; + + py_str_rep = DateObject___str__(self); + if (py_str_rep == NULL) { return NULL; } + + py_freqstr = DateObject_freqstr(self, NULL); + + str_rep = PyString_AsString(py_str_rep); + freqstr = PyString_AsString(py_freqstr); + + repr_len = strlen(str_rep) + strlen(freqstr) + 6; + + if((repr = malloc((repr_len + 1) * sizeof(char))) == NULL) + { return PyErr_NoMemory(); } + + strcpy(repr, "<"); + strcat(repr, freqstr); + strcat(repr, " : "); + strcat(repr, str_rep); + strcat(repr, ">"); + + py_repr = PyString_FromString(repr); + + Py_DECREF(py_str_rep); + Py_DECREF(py_freqstr); + + free(repr); + + return py_repr; +} + +/****************************** + These methods seem rather useless. May or may not implement them. +fromordinal(self, ordinal): + return Date(self.freq, datetime=dt.datetime.fromordinal(ordinal)) +tostring(self): + return str(self) +toobject(self): + return self +isvalid(self): + return True +*******************************/ + + +static DateObject * +DateObject_FromFreqAndValue(int freq, int value) { + + DateObject *result = DateObject_New(); + + PyObject *args = PyTuple_New(0); + PyObject *kw = PyDict_New(); + PyObject *py_freq = PyInt_FromLong(freq); + PyObject *py_value = PyInt_FromLong(value); + + PyDict_SetItemString(kw, "freq", py_freq); + PyDict_SetItemString(kw, "value", py_value); + + Py_DECREF(py_freq); + Py_DECREF(py_value); + + DateObject_init(result, args, kw); + + Py_DECREF(args); + Py_DECREF(kw); + + return result; +} + +static PyObject * +DateObject_date_plus_int(PyObject *date, PyObject *pyint) { + DateObject *dateobj = (DateObject*)date; + if (DateObject_Check(pyint)) { + PyErr_SetString(PyExc_TypeError, "Cannot add two Date objects"); + return NULL; + } + + return (PyObject*)DateObject_FromFreqAndValue(dateobj->freq, PyInt_AsLong(pyint) + dateobj->value); +} + +static PyObject * +DateObject___add__(PyObject *left, PyObject *right) +{ + if (DateObject_Check(left)) { + return DateObject_date_plus_int(left, right); + } else { + return DateObject_date_plus_int(right, left); + } +} + +static PyObject * +DateObject___subtract__(PyObject *left, PyObject *right) +{ + int result; + DateObject *dleft; + if (!DateObject_Check(left)) { + PyErr_SetString(PyExc_ValueError, "Cannot subtract Date from non-Date value"); + return NULL; + } + + dleft = (DateObject*)left; + + if (DateObject_Check(right)) { + DateObject *dright = (DateObject*)right; + if (dleft->freq != dright->freq) { + PyErr_SetString(PyExc_ValueError, "Cannot subtract Dates with different frequency"); + return NULL; + } + result = dleft->value - dright->value; + return PyInt_FromLong(result); + } else { + result = dleft->value - PyInt_AsLong(right); + return (PyObject*)DateObject_FromFreqAndValue(dleft->freq, result); + } +} + +static int +DateObject___compare__(DateObject * obj1, DateObject * obj2) +{ + if (obj1->freq != obj2->freq) { + PyErr_SetString(PyExc_ValueError, + "Cannot compare dates with different frequency"); + return -1; + } + + if (obj1->value < obj2->value) return -1; + if (obj1->value > obj2->value) return 1; + if (obj1->value == obj2->value) return 0; + +} + +static long +DateObject___hash__(DateObject *self) +{ + register int freq_group = get_freq_group(self->freq); + + /* within a given frequency, hash values are guaranteed to be unique + for different dates. For different frequencies, we make a reasonable + effort to ensure hash values will be unique, but it is not guaranteed */ + if (freq_group == FR_BUS) { + return self->value + 10000000; + } else if (freq_group == FR_WK) { + return self->value + 100000000; + } else { return self->value; } +} + +static PyObject * +DateObject___int__(DateObject *self) +{ + return PyInt_FromLong(self->value); +} + +static PyObject * +DateObject___float__(DateObject *self) +{ + return PyFloat_FromDouble((double)(self->value)); +} + +/*************************************************** + ====== Date Properties ====== +****************************************************/ + +// helper function for date property funcs +static int +DateObject_set_date_info(DateObject *self, struct date_info *dinfo) { + PyObject *daily_obj = DateObject_toordinal(self); + long absdate = PyInt_AsLong(daily_obj); + + Py_DECREF(daily_obj); + + if(dInfoCalc_SetFromAbsDate(dinfo, absdate, + GREGORIAN_CALENDAR)) return -1; + + return 0; +} + +// helper function for date property funcs +static int +DateObject_set_date_info_wtime(DateObject *self, struct date_info *dinfo) { + PyObject *daily_obj = DateObject_toordinal(self); + long absdate = PyInt_AsLong(daily_obj); + double abstime; + + Py_DECREF(daily_obj); + + abstime = getAbsTime(self->freq, absdate, self->value); + + if(dInfoCalc_SetFromAbsDateTime(dinfo, absdate, abstime, + GREGORIAN_CALENDAR)) return -1; + + return 0; +} + +static PyObject * +DateObject_year(DateObject *self, void *closure) { + struct date_info dinfo; + if(DateObject_set_date_info(self, &dinfo) == -1) return NULL; + return PyInt_FromLong(dinfo.year); +} + +static PyObject * +DateObject_quarter(DateObject *self, void *closure) { + struct date_info dinfo; + if(DateObject_set_date_info(self, &dinfo) == -1) return NULL; + return PyInt_FromLong(dinfo.quarter); +} + +static PyObject * +DateObject_month(DateObject *self, void *closure) { + struct date_info dinfo; + if(DateObject_set_date_info(self, &dinfo) == -1) return NULL; + return PyInt_FromLong(dinfo.month); +} + +static PyObject * +DateObject_day(DateObject *self, void *closure) { + struct date_info dinfo; + if(DateObject_set_date_info(self, &dinfo) == -1) return NULL; + return PyInt_FromLong(dinfo.day); +} + +static PyObject * +DateObject_day_of_week(DateObject *self, void *closure) { + struct date_info dinfo; + if(DateObject_set_date_info(self, &dinfo) == -1) return NULL; + return PyInt_FromLong(dinfo.day_of_week); +} + +static PyObject * +DateObject_day_of_year(DateObject *self, void *closure) { + struct date_info dinfo; + if(DateObject_set_date_info(self, &dinfo) == -1) return NULL; + return PyInt_FromLong(dinfo.day_of_year); +} + +static PyObject * +DateObject_week(DateObject *self, void *closure) { + struct date_info dinfo; + if(DateObject_set_date_info(self, &dinfo) == -1) return NULL; + return PyInt_FromLong(dInfoCalc_ISOWeek(&dinfo)); +} + +static PyObject * +DateObject_hour(DateObject *self, void *closure) { + struct date_info dinfo; + if(DateObject_set_date_info_wtime(self, &dinfo) == -1) return NULL; + return PyInt_FromLong(dinfo.hour); +} + +static PyObject * +DateObject_minute(DateObject *self, void *closure) { + struct date_info dinfo; + if(DateObject_set_date_info_wtime(self, &dinfo) == -1) return NULL; + return PyInt_FromLong(dinfo.minute); +} + +static PyObject * +DateObject_second(DateObject *self, void *closure) { + struct date_info dinfo; + if(DateObject_set_date_info_wtime(self, &dinfo) == -1) return NULL; + return PyInt_FromLong((int)dinfo.second); +} + +static PyObject * +DateObject_datetime(DateObject *self, void *closure) { + PyObject *datetime; + struct date_info dinfo; + if(DateObject_set_date_info_wtime(self, &dinfo) == -1) return NULL; + datetime = PyDateTime_FromDateAndTime(dinfo.year, dinfo.month, + dinfo.day, dinfo.hour, + dinfo.minute, (int)dinfo.second, 0); + return datetime; +} + +static int +DateObject_ReadOnlyErr(DateObject *self, PyObject *value, void *closure) { + PyErr_SetString(PyExc_AttributeError, "Cannot set read-only property"); + return -1; +} + +static PyGetSetDef DateObject_getseters[] = { + {"year", (getter)DateObject_year, (setter)DateObject_ReadOnlyErr, + "Returns the year.", NULL}, + {"quarter", (getter)DateObject_quarter, (setter)DateObject_ReadOnlyErr, + "Returns the quarter.", NULL}, + {"month", (getter)DateObject_month, (setter)DateObject_ReadOnlyErr, + "Returns the month.", NULL}, + {"week", (getter)DateObject_week, (setter)DateObject_ReadOnlyErr, + "Returns the week.", NULL}, + {"day", (getter)DateObject_day, (setter)DateObject_ReadOnlyErr, + "Returns the day of month.", NULL}, + {"day_of_week", (getter)DateObject_day_of_week, (setter)DateObject_ReadOnlyErr, + "Returns the day of week.", NULL}, + {"day_of_year", (getter)DateObject_day_of_year, (setter)DateObject_ReadOnlyErr, + "Returns the day of year.", NULL}, + {"second", (getter)DateObject_second, (setter)DateObject_ReadOnlyErr, + "Returns the second.", NULL}, + {"minute", (getter)DateObject_minute, (setter)DateObject_ReadOnlyErr, + "Returns the minute.", NULL}, + {"hour", (getter)DateObject_hour, (setter)DateObject_ReadOnlyErr, + "Returns the hour.", NULL}, + + {"freqstr", (getter)DateObject_freqstr, (setter)DateObject_ReadOnlyErr, + "Returns the string representation of frequency.", NULL}, + {"datetime", (getter)DateObject_datetime, (setter)DateObject_ReadOnlyErr, + "Returns the Date object converted to standard python datetime object", + NULL}, + + {NULL} /* Sentinel */ +}; + + +static PyNumberMethods DateObject_as_number = { + (binaryfunc)DateObject___add__, /* nb_add */ + (binaryfunc)DateObject___subtract__, /* nb_subtract */ + 0, /* nb_multiply */ + 0, /* nb_divide */ + 0, /* nb_remainder */ + 0, /* nb_divmod */ + 0, /* nb_power */ + 0, /* nb_negative */ + 0, /* nb_positive */ + 0, /* nb_absolute */ + 0, /* nb_nonzero */ + 0, /* nb_invert */ + 0, /* nb_lshift */ + 0, /* nb_rshift */ + 0, /* nb_and */ + 0, /* nb_xor */ + 0, /* nb_or */ + 0, /* nb_coerce */ + (unaryfunc)DateObject___int__, /* nb_int */ + (unaryfunc)0, /* nb_long */ + (unaryfunc)DateObject___float__, /* nb_float */ + (unaryfunc)0, /* nb_oct */ + (unaryfunc)0, /* nb_hex */ +}; + +static PyMethodDef DateObject_methods[] = { + {"toordinal", (PyCFunction)DateObject_toordinal, METH_NOARGS, + DateObject_toordinal_doc}, + {"strfmt", (PyCFunction)DateObject_strfmt, METH_VARARGS, + DateObject_strfmt_doc}, + {"asfreq", (PyCFunction)DateObject_asfreq, METH_VARARGS | METH_KEYWORDS, + DateObject_asfreq_doc}, + {NULL} /* Sentinel */ +}; + + +static PyTypeObject DateType = { + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + "timeseries.Date", /* tp_name */ + sizeof(DateObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)DateObject_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + (cmpfunc)DateObject___compare__, /* tp_compare */ + (reprfunc)DateObject___repr__, /* tp_repr */ + &DateObject_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)DateObject___hash__, /* tp_hash */ + 0, /* tp_call*/ + (reprfunc)DateObject___str__, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | /* tp_flags */ + Py_TPFLAGS_CHECKTYPES | + Py_TPFLAGS_BASETYPE, + "Defines a Date object, as the combination of a date and a frequency.\n" + "Several options are available to construct a Date object explicitly:\n\n" + "- Give appropriate values to the `year`, `month`, `day`, `quarter`, `hours`,\n" + " `minutes`, `seconds` arguments.\n\n" + " >>> td.Date(freq='Q',year=2004,quarter=3)\n" + " >>> td.Date(freq='D',year=2001,month=1,day=1)\n\n" + "- Use the `string` keyword. This method uses a modified version of the\n" + " mx.DateTime parser submodule. More information is available in its\n" + " documentation.\n\n" + " >>> ts.Date('D', '2007-01-01')\n\n" + "- Use the `datetime` keyword with an existing datetime.datetime object.\n\n" + " >>> td.Date('D', datetime=datetime.datetime.now())", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DateObject_methods, /* tp_methods */ + DateObject_members, /* tp_members */ + DateObject_getseters, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)DateObject_init, /* tp_init */ + 0, /* tp_alloc */ + DateObject_new, /* tp_new */ +}; + + +/////////////////////////////////////////////////////////////////////// + +static char cseries_check_freq_doc[] = +"translate user specified frequency into frequency constant"; +static PyObject * +cseries_check_freq(PyObject *self, PyObject *args) { + + PyObject *freq; + int freq_val; + + if (!PyArg_ParseTuple(args, "O:check_freq(freq)", &freq)) return NULL; + if ((freq_val = check_freq(freq)) == INT_ERR_CODE) return NULL; + + return PyInt_FromLong(freq_val); +} + +static char cseries_check_freq_str_doc[] = +"translate user specified frequency into standard string representation"; +static PyObject * +cseries_check_freq_str(PyObject *self, PyObject *args) { + + PyObject *alias_tuple, *result, *freq_key; + int freq_val; + + if ((freq_key = cseries_check_freq(self, args)) == NULL) return NULL; + + alias_tuple = PyDict_GetItem(freq_dict, freq_key); + result = PyTuple_GET_ITEM(alias_tuple, 0); + + Py_INCREF(result); + + Py_DECREF(freq_key); + + return result; +} + +static char cseries_thisday_doc[] = +"Returns today's date, at the given frequency\n\n" +":Parameters:\n" +" - freq : string/int\n" +" Frequency to convert the Date to. Accepts any valid frequency\n" +" specification (string or integer)\n"; +static PyObject * +cseries_thisday(PyObject *self, PyObject *args) { + + PyObject *freq, *init_args, *init_kwargs; + time_t rawtime; + struct tm *timeinfo; + int freq_val; + + DateObject *secondly_date; + + if (!PyArg_ParseTuple(args, "O:thisday(freq)", &freq)) return NULL; + + if ((freq_val = check_freq(freq)) == INT_ERR_CODE) return NULL; + + time(&rawtime); + timeinfo = localtime(&rawtime); + + init_args = PyTuple_New(0); + init_kwargs = PyDict_New(); + + DICT_SETINT_STRKEY(init_kwargs, "freq", FR_SEC); + DICT_SETINT_STRKEY(init_kwargs, "year", timeinfo->tm_year+1900); + DICT_SETINT_STRKEY(init_kwargs, "month", timeinfo->tm_mon+1); + DICT_SETINT_STRKEY(init_kwargs, "day", timeinfo->tm_mday); + DICT_SETINT_STRKEY(init_kwargs, "hour", timeinfo->tm_hour); + DICT_SETINT_STRKEY(init_kwargs, "minute", timeinfo->tm_min); + DICT_SETINT_STRKEY(init_kwargs, "second", timeinfo->tm_sec); + + secondly_date = DateObject_New(); + DateObject_init(secondly_date, init_args, init_kwargs); + + Py_DECREF(init_args); + Py_DECREF(init_kwargs); + + if (freq_val != FR_SEC) { + DateObject *result = DateObject_New(); + + long (*asfreq_func)(long, char, struct asfreq_info*) = NULL; + struct asfreq_info af_info; + + int date_val; + + get_asfreq_info(FR_SEC, freq_val, &af_info); + asfreq_func = get_asfreq_func(FR_SEC, freq_val, 0); + + date_val = asfreq_func(secondly_date->value, 'A', &af_info); + + Py_DECREF(secondly_date); + + result->freq = freq_val; + result->value = date_val; + + return (PyObject*)result; + + } else { return (PyObject*)secondly_date; } +} + + +static char TimeSeries_convert_doc[] = ""; +static PyObject * +TimeSeries_convert(PyObject *self, PyObject *args) +{ PyObject *arrayTest; PyArrayObject *array, *newArray; PyArrayObject *mask, *newMask; @@ -1190,6 +2547,7 @@ npy_intp *dim, *newIdx; long currPerLen; char *position; + PyObject *fromFreq_arg, *toFreq_arg; int fromFreq, toFreq; char relation; struct asfreq_info af_info; @@ -1202,16 +2560,29 @@ returnVal = PyDict_New(); - if (!PyArg_ParseTuple(args, "OiislO:convert(array, fromfreq, tofreq, position, startIndex, mask)", &array, &fromFreq, &toFreq, &position, &startIndex, &mask)) return NULL; + if (!PyArg_ParseTuple(args, + "OOOslO:convert(array, fromfreq, tofreq, position, startIndex, mask)", + &array, &fromFreq_arg, &toFreq_arg, + &position, &startIndex, &mask)) return NULL; + if((fromFreq = check_freq(fromFreq_arg)) == INT_ERR_CODE) return NULL; + if((toFreq = check_freq(toFreq_arg)) == INT_ERR_CODE) return NULL; + if (toFreq == fromFreq) { - PyDict_SetItemString(returnVal, "values", (PyObject*)array); - PyDict_SetItemString(returnVal, "mask", (PyObject*)mask); + PyObject *sidx; + newArray = (PyArrayObject *)PyArray_Copy(array); + newMask = (PyArrayObject *)PyArray_Copy(mask); + sidx = PyInt_FromLong(startIndex); - Py_DECREF(array); - Py_DECREF(mask); + PyDict_SetItemString(returnVal, "values", (PyObject*)newArray); + PyDict_SetItemString(returnVal, "mask", (PyObject*)newMask); + PyDict_SetItemString(returnVal, "startindex", sidx); + Py_DECREF(newArray); + Py_DECREF(newMask); + Py_DECREF(sidx); + return returnVal; } @@ -1338,9 +2709,9 @@ return returnVal; } -static char cseries_asfreq_doc[] = ""; +static char DateArray_asfreq_doc[] = ""; static PyObject * -cseries_asfreq(PyObject *self, PyObject *args) +DateArray_asfreq(PyObject *self, PyObject *args) { PyArrayObject *fromDates, *toDates; PyArrayIterObject *iterFrom, *iterTo; @@ -1351,7 +2722,9 @@ long (*asfreq_main)(long, char, struct asfreq_info*) = NULL; struct asfreq_info af_info; - if (!PyArg_ParseTuple(args, "Oiis:asfreq(fromDates, fromfreq, tofreq, relation)", &fromDates, &fromFreq, &toFreq, &relation)) return NULL; + if (!PyArg_ParseTuple(args, + "Oiis:asfreq(fromDates, fromfreq, tofreq, relation)", + &fromDates, &fromFreq, &toFreq, &relation)) return NULL; get_asfreq_info(fromFreq, toFreq, &af_info); @@ -1388,45 +2761,9 @@ } -static int dInfo_year(struct date_info *dateObj) { return dateObj->year; } -static int dInfo_quarter(struct date_info *dateObj) { return dateObj->quarter; } -static int dInfo_month(struct date_info *dateObj) { return dateObj->month; } -static int dInfo_day(struct date_info *dateObj) { return dateObj->day; } -static int dInfo_day_of_year(struct date_info *dateObj) { return dateObj->day_of_year; } -static int dInfo_day_of_week(struct date_info *dateObj) { return dateObj->day_of_week; } -static int dInfo_week(struct date_info *dateObj) { return dInfoCalc_ISOWeek(dateObj); } -static int dInfo_hour(struct date_info *dateObj) { return dateObj->hour; } -static int dInfo_minute(struct date_info *dateObj) { return dateObj->minute; } -static int dInfo_second(struct date_info *dateObj) { return (int)dateObj->second; } - -static double getAbsTime(int freq, long dailyDate, long originalDate) { - - long startOfDay, periodsPerDay; - - switch(freq) - { - case FR_HR: - periodsPerDay = 24; - break; - case FR_MIN: - periodsPerDay = 24*60; - break; - case FR_SEC: - periodsPerDay = 24*60*60; - break; - default: - return 0; - } - - startOfDay = asfreq_DtoHIGHFREQ(dailyDate, 'B', periodsPerDay); - return (24*60*60)*((double)(originalDate - startOfDay))/((double)periodsPerDay); -} - - - -static char cseries_getDateInfo_doc[] = ""; +static char DateArray_getDateInfo_doc[] = ""; static PyObject * -cseries_getDateInfo(PyObject *self, PyObject *args) +DateArray_getDateInfo(PyObject *self, PyObject *args) { int freq; char *info; @@ -1513,162 +2850,50 @@ return (PyObject *) newArray; } -static char *str_replace(const char *s, const char *old, const char *new) -{ - char *ret; - int i, count = 0; - size_t newlen = strlen(new); - size_t oldlen = strlen(old); +static PyMethodDef cseries_methods[] = { - for (i = 0; s[i] != '\0'; i++) { - if (strstr(&s[i], old) == &s[i]) { - count++; - i += oldlen - 1; - } - } + {"TS_convert", TimeSeries_convert, METH_VARARGS, TimeSeries_convert_doc}, - ret = malloc(i + 1 + count * (newlen - oldlen)); - if (ret == NULL) return NULL; + {"DA_asfreq", DateArray_asfreq, METH_VARARGS, DateArray_asfreq_doc}, + {"DA_getDateInfo", DateArray_getDateInfo, METH_VARARGS, DateArray_getDateInfo_doc}, - i = 0; - while (*s) { - if (strstr(s, old) == s) { - strcpy(&ret[i], new); - i += newlen; - s += oldlen; - } else { - ret[i++] = *s++; - } - } - ret[i] = '\0'; + {"thisday", cseries_thisday, METH_VARARGS, cseries_thisday_doc}, + {"check_freq", cseries_check_freq, METH_VARARGS, cseries_check_freq_doc}, + {"check_freq_str", cseries_check_freq_str, METH_VARARGS, cseries_check_freq_str_doc}, - return ret; -} + {"set_callback_DateFromString", set_callback_DateFromString, METH_VARARGS, + set_callback_DateFromString_doc}, + {"set_callback_DateTimeFromString", set_callback_DateTimeFromString, METH_VARARGS, + set_callback_DateTimeFromString_doc}, -static char cseries_strfmt_doc[] = ""; -static PyObject * -cseries_strfmt(PyObject *self, PyObject *args) -{ - - char *orig_fmt_str, *fmt_str, *q_loc; - char *result; - char place_holder[] = "^`"; - struct tm c_date; - struct date_info tempDate; - int result_len; - PyObject *date, *py_result; - - if (!PyArg_ParseTuple(args, "Os:strfmt(datetime, fmt_str)", &date, &orig_fmt_str)) return NULL; - - if (dInfoCalc_SetFromDateAndTime(&tempDate, - PyDateTime_GET_YEAR(date), - PyDateTime_GET_MONTH(date), - PyDateTime_GET_DAY(date), - PyDateTime_DATE_GET_HOUR(date), - PyDateTime_DATE_GET_MINUTE(date), - PyDateTime_DATE_GET_SECOND(date), - GREGORIAN_CALENDAR)) return NULL; - - /* We need to modify the fmt_str passed in to handle our special syntax for quarters. - We can't modify the string passed in directly, so we must make a copy. */ - fmt_str = malloc((strlen(orig_fmt_str) + 1)*sizeof(char)); - strcpy(fmt_str, orig_fmt_str); - - if ((q_loc = strstr(fmt_str,"%q")) != NULL) { - q_loc = strstr(fmt_str,"%q"); - strncpy (q_loc,place_holder,2); - } - - c_date.tm_sec = (int)tempDate.second; - c_date.tm_min = tempDate.minute; - c_date.tm_hour = tempDate.hour; - c_date.tm_mday = tempDate.day; - c_date.tm_mon = tempDate.month - 1; - c_date.tm_year = tempDate.year - 1900; - c_date.tm_wday = tempDate.day_of_week; - c_date.tm_yday = tempDate.day_of_year; - c_date.tm_isdst = -1; - - result_len = strlen(orig_fmt_str) + 50; - - result = malloc(result_len * sizeof(char)); - - strftime(result, result_len, fmt_str, &c_date); - - if (q_loc != NULL) { - char *alt_result; - char q_str[2]; - - sprintf(q_str, "%i", tempDate.quarter); - alt_result = str_replace(result, place_holder, q_str); - py_result = PyString_FromString(alt_result); - free(result); - free(alt_result); - } else { - py_result = PyString_FromString(result); - free(result); - } - - return py_result; - -} - - -/////////////////////////////////////////////////////////////////////// - -//{"fpointer", cseries_fpointer, METH_VARARGS, cseries_fpointer_doc}, - -static PyMethodDef cseries_methods[] = { - {"strfmt", cseries_strfmt, METH_VARARGS, cseries_strfmt_doc}, - {"convert", cseries_convert, METH_VARARGS, cseries_convert_doc}, - {"asfreq", cseries_asfreq, METH_VARARGS, cseries_asfreq_doc}, - {"getDateInfo", cseries_getDateInfo, METH_VARARGS, cseries_getDateInfo_doc}, {NULL, NULL} }; PyMODINIT_FUNC initcseries(void) { - PyObject *m, *TSER_CONSTANTS; + PyObject *m; + + if (PyType_Ready(&DateType) < 0) return; + m = Py_InitModule3("cseries", cseries_methods, cseries_doc); + if (m == NULL) + return; + import_array(); PyDateTime_IMPORT; - TSER_CONSTANTS = PyDict_New(); + Py_INCREF(&DateType); + PyModule_AddObject(m, "Date", (PyObject *)&DateType); - // Add all the frequency constants to a python dictionary - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANN", FR_ANN); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNJAN", FR_ANNJAN); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNFEB", FR_ANNFEB); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNMAR", FR_ANNMAR); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNAPR", FR_ANNAPR); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNMAY", FR_ANNMAY); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNJUN", FR_ANNJUN); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNJUL", FR_ANNJUL); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNAUG", FR_ANNAUG); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNSEP", FR_ANNSEP); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNOCT", FR_ANNOCT); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNNOV", FR_ANNNOV); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_ANNDEC", FR_ANNDEC); + if(build_freq_dict(m) == INT_ERR_CODE) { + PyErr_SetString( \ + PyExc_ImportError, \ + "initialization of module timeseries.cseries failed"); + return; + }; - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_QTR", FR_QTR); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_MTH", FR_MTH); - - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WK", FR_WK); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKSUN", FR_WKSUN); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKSAT", FR_WKSAT); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKFRI", FR_WKFRI); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKTHU", FR_WKTHU); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKWED", FR_WKWED); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKTUE", FR_WKTUE); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_WKMON", FR_WKMON); - - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_BUS", FR_BUS); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_DAY", FR_DAY); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_HR", FR_HR); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_MIN", FR_MIN); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_SEC", FR_SEC); - ADD_INT_TO_DICT(TSER_CONSTANTS, "FR_UND", FR_UND); - - PyModule_AddObject(m, "TSER_CONSTANTS", TSER_CONSTANTS); + PyModule_AddObject(m, "freq_dict", freq_dict); + PyModule_AddObject(m, "freq_dict_rev", freq_dict_rev); + PyModule_AddObject(m, "freq_constants", freq_constants); } \ No newline at end of file Modified: trunk/Lib/sandbox/timeseries/tcore.py =================================================================== --- trunk/Lib/sandbox/timeseries/tcore.py 2007-03-20 14:42:18 UTC (rev 2851) +++ trunk/Lib/sandbox/timeseries/tcore.py 2007-03-20 14:44:08 UTC (rev 2852) @@ -13,19 +13,8 @@ import numpy import numpy.core.numeric as numeric -from scipy.interpolate import fitpack - import maskedarray as MA -from cseries import TSER_CONSTANTS - -"""add constants in cfame.FAME_CONSTANTS dictionary to global namespace -for this module""" - -_g = globals() -_g.update(TSER_CONSTANTS) - - #####--------------------------------------------------------------------------- #---- --- Generic functions --- #####--------------------------------------------------------------------------- @@ -48,149 +37,6 @@ #####--------------------------------------------------------------------------- -#---- --- Option conversion --- -#####--------------------------------------------------------------------------- -fmtobs_dict = {'UNDEFINED': ['UNDEF','UNDEFINED',None], - 'BEGINNING': ['BEGIN','BEGINNING'], - 'ENDING': ['END','ENDING'], - 'AVERAGED': ['AVERAGE','AVERAGE','MEAN'], - 'SUMMED': ['SUM','SUMMED'], - 'MAXIMUM': ['MAX','MAXIMUM','HIGH'], - 'MINIMUM': ['MIN','MINIMUM','LOW']} - -obs_dict = {None:None, - "UNDEFINED":None, - "UNDEF":None, - "BEGIN": first_unmasked_val, - "BEGINNING": first_unmasked_val, - "END": last_unmasked_val, - "ENDING": last_unmasked_val, - "AVERAGED": MA.average, - "AVERAGE": MA.average, - "MEAN": MA.average, - "SUMMED": MA.sum, - "SUM": MA.sum, - "MAXIMUM": MA.maximum, - "MAX": MA.maximum, - "MINIMUM": MA.minimum, - "MIN": MA.minimum, - } -obsDict = obs_dict -fmtobs_revdict = reverse_dict(fmtobs_dict) - -# -def fmtObserv(obStr): - "Converts a possible 'Observed' string into acceptable values." - if obStr is None: - return fmtobs_revdict[None] - elif obStr.upper() in fmtobs_revdict: - return fmtobs_revdict[obStr.upper()] - else: - raise ValueError("Invalid value for observed attribute: %s " % str(obStr)) - -_weekly_prefixes = ['W','WEEK','WEEKLY'] -_week_end_map = { - FR_WKSUN:'SUNDAY', - FR_WKSAT:'SATURDAY', - FR_WKFRI:'FRIDAY', - FR_WKTHU:'THURSDAY', - FR_WKWED:'WEDNESDAY', - FR_WKTUE:'TUESDAY', - FR_WKMON:'MONDAY'} - -def _gen_weekly_strs(day): - result = [] - for pr in _weekly_prefixes: - result += [pr+'-'+day_str for day_str in (day[:3], day)] - return result - -_annual_prefixes = ['A','Y','ANNUAL','ANNUALLY','YEAR','YEARLY'] -_year_end_map = { - FR_ANNJAN:'JANUARY', - FR_ANNFEB:'FEBRUARY', - FR_ANNMAR:'MARCH', - FR_ANNAPR:'APRIL', - FR_ANNMAY:'MAY', - FR_ANNJUN:'JUNE', - FR_ANNJUL:'JULY', - FR_ANNAUG:'AUGUST', - FR_ANNSEP:'SEPTEMBER', - FR_ANNOCT:'OCTOBER', - FR_ANNNOV:'NOVEMBER', - FR_ANNDEC:'DECEMBER' - } - -def _gen_annual_strs(month): - result = [] - for pr in _annual_prefixes: - result += [pr+'-'+mth_str for mth_str in (month[:3], month)] - return result - -freq_dict = { FR_QTR: ['Q','QUARTER','QUARTERLY'], - FR_MTH: ['M','MONTH','MONTHLY'], - FR_BUS: ['B','BUSINESS','BUSINESSLY'], - FR_DAY: ['D','DAY','DAILY'], - FR_HR: ['H','HOUR','HOURLY'], - FR_MIN: ['T','MINUTE','MINUTELY'], - FR_SEC: ['S','SECOND','SECONDLY'], - FR_UND: ['U','UNDEF','UNDEFINED'] - } - -for _freq, day_str in _week_end_map.iteritems(): - freq_dict[_freq] = _gen_weekly_strs(day_str) -freq_dict[FR_WK] += _weekly_prefixes - -for _freq, mth_str in _year_end_map.iteritems(): - freq_dict[_freq] = _gen_annual_strs(mth_str) -freq_dict[FR_ANN] += _annual_prefixes - -freq_revdict = reverse_dict(freq_dict) - -def freq_fromstr(freq_asstr): - "Converts a frequency given as string to the corresponding integer." - freq_asstr = freq_asstr.upper() - if freq_asstr not in freq_revdict.keys(): - raise ValueError, "Invalid frequency string %s" % freq_asstr - return freq_revdict[freq_asstr] - -def freq_tostr(freq_asint): - "Converts a frequency given as integer to the corresponding symbol." - if freq_asint not in freq_dict.keys(): - raise ValueError, "Invalid frequency representation %s" % freq_asint - return freq_dict[freq_asint][0] - -def check_freq(freq): - "Converts a possible 'frequency' string to acceptable values." - if freq is None: - return None - elif isinstance(freq, int): - if freq not in freq_dict.keys(): - raise ValueError("Invalid frequency: %s " % str(freq)) - return freq - elif freq.upper() in freq_revdict.keys(): - return freq_revdict[freq.upper()] - else: - raise ValueError("Invalid frequency: %s " % str(freq)) - -def check_freqstr(freq): - if freq is None: - return None - elif isinstance(freq, int): - if freq not in freq_dict.keys(): - raise ValueError("Invalid frequency: %s " % str(freq)) - return freq_dict[freq][0] - elif freq.upper() in freq_revdict.keys(): - return freq_dict[freq_revdict[freq.upper()]][0] - else: - raise ValueError("Invalid frequency: %s " % str(freq)) -fmtFreq = check_freqstr - -def get_freq_group(freq): - # truncate frequency to nearest thousand - return (freq//1000)*1000 - - -#####--------------------------------------------------------------------------- #---- --- Misc functions --- #####--------------------------------------------------------------------------- #http://aspn.activestate.com/ASPN/Mail/Message/python-tutor/2302348 @@ -203,11 +49,10 @@ yield f else: yield elm - + def flatargs(*args): "Flattens the arguments." if not hasattr(args, '__iter__'): return args else: return flatten_sequence(args) - Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-20 14:42:18 UTC (rev 2851) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-20 14:44:08 UTC (rev 2852) @@ -27,38 +27,25 @@ import maskedarray as MA -try: - from mx.DateTime import DateTimeType -except ImportError: - class DateTimeType: pass +from parser import DateFromString, DateTimeFromString -from parser import DateFromString, DateTimeFromString - import tcore as corelib -import tcore as _c +import const as _c import cseries +from cseries import Date, thisday, check_freq, check_freq_str +today = thisday - __all__ = [ 'Date', 'DateArray','isDate','isDateArray', 'DateError', 'ArithmeticDateError', 'FrequencyDateError','InsufficientDateError', 'datearray','date_array', 'date_array_fromlist', 'date_array_fromrange', -'day_of_week','day_of_year','day','month','quarter','year','hour','minute','second', -'truncateDate','monthToQuarter','thisday','today','prevbusday','asfreq', -'period_break' +'day_of_week','day_of_year','day','month','quarter','year','hour','minute', +'second','thisday','today','prevbusday','period_break', 'check_freq', +'check_freq_str' ] -#####--------------------------------------------------------------------------- -#---- --- Date Info --- -#####--------------------------------------------------------------------------- -OriginDate = dt.datetime(1970, 1, 1) -secondlyOriginDate = OriginDate - dt.timedelta(seconds=1) -minutelyOriginDate = OriginDate - dt.timedelta(minutes=1) -hourlyOriginDate = OriginDate - dt.timedelta(hours=1) - - #####--------------------------------------------------------------------------- #---- --- Date Exceptions --- #####--------------------------------------------------------------------------- @@ -72,15 +59,15 @@ "Calculate the string representation" return str(self.args) __repr__ = __str__ - + class InsufficientDateError(DateError): - """Defines the exception raised when there is not enough information + """Defines the exception raised when there is not enough information to create a Date object.""" def __init__(self, msg=None): if msg is None: msg = "Insufficient parameters given to create a date at the given frequency" DateError.__init__(self, msg) - + class FrequencyDateError(DateError): """Defines the exception raised when the frequencies are incompatible.""" def __init__(self, msg, freql=None, freqr=None): @@ -88,470 +75,45 @@ if not (freql is None or freqr is None): msg += " (%s<>%s)" % (freql, freqr) DateError.__init__(self, msg) - + class ArithmeticDateError(DateError): """Defines the exception raised when dates are used in arithmetic expressions.""" def __init__(self, msg=''): msg += " Cannot use dates for arithmetics!" DateError.__init__(self, msg) -#####--------------------------------------------------------------------------- -#---- --- Date Class --- -#####--------------------------------------------------------------------------- -class Date: - """Defines a Date object, as the combination of a date and a frequency. - Several options are available to construct a Date object explicitly: - - - Give appropriate values to the `year`, `month`, `day`, `quarter`, `hours`, - `minutes`, `seconds` arguments. - - >>> td.Date(freq='Q',year=2004,quarter=3) - >>> td.Date(freq='D',year=2001,month=1,day=1) - - - Use the `string` keyword. This method calls the `mx.DateTime.Parser` - submodule, more information is available in its documentation. - - >>> ts.Date('D', '2007-01-01') - - - Use the `datetime` keyword with an existing datetime.datetime object. - - >>> td.Date('D', datetime=datetime.datetime.now()) - """ - default_fmtstr = {_c.FR_ANN: "%Y", - _c.FR_QTR: "%YQ%q", - _c.FR_MTH: "%b-%Y", - _c.FR_WK: "%d-%b-%Y", - _c.FR_BUS: "%d-%b-%Y", - _c.FR_DAY: "%d-%b-%Y", - _c.FR_UND: "%d-%b-%Y", - _c.FR_HR: "%d-%b-%Y %H:00", - _c.FR_MIN: "%d-%b-%Y %H:%M", - _c.FR_SEC: "%d-%b-%Y %H:%M:%S" - } - - for x in range(7): default_fmtstr[_c.FR_WK+x] = default_fmtstr[_c.FR_WK] - for x in range(12): default_fmtstr[_c.FR_ANN+x] = default_fmtstr[_c.FR_ANN] - - def __init__(self, freq, value=None, string=None, - year=None, month=None, day=None, quarter=None, - hour=None, minute=None, second=None, - datetime=None): - - if hasattr(freq, 'freq'): - self.freq = corelib.check_freq(freq.freq) - else: - self.freq = corelib.check_freq(freq) - self.freqstr = corelib.freq_tostr(self.freq) - - _freqGroup = corelib.get_freq_group(self.freq) - - if isinstance(value, str): - if self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): - self.datetime = DateTimeFromString(value) - else: - self.datetime = DateFromString(value) - elif value is not None: - - #value could be a numpy scalar, which is not acceptable - value = int(value) - - if self.freq == _c.FR_SEC: - self.datetime = secondlyOriginDate + dt.timedelta(seconds=value) - elif self.freq == _c.FR_MIN: - self.datetime = minutelyOriginDate + dt.timedelta(minutes=value) - elif self.freq == _c.FR_HR: - self.datetime = hourlyOriginDate + dt.timedelta(hours=value) - elif self.freq == _c.FR_DAY: - self.datetime = dt.datetime.fromordinal(value) - elif self.freq == _c.FR_UND: - self.datetime = int(value) - elif self.freq == _c.FR_BUS: - valtmp = (value - 1)//5 - self.datetime = dt.datetime.fromordinal(value + valtmp*2) - elif _freqGroup == _c.FR_WK: - """value=1 must correspond to first FULL week in the year 0001 - ending on the given day of the week""" - self.datetime = dt.datetime(1,1,7) + \ - dt.timedelta(days=(value-1)*7 + (self.freq - _c.FR_WK)) - elif self.freq == _c.FR_MTH: - year = (value - 1)//12 + 1 - month = value - (year - 1)*12 - self.datetime = dt.datetime(year, month, 1) - elif self.freq == _c.FR_QTR: - year = (value - 1)//4 + 1 - month = (value - (year - 1)*4)*3 - self.datetime = dt.datetime(year, month, 1) - elif _freqGroup == _c.FR_ANN: - if self.freq == _c.FR_ANNDEC: - self.datetime = dt.datetime(value, 12, 1) - else: - self.datetime = dt.datetime(value, self.freq - _c.FR_ANN, 1) - else: - raise ValueError("unrecognized frequency: "+str(self.freq)) - - elif string is not None: - if self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): - self.datetime = DateTimeFromString(string) - else: - self.datetime = DateFromString(string) - - elif datetime is not None: - if isinstance(datetime, DateTimeType): - datetime = mx_to_datetime(datetime) - self.datetime = truncateDate(self.freq, datetime) - - else: - # First, some basic checks..... - if year is None: - raise InsufficientDateError - if _freqGroup in (_c.FR_BUS, _c.FR_DAY, _c.FR_WK, _c.FR_UND): - if month is None or day is None: - raise InsufficientDateError - elif self.freq == _c.FR_MTH: - if month is None: - raise InsufficientDateError - day = 1 - elif self.freq == _c.FR_QTR: - if quarter is None: - raise InsufficientDateError - month = quarter * 3 - day = 1 - elif _freqGroup == _c.FR_ANN: - month = self.freq - _freqGroup - if month == 0: month = 12 - day = 1 - elif self.freq == _c.FR_SEC: - if month is None or day is None or second is None: - raise InsufficientDateError - - if _freqGroup in (_c.FR_BUS, _c.FR_DAY, _c.FR_WK, - _c.FR_MTH, _c.FR_QTR, _c.FR_ANN): - self.datetime = truncateDate(self.freq, dt.datetime(year, month, day)) - if self.freq == _c.FR_BUS: - if self.datetime.isoweekday() in [6,7]: - raise ValueError("Weekend passed as business day") - elif self.freq in (_c.FR_HR, _c.FR_MIN, _c.FR_SEC): - if hour is None: - if minute is None: - if second is None: - hour = 0 - else: - hour = second//3600 - else: - hour = minute // 60 - if minute is None: - if second is None: - minute = 0 - else: - minute = (second-hour*3600)//60 - if second is None: - second = 0 - else: - second = second % 60 - self.datetime = truncateDate(self.freq, - dt.datetime(year, month, day, - hour, minute, second)) - else: - raise ValueError("unrecognized frequency: "+str(self.freq)) - - self.value = self.__value() - - def __getitem__(self, indx): - return self - - @property - def day(self): - "Returns the day of month." - return self.__getdateinfo__('D') - @property - def day_of_week(self): - "Returns the day of week." - return self.__getdateinfo__('W') - @property - def day_of_year(self): - "Returns the day of year." - return self.__getdateinfo__('R') - @property - def month(self): - "Returns the month." - return self.__getdateinfo__('M') - @property - def quarter(self): - "Returns the quarter." - return self.__getdateinfo__('Q') - @property - def year(self): - "Returns the year." - return self.__getdateinfo__('Y') - @property - def second(self): - "Returns the seconds." - return self.__getdateinfo__('S') - @property - def minute(self): - "Returns the minutes." - return self.__getdateinfo__('T') - @property - def hour(self): - "Returns the hour." - return self.__getdateinfo__('H') - @property - def week(self): - "Returns the week." - return self.__getdateinfo__('I') - - def __getdateinfo__(self, info): - return int(cseries.getDateInfo(numpy.asarray(self.value), - self.freq, info)) - __getDateInfo = __getdateinfo__ - - def __add__(self, other): - if isinstance(other, Date): - raise FrequencyDateError("Cannot add dates", - self.freqstr, other.freqstr) - return Date(freq=self.freq, value=int(self) + other) - - def __radd__(self, other): - return self+other - - def __sub__(self, other): - if isinstance(other, Date): - if self.freq != other.freq: - raise FrequencyDateError("Cannot subtract dates", \ - self.freqstr, other.freqstr) - else: - return int(self) - int(other) - else: - return self + (-1) * int(other) - - def __eq__(self, other): - if not hasattr(other, 'freq'): - return False - elif self.freq != other.freq: - raise FrequencyDateError("Cannot compare dates", \ - self.freqstr, other.freqstr) - return int(self) == int(other) - - def __cmp__(self, other): - if not hasattr(other, 'freq'): - return False - elif self.freq != other.freq: - raise FrequencyDateError("Cannot compare dates", \ - self.freqstr, other.freqstr) - return int(self)-int(other) - - def __hash__(self): - return hash(int(self)) ^ hash(self.freq) - - def __int__(self): - return self.value - - def __float__(self): - return float(self.value) - - def __value(self): - "Converts the date to an integer, depending on the current frequency." - _freqGroup = corelib.get_freq_group(self.freq) - # Secondly...... - if self.freq == _c.FR_SEC: - delta = (self.datetime - secondlyOriginDate) - val = delta.days*86400 + delta.seconds - # Minutely...... - elif self.freq == _c.FR_MIN: - delta = (self.datetime - minutelyOriginDate) - val = delta.days*1440 + delta.seconds/(60) - # Hourly........ - elif self.freq == _c.FR_HR: - delta = (self.datetime - hourlyOriginDate) - val = delta.days*24 + delta.seconds/(3600) - # Daily - elif self.freq == _c.FR_DAY: - val = self.datetime.toordinal() - # undefined - elif self.freq == _c.FR_UND: - if not hasattr(self.datetime, 'toordinal'): - val = self.datetime - else: - val = self.datetime.toordinal() - # Business days. - elif self.freq == _c.FR_BUS: - days = self.datetime.toordinal() - weeks = days // 7 - val = days - weeks*2 - # Weekly........ - elif _freqGroup == _c.FR_WK: - val = self.datetime.toordinal()//7 - # Monthly....... - elif self.freq == _c.FR_MTH: - val = (self.datetime.year-1)*12 + self.datetime.month - # Quarterly..... - elif self.freq == _c.FR_QTR: - val = (self.datetime.year-1)*4 + self.datetime.month//3 - # Annual ....... - elif _freqGroup == _c.FR_ANN: - val = self.datetime.year - - return int(val) - #...................................................... - def strfmt(self, fmt): - "Formats the date" - if fmt is None: - fmt = self.default_fmtstr[self.freq] - if self.freq == _c.FR_UND: - return str(self.value) - return cseries.strfmt(self.datetime, fmt) - - def __str__(self): - return self.strfmt(self.default_fmtstr[self.freq]) - - def __repr__(self): - return "<%s : %s>" % (str(self.freqstr), str(self)) - #...................................................... - def toordinal(self): - "Returns the date as an ordinal." - # FIXME: We shouldn't need the test if we were in C - if self.freq == _c.FR_UND: - return self.value - return self.datetime.toordinal() - - def fromordinal(self, ordinal): - "Returns the date as an ordinal." - return Date(self.freq, datetime=dt.datetime.fromordinal(ordinal)) - - def tostring(self): - "Returns the date as a string." - return str(self) - - def toobject(self): - "Returns the date as itself." - return self - - def isvalid(self): - "Returns whether the DateArray is valid: no missing/duplicated dates." - # A date is always valid by itself, but we need the object to support the function - # when we're working with singletons. - return True - #...................................................... - - #####--------------------------------------------------------------------------- #---- --- Functions --- #####--------------------------------------------------------------------------- -def mx_to_datetime(mxDate): - microsecond = 1000000*(mxDate.second % 1) - return dt.datetime(mxDate.year, mxDate.month, - mxDate.day, mxDate.hour, - mxDate.minute, - int(mxDate.second), microsecond) - - -def truncateDate(freq, datetime): - "Chops off the irrelevant information from the datetime object passed in." - freq = corelib.check_freq(freq) - _freqGroup = corelib.get_freq_group(freq) - if freq == _c.FR_MIN: - return dt.datetime(datetime.year, datetime.month, datetime.day, \ - datetime.hour, datetime.minute) - elif freq == _c.FR_HR: - return dt.datetime(datetime.year, datetime.month, datetime.day, \ - datetime.hour) - elif freq in (_c.FR_BUS, _c.FR_DAY): - if freq == _c.FR_BUS and datetime.isoweekday() in (6,7): - raise ValueError("Weekend passed as business day") - return dt.datetime(datetime.year, datetime.month, datetime.day) - elif _freqGroup == _c.FR_WK: - d = datetime.toordinal() - day_adj = (7 - (freq - _c.FR_WK)) % 7 - return dt.datetime.fromordinal(d + ((7 - day_adj) - d % 7) % 7) - elif freq == _c.FR_MTH: - return dt.datetime(datetime.year, datetime.month, 1) - elif freq == _c.FR_QTR: - return dt.datetime(datetime.year, monthToQuarter(datetime.month)*3, 1) - elif _freqGroup == _c.FR_ANN: - - if freq == _c.FR_ANNDEC: fr_month = 12 - else: fr_month = freq - _c.FR_ANN - - if datetime.month <= fr_month: - return dt.datetime(datetime.year, fr_month, 1) - else: - return dt.datetime(datetime.year+1, fr_month, 1) - - else: - return datetime - -def monthToQuarter(monthNum): - """Returns the quarter corresponding to the month `monthnum`. - For example, December is the 4th quarter, Januray the first.""" - return int((monthNum-1)/3)+1 - -def thisday(freq): - "Returns today's date, at the given frequency `freq`." - freq = corelib.check_freq(freq) - _freqGroup = corelib.get_freq_group(freq) - tempDate = dt.datetime.now() - # if it is Saturday or Sunday currently, freq==B, then we want to use Friday - if freq == _c.FR_BUS and tempDate.isoweekday() >= 6: - tempDate = tempDate - dt.timedelta(days=(tempDate.isoweekday() - 5)) - return Date(freq=freq, datetime=tempDate) -today = thisday - def prevbusday(day_end_hour=18, day_end_min=0): "Returns the previous business day." tempDate = dt.datetime.now() dateNum = tempDate.hour + float(tempDate.minute)/60 checkNum = day_end_hour + float(day_end_min)/60 - if dateNum < checkNum: + if dateNum < checkNum: return thisday(_c.FR_BUS) - 1 - else: + else: return thisday(_c.FR_BUS) - -def asfreq(date, toFreq, relation="BEFORE"): - """Returns a date converted to another frequency `toFreq`, according to the - relation `relation` .""" - tofreq = corelib.check_freq(toFreq) - _rel = relation.upper()[0] - if _rel not in ['B', 'A']: - msg = "Invalid relation '%s': Should be in ['before', 'after']" - raise ValueError, msg % relation - if not isinstance(date, Date): - raise DateError, "Date should be a valid Date instance!" - if date.freq == _c.FR_UND: - warnings.warn("Undefined frequency: assuming daily!") - fromfreq = _c.FR_DAY - else: - fromfreq = date.freq - - if fromfreq == tofreq: - return date - else: - value = cseries.asfreq(numeric.asarray(date.value), fromfreq, tofreq, _rel) - if value > 0: - return Date(freq=tofreq, value=value) - else: - return None -Date.asfreq = asfreq - def isDate(data): "Returns whether `data` is an instance of Date." return isinstance(data, Date) or \ (hasattr(data,'freq') and hasattr(data,'value')) - + #####--------------------------------------------------------------------------- #---- --- DateArray --- -#####--------------------------------------------------------------------------- +#####--------------------------------------------------------------------------- ufunc_dateOK = ['add','subtract', 'equal','not_equal','less','less_equal', 'greater','greater_equal', 'isnan'] class _datearithmetics(object): """Defines a wrapper for arithmetic methods. -Instead of directly calling a ufunc, the corresponding method of the `array._data` +Instead of directly calling a ufunc, the corresponding method of the `array._data` object is called instead. If `asdates` is True, a DateArray object is returned , else a regular ndarray is returned. @@ -590,14 +152,14 @@ if other.dtype.kind not in ['i','f']: raise ArithmeticDateError if self._asdates: - return instance.__class__(method(other, *args), + return instance.__class__(method(other, *args), freq=freq) else: return method(other, *args) -class DateArray(ndarray): +class DateArray(ndarray): """Defines a ndarray of dates, as ordinals. - + When viewed globally (array-wise), DateArray is an array of integers. When viewed element-wise, DateArray is a sequence of dates. For example, a test such as : @@ -605,17 +167,17 @@ will be valid only if value is an integer, not a Date However, a loop such as : >>> for d in DateArray(...): -accesses the array element by element. Therefore, `d` is a Date object. +accesses the array element by element. Therefore, `d` is a Date object. """ - _defcachedinfo = dict(toobj=None, tostr=None, toord=None, + _defcachedinfo = dict(toobj=None, tostr=None, toord=None, steps=None, full=None, hasdups=None) def __new__(cls, dates=None, freq=None, copy=False): # Get the frequency ...... if freq is None: _freq = getattr(dates, 'freq', _c.FR_UND) else: - _freq = corelib.check_freq(freq) - cls._defaultfreq = corelib.check_freq(_freq) + _freq = check_freq(freq) + cls._defaultfreq = check_freq(_freq) # Get the dates .......... _dates = numeric.array(dates, copy=copy, dtype=int_, subok=1) if _dates.ndim == 0: @@ -623,29 +185,29 @@ _dates = _dates.view(cls) _dates.freq = _freq return _dates - + def __array_wrap__(self, obj, context=None): if context is None: return self elif context[0].__name__ not in ufunc_dateOK: raise ArithmeticDateError, "(function %s)" % context[0].__name__ - + def __array_finalize__(self, obj): self.freq = getattr(obj, 'freq', _c.FR_UND) - self._cachedinfo = dict(toobj=None, tostr=None, toord=None, + self._cachedinfo = dict(toobj=None, tostr=None, toord=None, steps=None, full=None, hasdups=None) if hasattr(obj,'_cachedinfo'): self._cachedinfo.update(obj._cachedinfo) return - + def __getitem__(self, indx): if isinstance(indx, Date): indx = self.find_dates(indx) elif numeric.asarray(indx).dtype.kind == 'O': try: - indx = self.find_dates(indx) + indx = self.find_dates(indx) except AttributeError: - pass + pass r = ndarray.__getitem__(self, indx) if isinstance(r, (generic, int)): return Date(self.freq, value=r) @@ -662,7 +224,7 @@ if r._cachedinfo[attr] is not None: r._cachedinfo[attr] = r._cachedinfo[attr][indx] return r - + def __repr__(self): return ndarray.__repr__(self)[:-1] + \ ",\n freq='%s')" % self.freqstr @@ -681,41 +243,41 @@ @property def freqstr(self): "Returns the frequency string code." - return corelib.freq_tostr(self.freq) + return check_freq_str(self.freq) @property - def day(self): + def day(self): "Returns the day of month." return self.__getdateinfo__('D') @property - def day_of_week(self): + def day_of_week(self): "Returns the day of week." return self.__getdateinfo__('W') @property - def day_of_year(self): + def day_of_year(self): "Returns the day of year." return self.__getdateinfo__('R') @property - def month(self): + def month(self): "Returns the month." return self.__getdateinfo__('M') @property - def quarter(self): - "Returns the quarter." + def quarter(self): + "Returns the quarter." return self.__getdateinfo__('Q') @property - def year(self): + def year(self): "Returns the year." return self.__getdateinfo__('Y') @property - def second(self): - "Returns the seconds." + def second(self): + "Returns the seconds." return self.__getdateinfo__('S') @property - def minute(self): - "Returns the minutes." + def minute(self): + "Returns the minutes." return self.__getdateinfo__('T') @property - def hour(self): + def hour(self): "Returns the hour." return self.__getdateinfo__('H') @property @@ -733,12 +295,12 @@ minutes = minute hours = hour weeks = week - + def __getdateinfo__(self, info): - return numeric.asarray(cseries.getDateInfo(numeric.asarray(self), - self.freq, info), + return numeric.asarray(cseries.DA_getDateInfo(numeric.asarray(self), + self.freq, info), dtype=int_) - __getDateInfo = __getdateinfo__ + __getDateInfo = __getdateinfo__ #.... Conversion methods .................... # def tovalue(self): @@ -771,20 +333,20 @@ tostr = firststr self._cachedinfo['tostr'] = tostr return self._cachedinfo['tostr'] - # + # def asfreq(self, freq=None, relation="BEFORE"): "Converts the dates to another frequency." # Note: As we define a new object, we don't need caching if freq is None or freq == _c.FR_UND: return self - tofreq = corelib.check_freq(freq) + tofreq = check_freq(freq) if tofreq == self.freq: - return self - _rel = relation.upper()[0] + return self + _rel = relation.upper()[0] fromfreq = self.freq if fromfreq == _c.FR_UND: fromfreq = _c.FR_DAY - new = cseries.asfreq(numeric.asarray(self), fromfreq, tofreq, _rel) + new = cseries.DA_asfreq(numeric.asarray(self), fromfreq, tofreq, _rel) return DateArray(new, freq=freq) #...................................................... @@ -799,7 +361,7 @@ c = c.nonzero() if fromnumeric.size(c) == 0: raise IndexError, "Date out of bounds!" - return c + return c def date_to_index(self, date): "Returns the index corresponding to one given date, as an integer." @@ -811,9 +373,9 @@ else: index_asarray = (self == date.value).nonzero() if fromnumeric.size(index_asarray) == 0: - raise IndexError, "Date out of bounds!" + raise IndexError, "Date out of bounds!" return index_asarray[0][0] - #...................................................... + #...................................................... def get_steps(self): """Returns the time steps between consecutive dates. The timesteps have the same unit as the frequency of the series.""" @@ -834,25 +396,25 @@ steps = numeric.array([], dtype=int_) self._cachedinfo['steps'] = steps return self._cachedinfo['steps'] - + def has_missing_dates(self): "Returns whether the DateArray have missing dates." if self._cachedinfo['full'] is None: steps = self.get_steps() return not(self._cachedinfo['full']) - + def isfull(self): "Returns whether the DateArray has no missing dates." if self._cachedinfo['full'] is None: steps = self.get_steps() return self._cachedinfo['full'] - + def has_duplicated_dates(self): "Returns whether the DateArray has duplicated dates." if self._cachedinfo['hasdups'] is None: steps = self.get_steps() return self._cachedinfo['hasdups'] - + def isvalid(self): "Returns whether the DateArray is valid: no missing/duplicated dates." return (self.isfull() and not self.has_duplicated_dates()) @@ -863,7 +425,7 @@ #####--------------------------------------------------------------------------- #---- --- DateArray functions --- -#####--------------------------------------------------------------------------- +#####--------------------------------------------------------------------------- def isDateArray(a): "Tests whether an array is a DateArray object." return isinstance(a,DateArray) @@ -915,14 +477,16 @@ float_) ords += 1 #...try to guess the frequency - if freq is None: + if freq is None or freq == _c.FR_UND: freq = guess_freq(ords) #...construct a list of dates + for s in dlist: + x = Date(freq, string=s) dates = [Date(freq, string=s) for s in dlist] # Case #2: dates as numbers ................. elif dlist.dtype.kind in 'if': #...hopefully, they are values - if freq is None: + if freq is None or freq == _c.FR_UND: freq = guess_freq(dlist) dates = dlist # Case #3: dates as objects ................. @@ -934,7 +498,7 @@ #...as mx.DateTime objects elif hasattr(template,'absdays'): # no freq given: try to guess it from absdays - if freq is None: + if freq == _c.FR_UND: ords = numpy.fromiter((s.absdays for s in dlist), float_) ords += 1 freq = guess_freq(ords) @@ -942,7 +506,7 @@ #...as datetime objects elif hasattr(template, 'toordinal'): ords = numpy.fromiter((d.toordinal() for d in dlist), float_) - if freq is None: + if freq == _c.FR_UND: freq = guess_freq(ords) dates = [Date(freq, datetime=dt.datetime.fromordinal(a)) for a in ords] # @@ -950,18 +514,18 @@ return result -def date_array(dlist=None, start_date=None, end_date=None, length=None, +def date_array(dlist=None, start_date=None, end_date=None, length=None, include_last=True, freq=None): """Constructs a DateArray from: - a starting date and either an ending date or a given length. - a list of dates. """ - freq = corelib.check_freq(freq) + freq = check_freq(freq) # Case #1: we have a list ................... if dlist is not None: # Already a DateArray.................... if isinstance(dlist, DateArray): - if (freq is not None) and (dlist.freq != corelib.check_freq(freq)): + if (freq != _c.FR_UND) and (dlist.freq != check_freq(freq)): return dlist.asfreq(freq) else: return dlist @@ -999,7 +563,7 @@ # dlist = [(start_date+i).value for i in range(length)] dlist = numeric.arange(length, dtype=int_) dlist += start_date.value - if freq is None: + if freq == _c.FR_UND: freq = start_date.freq return DateArray(dlist, freq=freq) datearray = date_array @@ -1008,12 +572,12 @@ "Constructs a DateArray from a list of dates." return date_array(dlist=dlist, freq=freq) -def date_array_fromrange(start_date, end_date=None, length=None, +def date_array_fromrange(start_date, end_date=None, length=None, include_last=True, freq=None): - """Constructs a DateArray from a starting date and either an ending date or + """Constructs a DateArray from a starting date and either an ending date or a length.""" - return date_array(start_date=start_date, end_date=end_date, - length=length, include_last=include_last, freq=freq) + return date_array(start_date=start_date, end_date=end_date, + length=length, include_last=include_last, freq=freq) #####--------------------------------------------------------------------------- #---- --- Definition of functions from the corresponding methods --- @@ -1089,7 +653,7 @@ hodie = today('D') D = DateArray(today('D')) assert_equal(D.freq, 6000) - + if 0: freqs = [x[0] for x in corelib.freq_dict.values() if x[0] != 'U'] print freqs @@ -1097,17 +661,17 @@ print f today = thisday(f) assert(Date(freq=f, value=today.value) == today) - + if 1: D = date_array(freq='U', start_date=Date('U',1), length=10) - + if 1: dlist = ['2007-01-%02i' % i for i in (1,2,4,5,7,8,10,11,13)] - - + + ords = numpy.fromiter((DateTimeFromString(s).toordinal() for s in dlist), float_) - + if 1: "Tests the automatic sorting of dates." D = date_array_fromlist(dlist=['2006-01','2005-01','2004-01'],freq='M') Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-03-20 14:42:18 UTC (rev 2851) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-03-20 14:44:08 UTC (rev 2852) @@ -1,5 +1,5 @@ # pylint: disable-msg=W0611, W0612, W0511,R0201 -"""Tests suite for timeseries.tdates. +"""Tests suite for Date handling. :author: Pierre Gerard-Marchant & Matt Knox :contact: pierregm_at_uga_dot_edu - mattknow_ca_at_hotmail_dot_com @@ -25,20 +25,20 @@ import maskedarray.testutils from maskedarray.testutils import assert_equal, assert_array_equal -import timeseries.tdates as tdates -from timeseries.tdates import * -from timeseries.parser import DateFromString -from timeseries import tcore +import timeseries as ts +from timeseries import * +from timeseries.cseries import freq_dict class test_creation(NumpyTestCase): "Base test class for MaskedArrays." - + def __init__(self, *args, **kwds): NumpyTestCase.__init__(self, *args, **kwds) - + def test_fromstrings(self): "Tests creation from list of strings" + print "starting test_fromstrings..." dlist = ['2007-01-%02i' % i for i in range(1,15)] # A simple case: daily data dates = date_array_fromlist(dlist, 'D') @@ -72,9 +72,11 @@ assert(dates.isfull()) assert(not dates.has_duplicated_dates()) assert_equal(dates, 24073 + numpy.arange(12)) - + print "finished test_fromstrings" + def test_fromstrings_wmissing(self): "Tests creation from list of strings w/ missing dates" + print "starting test_fromstrings_wmissing..." dlist = ['2007-01-%02i' % i for i in (1,2,4,5,7,8,10,11,13)] dates = date_array_fromlist(dlist) assert_equal(dates.freqstr,'U') @@ -91,10 +93,12 @@ assert_equal(mdates.freqstr,'M') assert(not dates.isfull()) assert(mdates.has_duplicated_dates()) + print "finished test_fromstrings_wmissing" # - + def test_fromsobjects(self): "Tests creation from list of objects." + print "starting test_fromsobjects..." dlist = ['2007-01-%02i' % i for i in (1,2,4,5,7,8,10,11,13)] dates = date_array_fromlist(dlist) dobj = [datetime.datetime.fromordinal(d) for d in dates.toordinal()] @@ -103,17 +107,21 @@ dobj = [DateFromString(d) for d in dlist] odates = date_array_fromlist(dobj) assert_equal(dates,odates) + print "finished test_fromsobjects" def test_consistent_value(self): "Tests that values don't get mutated when constructing dates from a value" - freqs = [x[0] for x in tcore.freq_dict.values() if x[0] != 'U'] + print "starting test_consistent_value..." + freqs = [x[0] for x in freq_dict.values() if x[0] != 'U'] print freqs for f in freqs: - today = tdates.thisday(f) - assert_equal(tdates.Date(freq=f, value=today.value), today) - + today = thisday(f) + assert_equal(Date(freq=f, value=today.value), today) + print "finished test_consistent_value" + def test_shortcuts(self): "Tests some creation shortcuts. Because I'm lazy like that." + print "starting test_shortcuts..." # Dates shortcuts assert_equal(Date('D','2007-01'), Date('D',string='2007-01')) assert_equal(Date('D','2007-01'), Date('D', value=732677)) @@ -123,26 +131,27 @@ d = date_array(start_date=n, length=3) assert_equal(date_array(n,length=3), d) assert_equal(date_array(n, n+2), d) + print "finished test_shortcuts" class test_date_properties(NumpyTestCase): "Test properties such as year, month, day_of_week, etc...." - + def __init__(self, *args, **kwds): NumpyTestCase.__init__(self, *args, **kwds) def test_properties(self): - - a_date = tdates.Date(freq='A', year=2007) - q_date = tdates.Date(freq='Q', year=2007, quarter=1) - m_date = tdates.Date(freq='M', year=2007, month=1) - w_date = tdates.Date(freq='W', year=2007, month=1, day=7) - b_date = tdates.Date(freq='B', year=2007, month=1, day=1) - d_date = tdates.Date(freq='D', year=2007, month=1, day=1) - h_date = tdates.Date(freq='H', year=2007, month=1, day=1, + + a_date = Date(freq='A', year=2007) + q_date = Date(freq='Q', year=2007, quarter=1) + m_date = Date(freq='M', year=2007, month=1) + w_date = Date(freq='W', year=2007, month=1, day=7) + b_date = Date(freq='B', year=2007, month=1, day=1) + d_date = Date(freq='D', year=2007, month=1, day=1) + h_date = Date(freq='H', year=2007, month=1, day=1, hour=0) - t_date = tdates.Date(freq='T', year=2007, month=1, day=1, + t_date = Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0) - s_date = tdates.Date(freq='T', year=2007, month=1, day=1, + s_date = Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0, second=0) assert_equal(a_date.year, 2007) @@ -219,12 +228,12 @@ class test_freq_conversion(NumpyTestCase): "Test frequency conversion of date objects" - + def __init__(self, *args, **kwds): NumpyTestCase.__init__(self, *args, **kwds) self.dateWrap = [(dArrayWrap, assert_array_equal), (noWrap, assert_equal)] - + def test_conv_annual(self): "frequency conversion tests: from Annual Frequency" @@ -240,17 +249,17 @@ date_A_to_B_after = dWrap(Date(freq='B', year=2007, month=12, day=31)) date_A_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) date_A_to_D_after = dWrap(Date(freq='D', year=2007, month=12, day=31)) - date_A_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_A_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_A_to_H_after = dWrap(Date(freq='H', year=2007, month=12, day=31, + date_A_to_H_after = dWrap(Date(freq='H', year=2007, month=12, day=31, hour=23)) - date_A_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_A_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_A_to_T_after = dWrap(Date(freq='T', year=2007, month=12, day=31, + date_A_to_T_after = dWrap(Date(freq='T', year=2007, month=12, day=31, hour=23, minute=59)) - date_A_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_A_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_A_to_S_after = dWrap(Date(freq='S', year=2007, month=12, day=31, + date_A_to_S_after = dWrap(Date(freq='S', year=2007, month=12, day=31, hour=23, minute=59, second=59)) assert_func(date_A.asfreq('Q', "BEFORE"), date_A_to_Q_before) @@ -270,7 +279,7 @@ assert_func(date_A.asfreq('S', "BEFORE"), date_A_to_S_before) assert_func(date_A.asfreq('S', "AFTER"), date_A_to_S_after) - + def test_conv_quarterly(self): "frequency conversion tests: from Quarterly Frequency" @@ -286,17 +295,17 @@ date_Q_to_B_after = dWrap(Date(freq='B', year=2007, month=3, day=30)) date_Q_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) date_Q_to_D_after = dWrap(Date(freq='D', year=2007, month=3, day=31)) - date_Q_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_Q_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_Q_to_H_after = dWrap(Date(freq='H', year=2007, month=3, day=31, + date_Q_to_H_after = dWrap(Date(freq='H', year=2007, month=3, day=31, hour=23)) - date_Q_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_Q_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_Q_to_T_after = dWrap(Date(freq='T', year=2007, month=3, day=31, + date_Q_to_T_after = dWrap(Date(freq='T', year=2007, month=3, day=31, hour=23, minute=59)) - date_Q_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_Q_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_Q_to_S_after = dWrap(Date(freq='S', year=2007, month=3, day=31, + date_Q_to_S_after = dWrap(Date(freq='S', year=2007, month=3, day=31, hour=23, minute=59, second=59)) assert_func(date_Q.asfreq('A'), date_Q_to_A) @@ -316,11 +325,11 @@ assert_func(date_Q.asfreq('T', "AFTER"), date_Q_to_T_after) assert_func(date_Q.asfreq('S', "BEFORE"), date_Q_to_S_before) assert_func(date_Q.asfreq('S', "AFTER"), date_Q_to_S_after) - + def test_conv_monthly(self): "frequency conversion tests: from Monthly Frequency" - + for dWrap, assert_func in self.dateWrap: date_M = dWrap(Date(freq='M', year=2007, month=1)) date_M_end_of_year = dWrap(Date(freq='M', year=2007, month=12)) @@ -333,17 +342,17 @@ date_M_to_B_after = dWrap(Date(freq='B', year=2007, month=1, day=31)) date_M_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) date_M_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=31)) - date_M_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_M_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_M_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=31, + date_M_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=31, hour=23)) - date_M_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_M_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_M_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=31, + date_M_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=31, hour=23, minute=59)) - date_M_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_M_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_M_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=31, + date_M_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=31, hour=23, minute=59, second=59)) assert_func(date_M.asfreq('A'), date_M_to_A) @@ -364,10 +373,10 @@ assert_func(date_M.asfreq('S', "BEFORE"), date_M_to_S_before) assert_func(date_M.asfreq('S', "AFTER"), date_M_to_S_after) - + def test_conv_weekly(self): "frequency conversion tests: from Weekly Frequency" - + for dWrap, assert_func in self.dateWrap: date_W = dWrap(Date(freq='W', year=2007, month=1, day=1)) date_W_end_of_year = dWrap(Date(freq='W', year=2007, month=12, day=31)) @@ -396,17 +405,17 @@ date_W_to_B_after = dWrap(Date(freq='B', year=2007, month=1, day=5)) date_W_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) date_W_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=7)) - date_W_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_W_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_W_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=7, + date_W_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=7, hour=23)) - date_W_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_W_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_W_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=7, + date_W_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=7, hour=23, minute=59)) - date_W_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_W_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_W_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=7, + date_W_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=7, hour=23, minute=59, second=59)) assert_func(date_W.asfreq('A'), date_W_to_A) @@ -426,10 +435,10 @@ assert_func(date_W.asfreq('T', "AFTER"), date_W_to_T_after) assert_func(date_W.asfreq('S', "BEFORE"), date_W_to_S_before) assert_func(date_W.asfreq('S', "AFTER"), date_W_to_S_after) - + def test_conv_business(self): "frequency conversion tests: from Business Frequency" - + for dWrap, assert_func in self.dateWrap: date_B = dWrap(Date(freq='B', year=2007, month=1, day=1)) date_B_end_of_year = dWrap(Date(freq='B', year=2007, month=12, day=31)) @@ -442,17 +451,17 @@ date_B_to_M = dWrap(Date(freq='M', year=2007, month=1)) date_B_to_W = dWrap(Date(freq='W', year=2007, month=1, day=7)) date_B_to_D = dWrap(Date(freq='D', year=2007, month=1, day=1)) - date_B_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_B_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_B_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_B_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=23)) - date_B_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_B_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_B_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_B_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=23, minute=59)) - date_B_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_B_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_B_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_B_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=23, minute=59, second=59)) assert_func(date_B.asfreq('A'), date_B_to_A) @@ -475,7 +484,7 @@ def test_conv_daily(self): "frequency conversion tests: from Business Frequency" - + for dWrap, assert_func in self.dateWrap: date_D = dWrap(Date(freq='D', year=2007, month=1, day=1)) date_D_end_of_year = dWrap(Date(freq='D', year=2007, month=12, day=31)) @@ -496,17 +505,17 @@ date_D_to_M = dWrap(Date(freq='M', year=2007, month=1)) date_D_to_W = dWrap(Date(freq='W', year=2007, month=1, day=7)) - date_D_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_D_to_H_before = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_D_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_D_to_H_after = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=23)) - date_D_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_D_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_D_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_D_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=23, minute=59)) - date_D_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_D_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_D_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_D_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=23, minute=59, second=59)) assert_func(date_D.asfreq('A'), date_D_to_A) @@ -533,20 +542,20 @@ def test_conv_hourly(self): "frequency conversion tests: from Hourly Frequency" - + for dWrap, assert_func in self.dateWrap: date_H = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_H_end_of_year = dWrap(Date(freq='H', year=2007, month=12, day=31, + date_H_end_of_year = dWrap(Date(freq='H', year=2007, month=12, day=31, hour=23)) - date_H_end_of_quarter = dWrap(Date(freq='H', year=2007, month=3, day=31, + date_H_end_of_quarter = dWrap(Date(freq='H', year=2007, month=3, day=31, hour=23)) - date_H_end_of_month = dWrap(Date(freq='H', year=2007, month=1, day=31, + date_H_end_of_month = dWrap(Date(freq='H', year=2007, month=1, day=31, hour=23)) - date_H_end_of_week = dWrap(Date(freq='H', year=2007, month=1, day=7, + date_H_end_of_week = dWrap(Date(freq='H', year=2007, month=1, day=7, hour=23)) - date_H_end_of_day = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_H_end_of_day = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=23)) - date_H_end_of_bus = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_H_end_of_bus = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=23)) date_H_to_A = dWrap(Date(freq='A', year=2007)) @@ -556,13 +565,13 @@ date_H_to_D = dWrap(Date(freq='D', year=2007, month=1, day=1)) date_H_to_B = dWrap(Date(freq='B', year=2007, month=1, day=1)) - date_H_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_H_to_T_before = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_H_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_H_to_T_after = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=59)) - date_H_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_H_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_H_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_H_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=59, second=59)) assert_func(date_H.asfreq('A'), date_H_to_A) @@ -585,23 +594,23 @@ def test_conv_minutely(self): "frequency conversion tests: from Minutely Frequency" - + for dWrap, assert_func in self.dateWrap: - date_T = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_T = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) - date_T_end_of_year = dWrap(Date(freq='T', year=2007, month=12, day=31, + date_T_end_of_year = dWrap(Date(freq='T', year=2007, month=12, day=31, hour=23, minute=59)) - date_T_end_of_quarter = dWrap(Date(freq='T', year=2007, month=3, day=31, + date_T_end_of_quarter = dWrap(Date(freq='T', year=2007, month=3, day=31, hour=23, minute=59)) - date_T_end_of_month = dWrap(Date(freq='T', year=2007, month=1, day=31, + date_T_end_of_month = dWrap(Date(freq='T', year=2007, month=1, day=31, hour=23, minute=59)) - date_T_end_of_week = dWrap(Date(freq='T', year=2007, month=1, day=7, + date_T_end_of_week = dWrap(Date(freq='T', year=2007, month=1, day=7, hour=23, minute=59)) - date_T_end_of_day = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_T_end_of_day = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=23, minute=59)) - date_T_end_of_bus = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_T_end_of_bus = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=23, minute=59)) - date_T_end_of_hour = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_T_end_of_hour = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=59)) date_T_to_A = dWrap(Date(freq='A', year=2007)) @@ -612,9 +621,9 @@ date_T_to_B = dWrap(Date(freq='B', year=2007, month=1, day=1)) date_T_to_H = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_T_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_T_to_S_before = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_T_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_T_to_S_after = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=59)) assert_func(date_T.asfreq('A'), date_T_to_A) @@ -638,25 +647,25 @@ def test_conv_secondly(self): "frequency conversion tests: from Secondly Frequency" - + for dWrap, assert_func in self.dateWrap: - date_S = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_S = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=0)) - date_S_end_of_year = dWrap(Date(freq='S', year=2007, month=12, day=31, + date_S_end_of_year = dWrap(Date(freq='S', year=2007, month=12, day=31, hour=23, minute=59, second=59)) - date_S_end_of_quarter = dWrap(Date(freq='S', year=2007, month=3, day=31, + date_S_end_of_quarter = dWrap(Date(freq='S', year=2007, month=3, day=31, hour=23, minute=59, second=59)) - date_S_end_of_month = dWrap(Date(freq='S', year=2007, month=1, day=31, + date_S_end_of_month = dWrap(Date(freq='S', year=2007, month=1, day=31, hour=23, minute=59, second=59)) - date_S_end_of_week = dWrap(Date(freq='S', year=2007, month=1, day=7, + date_S_end_of_week = dWrap(Date(freq='S', year=2007, month=1, day=7, hour=23, minute=59, second=59)) - date_S_end_of_day = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_S_end_of_day = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=23, minute=59, second=59)) - date_S_end_of_bus = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_S_end_of_bus = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=23, minute=59, second=59)) - date_S_end_of_hour = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_S_end_of_hour = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=59, second=59)) - date_S_end_of_minute = dWrap(Date(freq='S', year=2007, month=1, day=1, + date_S_end_of_minute = dWrap(Date(freq='S', year=2007, month=1, day=1, hour=0, minute=0, second=59)) date_S_to_A = dWrap(Date(freq='A', year=2007)) @@ -665,9 +674,9 @@ date_S_to_W = dWrap(Date(freq='W', year=2007, month=1, day=7)) date_S_to_D = dWrap(Date(freq='D', year=2007, month=1, day=1)) date_S_to_B = dWrap(Date(freq='B', year=2007, month=1, day=1)) - date_S_to_H = dWrap(Date(freq='H', year=2007, month=1, day=1, + date_S_to_H = dWrap(Date(freq='H', year=2007, month=1, day=1, hour=0)) - date_S_to_T = dWrap(Date(freq='T', year=2007, month=1, day=1, + date_S_to_T = dWrap(Date(freq='T', year=2007, month=1, day=1, hour=0, minute=0)) assert_func(date_S.asfreq('A'), date_S_to_A) @@ -686,14 +695,14 @@ assert_func(date_S_end_of_hour.asfreq('H'), date_S_to_H) assert_func(date_S.asfreq('T'), date_S_to_T) assert_func(date_S_end_of_minute.asfreq('T'), date_S_to_T) - + class test_methods(NumpyTestCase): "Base test class for MaskedArrays." - + def __init__(self, *args, **kwds): - NumpyTestCase.__init__(self, *args, **kwds) - + NumpyTestCase.__init__(self, *args, **kwds) + def test_getitem(self): "Tests getitem" dlist = ['2007-%02i' % i for i in range(1,5)+range(7,13)] @@ -708,7 +717,7 @@ assert_equal(mdates[lag], mdates[5]) # Using several dates lag = mdates.find_dates(Date('M',value=24073), Date('M',value=24084)) - assert_equal(mdates[lag], + assert_equal(mdates[lag], DateArray([mdates[0], mdates[-1]], freq='M')) assert_equal(mdates[[mdates[0],mdates[-1]]], mdates[lag]) # @@ -717,20 +726,20 @@ mdates = date_array_fromlist(dlist).asfreq('M') #CHECK : Oops, what were we supposed to do here ? - + def test_getsteps(self): "Tests the getsteps method" dlist = ['2007-01-%02i' %i for i in (1,2,3,4,8,9,10,11,12,15)] ddates = date_array_fromlist(dlist) assert_equal(ddates.get_steps(), [1,1,1,4,1,1,1,1,3]) - - + + def test_empty_datearray(self): empty_darray = DateArray([], freq='b') assert_equal(empty_darray.isfull(), True) assert_equal(empty_darray.isvalid(), True) assert_equal(empty_darray.get_steps(), None) - + def test_cachedinfo(self): D = date_array(start_date=thisday('D'), length=5) Dstr = D.tostring() @@ -741,4 +750,4 @@ ############################################################################### #------------------------------------------------------------------------------ if __name__ == "__main__": - NumpyTest().run() \ No newline at end of file + NumpyTest().run() \ No newline at end of file Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-03-20 14:42:18 UTC (rev 2851) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-03-20 14:44:08 UTC (rev 2852) @@ -2,7 +2,7 @@ """Tests suite for MaskedArray. Adapted from the original test_ma by Pierre Gerard-Marchant -:author: Pierre Gerard-Marchant & Matt Knox +:author: Pierre Gerard-Marchant & Matt Knox :contact: pierregm_at_uga_dot_edu & mattknox_ca_at_hotmail_dot_com :version: $Id$ """ @@ -26,8 +26,8 @@ from maskedarray.testutils import assert_equal, assert_array_equal from timeseries import tseries -from timeseries.tseries import Date, date_array_fromlist, date_array, thisday -from timeseries.tseries import time_series, TimeSeries, adjust_endpoints, \ +from timeseries import Date, date_array_fromlist, date_array, thisday +from timeseries import time_series, TimeSeries, adjust_endpoints, \ mask_period, align_series, fill_missing_dates, tsmasked, concatenate_series class test_creation(NumpyTestCase): @@ -70,26 +70,26 @@ assert_equal(series._series, data) assert_equal(series._dates, dates) assert_equal(series.freqstr, 'D') - - + + def test_fromdatearray(self): _, dates, _ = self.d data = dates - + series = time_series(data, dates) assert(isinstance(series, TimeSeries)) assert_equal(series._dates, dates) assert_equal(series._data, data) assert_equal(series.freqstr, 'D') - + series[5] = MA.masked - + # ensure that series can be represented by a string after masking a value - # (there was a bug before that prevented this from working when using a + # (there was a bug before that prevented this from working when using a # DateArray for the data) strrep = str(series) - - + + def test_datafromlist(self): (_, dates, _) = self.d data = list(range(15)) @@ -105,7 +105,7 @@ dates = date_array_fromlist(dlist) data = masked_array(numeric.arange(15), mask=[1,0,0,0,0]*3) self.d = (time_series(data, dlist), data) - + def test_intfloat(self): "Test arithmetic timeseries/integers" (series, data) =self.d @@ -115,7 +115,7 @@ assert_equal(nseries._mask, [1,0,0,0,0]*3) assert_equal(nseries._series, data+1) assert_equal(nseries._dates, series._dates) - # + # nseries = series-1 assert(isinstance(nseries, TimeSeries)) assert_equal(nseries._mask, [1,0,0,0,0]*3) @@ -133,7 +133,7 @@ assert_equal(nseries._mask, [1,0,0,0,0]*3) assert_equal(nseries._series, data/1.) assert_equal(nseries._dates, series._dates) - + def test_intfloat_inplace(self): "Test int/float arithmetics in place." (series, data) =self.d @@ -191,8 +191,8 @@ assert(tsmasked._series is masked) assert(series._series[0] is masked) assert(series[0]._series is masked) - - + + #............................................................................... class test_getitem(NumpyTestCase): @@ -203,7 +203,7 @@ dates = date_array_fromlist(dlist) data = masked_array(numeric.arange(15), mask=[1,0,0,0,0]*3, dtype=float_) self.d = (time_series(data, dlist), data, dates) - + def test_wdate(self): "Tests getitem with date as index" (series, data, dates) = self.d @@ -231,7 +231,7 @@ # Testing a basic condition on dates series[series._dates < Date('D',string='2007-01-06')] = masked assert_equal(series[:5]._series._mask, [1,1,1,1,1]) - + def test_wslices(self): "Test get/set items." (series, data, dates) = self.d @@ -252,16 +252,16 @@ # Now, using dates ! dseries = series[series.dates[3]:series.dates[7]] assert_equal(dseries, series[3:7]) - + def test_on2d(self): "Tests getitem on a 2D series" (a,b,d) = ([1,2,3],[3,2,1], date_array(thisday('M'),length=3)) ser_x = time_series(N.column_stack((a,b)), dates=d) assert_equal(ser_x[0,0], time_series(a[0],d[0])) assert_equal(ser_x[0,:], time_series([(a[0],b[0])], d[0])) - assert_equal(ser_x[:,0], time_series(a, d)) - assert_equal(ser_x[:,:], ser_x) - + assert_equal(ser_x[:,0], time_series(a, d)) + assert_equal(ser_x[:,:], ser_x) + def test_onnd(self): "Tests getitem on a nD series" hodie = thisday('D') @@ -287,7 +287,7 @@ assert_equal(series[0]._dates[0], (hodie)) assert_equal(series[:,0]._data, [0,2,4,6,8]) assert_equal(series[:,0]._mask, [1,0,0,0,0]) - assert_equal(series[:,0]._dates, series._dates) + assert_equal(series[:,0]._dates, series._dates) # Case 3D series = time_series(N.arange(30).reshape(5,3,2), start_date=hodie) x = series[0] @@ -299,7 +299,7 @@ x = series[:,:,0] assert_equal(series[:,:,0], series._data[:,:,0]) assert_equal(series[:,:,0]._dates, series._dates) - + class test_functions(NumpyTestCase): "Some getitem tests" def __init__(self, *args, **kwds): @@ -322,7 +322,7 @@ dseries = adjust_endpoints(series, end_date=Date('D', string='2007-01-06')) assert_equal(dseries.size, 6) assert_equal(dseries, series[:6]) - dseries = adjust_endpoints(series, + dseries = adjust_endpoints(series, start_date=Date('D', string='2007-01-06'), end_date=Date('D', string='2007-01-31')) assert_equal(dseries.size, 26) @@ -332,7 +332,7 @@ a, b = align_series(series, empty_series) assert_equal(a.start_date, b.start_date) assert_equal(a.end_date, b.end_date) - # + # def test_tshift(self): "Test tshift function" series = self.d[0] @@ -345,13 +345,13 @@ result_data = [1,2,3,4,5,6,7,8,9,10,11,12,13,14] + [999] result_mask = [0,0,0,0,1,0,0,0,0,1, 0, 0, 0, 0 ] + [1 ] shift_positive_result = time_series(result_data, series._dates, mask=result_mask) - + assert_array_equal(shift_negative, shift_negative_result) assert_array_equal(shift_positive, shift_positive_result) # def test_convert(self): """Test convert function - + Just check basic functionality. The details of the actual date conversion algorithms already tested by asfreq in the test_dates test suite. @@ -360,9 +360,9 @@ start_date=Date(freq='m', year=2005, month=6)) highFreqSeries = time_series(N.arange(100), start_date=Date(freq='b', year=2005, month=6, day=1)) - + lowToHigh_start = lowFreqSeries.convert('B', position='START') - + assert_equal(lowToHigh_start.start_date, Date(freq='m', year=2005, month=6).asfreq("B", relation="BEFORE")) assert_equal(lowToHigh_start.end_date, @@ -372,41 +372,43 @@ assert_equal(lowToHigh_start._mask[-1], True) lowToHigh_end = lowFreqSeries.convert('B', position='END') - + assert_equal(lowToHigh_end.start_date, Date(freq='m', year=2005, month=6).asfreq("B", relation="BEFORE")) assert_equal(lowToHigh_end.end_date, (Date(freq='m', year=2005, month=6) + 9).asfreq("B", relation="AFTER")) - + assert_equal(lowToHigh_end._mask[0], True) assert_equal(lowToHigh_end._mask[-1], False) - + highToLow = highFreqSeries.convert('M', func=None) - + assert_equal(highToLow.ndim, 2) assert_equal(highToLow.shape[1], 23) assert_equal(highToLow.start_date, Date(freq='b', year=2005, month=6, day=1).asfreq('M')) assert_equal(highToLow.end_date, (Date(freq='b', year=2005, month=6, day=1) + 99).asfreq('M')) - # + + assert_array_equal(lowFreqSeries, lowFreqSeries.convert("M")) + # def test_fill_missing_dates(self): """Test fill_missing_dates function""" _start = Date(freq='m', year=2005, month=1) _end = Date(freq='m', year=2005, month=4) - + dates = date_array([_start, _end], freq='M') series = time_series([1, 2], dates) filled_ser = fill_missing_dates(series) - + assert_equal(filled_ser.start_date, _start) assert_equal(filled_ser.end_date, _end) assert(filled_ser.isfull()) assert(not filled_ser.has_duplicated_dates()) assert_equal(filled_ser.size, _end - _start + 1) # - def test_maskperiod(self): + def test_maskperiod(self): "Test mask_period" (series, data, dates) = self.d series.mask = nomask @@ -430,8 +432,8 @@ inplace=False) result = N.array([0,0,0,0,0,1,1,1,1,1,1,1,0,0,0]) assert_equal(mask._mask, result.repeat(2).reshape(-1,2)) - - + + # def test_pickling(self): "Tests pickling/unpickling" @@ -450,8 +452,8 @@ assert_equal(series_pickled._data, series._data) assert_equal(series_pickled._mask, series._mask) assert(isinstance(series_pickled._data, N.matrix)) - - + + def test_empty_timeseries(self): "Tests that empty TimeSeries are handled properly" empty_ts = time_series([], freq='b') @@ -459,33 +461,33 @@ assert_array_equal(empty_ts, empty_ts + empty_ts) assert_equal(empty_ts.start_date, None) assert_equal(empty_ts.end_date, None) - + def test__timeseriescompat_multiple(self): - + seriesM_10 = time_series(N.arange(10), date_array( start_date=Date(freq='m', year=2005, month=1), length=10) ) - + seriesD_10 = time_series(N.arange(10), date_array( start_date=Date(freq='d', year=2005, month=1, day=1), length=10) ) - + seriesD_5 = time_series(N.arange(5), date_array( start_date=Date(freq='d', year=2005, month=1, day=1), length=5) ) - + seriesD_5_apr = time_series(N.arange(5), date_array( start_date=Date(freq='d', year=2005, month=4, day=1), length=5) ) - + assert(tseries._timeseriescompat_multiple(seriesM_10, seriesM_10, seriesM_10)) try: @@ -501,14 +503,14 @@ except: exception = True assert(exception) - + try: tseries._timeseriescompat_multiple(seriesD_5, seriesD_5_apr) exception = False except: exception = True assert(exception) - + def test_compressed(self): "Tests compress" dlist = ['2007-01-%02i' % i for i in range(1,16)] @@ -522,14 +524,14 @@ assert_equal(c_series._mask, nomask) assert_equal(c_series._dates, dates[keeper]) # - series_st = time_series(MA.column_stack((data,data[::-1])), + series_st = time_series(MA.column_stack((data,data[::-1])), dates=dates) c_series = series_st.compressed() d = [1,2,3,6,7,8,11,12,13] assert_equal(c_series._data, N.c_[(d,list(reversed(d)))]) assert_equal(c_series._mask, nomask) assert_equal(c_series._dates, dates[d]) - + def test_concatenate(self): "Tests concatenate" dlist = ['2007-%02i' % i for i in range(1,6)] @@ -554,11 +556,11 @@ assert_equal(newseries._data,[0,1,2,0,1,2,3,4]) assert_equal(newseries._mask,[1,0,0,1,0,0,0,0]) # - - - + + + ############################################################################### #------------------------------------------------------------------------------ if __name__ == "__main__": - NumpyTest().run() \ No newline at end of file + NumpyTest().run() \ No newline at end of file Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-03-20 14:42:18 UTC (rev 2851) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-03-20 14:44:08 UTC (rev 2852) @@ -1,7 +1,7 @@ """ The `TimeSeries` class provides a base for the definition of time series. A time series is defined here as the combination of two arrays: - + - an array storing the time information (as a `DateArray` instance); - an array storing the data (as a `MaskedArray` instance.) @@ -26,23 +26,23 @@ from numpy.core.records import recarray from numpy.core.records import fromarrays as recfromarrays -import maskedarray.core as MA -from maskedarray.core import MaskedArray, MAError, masked, nomask, \ +import maskedarray as MA +from maskedarray import MaskedArray, MAError, masked, nomask, \ filled, getmask, getmaskarray, make_mask_none, mask_or, make_mask, \ masked_array import tcore as corelib -from tcore import * +import const as _c import tdates from tdates import DateError, InsufficientDateError from tdates import Date, isDate, DateArray, isDateArray, \ - date_array, date_array_fromlist, date_array_fromrange, thisday, today + date_array, date_array_fromlist, date_array_fromrange, thisday, today, \ + check_freq, check_freq_str import cseries - __all__ = [ 'TimeSeriesError','TimeSeriesCompatibilityError','TimeSeries','isTimeSeries', 'time_series', 'tsmasked', @@ -50,15 +50,48 @@ 'adjust_endpoints','align_series','aligned','convert','group_byperiod', 'tshift','fill_missing_dates', 'stack', 'concatenate_series','empty_like', 'day_of_week','day_of_year','day','month','quarter','year', -'hour','minute','second', +'hour','minute','second', 'tofile','asrecords','flatten', ] -#............................................................................... -# -#ufunc_domain = {} -#ufunc_fills = {} +#####--------------------------------------------------------------------------- +#---- --- Observed options --- +#####--------------------------------------------------------------------------- +fmtobs_dict = {'UNDEFINED': ['UNDEF','UNDEFINED',None], + 'BEGINNING': ['BEGIN','BEGINNING'], + 'ENDING': ['END','ENDING'], + 'AVERAGED': ['AVERAGE','AVERAGED','MEAN'], + 'SUMMED': ['SUM','SUMMED'], + 'MAXIMUM': ['MAX','MAXIMUM','HIGH'], + 'MINIMUM': ['MIN','MINIMUM','LOW']} + +obs_dict = {"UNDEFINED":None, + "BEGINNING": corelib.first_unmasked_val, + "ENDING": corelib.last_unmasked_val, + "AVERAGED": MA.average, + "SUMMED": MA.sum, + "MAXIMUM": MA.maximum, + "MINIMUM": MA.minimum, + } + +alias_obs_dict = {} +for ob, aliases in fmtobs_dict.iteritems(): + for al in aliases: + alias_obs_dict[al] = obs_dict[ob] +obs_dict.update(alias_obs_dict) +fmtobs_revdict = corelib.reverse_dict(fmtobs_dict) + +def fmtObserv(obStr): + "Converts a possible 'Observed' string into acceptable values." + if obStr is None: + return fmtobs_revdict[None] + elif obStr.upper() in fmtobs_revdict: + return fmtobs_revdict[obStr.upper()] + else: + raise ValueError("Invalid value for observed attribute: %s " % str(obStr)) + + #### -------------------------------------------------------------------------- #--- ... TimeSeriesError class ... #### -------------------------------------------------------------------------- @@ -96,46 +129,46 @@ if a.freq != b.freq: raise TimeSeriesCompatibilityError('freq', a.freq, b.freq) elif a.start_date != b.start_date: - raise TimeSeriesCompatibilityError('start_date', + raise TimeSeriesCompatibilityError('start_date', a.start_date, b.start_date) else: step_diff = a._dates.get_steps() != b._dates.get_steps() if (step_diff is True) or (hasattr(step_diff, "any") and step_diff.any()): - raise TimeSeriesCompatibilityError('time_steps', + raise TimeSeriesCompatibilityError('time_steps', a._dates.get_steps(), b._dates.get_steps()) elif a.shape != b.shape: - raise TimeSeriesCompatibilityError('size', "1: %s" % str(a.shape), + raise TimeSeriesCompatibilityError('size', "1: %s" % str(a.shape), "2: %s" % str(b.shape)) return True - + def _timeseriescompat_multiple(*series): """Checks the date compatibility of multiple TimeSeries objects. Returns True if everything's fine, or raises an exception. Unlike the binary version, all items must be TimeSeries objects.""" - + freqs, start_dates, steps, shapes = \ zip(*[(ser.freq, ser.start_date, (ser._dates.get_steps() != series[0]._dates.get_steps()).any(), ser.shape) for ser in series]) - + if len(set(freqs)) > 1: errItems = tuple(set(freqs)) raise TimeSeriesCompatibilityError('freq', errItems[0], errItems[1]) - + if len(set(start_dates)) > 1: errItems = tuple(set(start_dates)) raise TimeSeriesCompatibilityError('start_dates', errItems[0], errItems[1]) - + if max(steps) == True: bad_index = [x for x, val in enumerate(steps) if val][0] - raise TimeSeriesCompatibilityError('time_steps', - series[0]._dates.get_steps(), series[bad_index]._dates.get_steps()) + raise TimeSeriesCompatibilityError('time_steps', + series[0]._dates.get_steps(), series[bad_index]._dates.get_steps()) if len(set(shapes)) > 1: errItems = tuple(set(shapes)) - raise TimeSeriesCompatibilityError('size', "1: %s" % str(errItems[0].shape), + raise TimeSeriesCompatibilityError('size', "1: %s" % str(errItems[0].shape), "2: %s" % str(errItems[1].shape)) return True @@ -143,7 +176,7 @@ def _datadatescompat(data,dates): """Checks the compatibility of dates and data at the creation of a TimeSeries. - Returns True if everything's fine, raises an exception otherwise.""" + Returns True if everything's fine, raises an exception otherwise.""" # If there's only 1 element, the date is a Date object, which has no size... tsize = numeric.size(dates) dsize = data.size @@ -154,10 +187,10 @@ #dsize = numeric.asarray(data.shape)[:-1].prod() dsize = data.shape[0] if dsize == tsize: - return True + return True elif data.ndim == 0 and tsize <= 1: - return True - raise TimeSeriesCompatibilityError('size', "data: %s" % dsize, + return True + raise TimeSeriesCompatibilityError('size', "data: %s" % dsize, "dates: %s" % tsize) def _getdatalength(data): @@ -166,10 +199,10 @@ return numeric.asarray(numeric.shape(data))[:-1].prod() else: return numeric.size(data) - + def _compare_frequencies(*series): - """Compares the frequencies of a sequence of series. - Returns the common frequency, or raises an exception if series have different + """Compares the frequencies of a sequence of series. + Returns the common frequency, or raises an exception if series have different frequencies.""" unique_freqs = numpy.unique([x.freqstr for x in series]) try: @@ -177,7 +210,7 @@ except ValueError: raise TimeSeriesError, \ "All series must have same frequency!" - return common_freq + return common_freq ##### -------------------------------------------------------------------------- ##--- ... Time Series ... @@ -266,33 +299,34 @@ pass return result -class TimeSeries(MaskedArray, object): +class TimeSeries(MaskedArray, object): """Base class for the definition of time series. A time series is here defined as the combination of three arrays: - + - `series` : *[ndarray]* Data part - `mask` : *[ndarray]* Mask part - `dates` : *[DateArray]* Date part - + The combination of `series` and `dates` is the `data` part. """ options = None _defaultobserved = None _genattributes = ['fill_value', 'observed'] - def __new__(cls, data, dates=None, mask=nomask, + def __new__(cls, data, dates=None, mask=nomask, freq=None, observed=None, start_date=None, length=None, dtype=None, copy=False, fill_value=None, keep_mask=True, small_mask=True, hard_mask=False, **options): maparms = dict(copy=copy, dtype=dtype, fill_value=fill_value, - keep_mask=keep_mask, small_mask=small_mask, + keep_mask=keep_mask, small_mask=small_mask, hard_mask=hard_mask,) # Get the data ............................... _data = MaskedArray(data, mask=mask, **maparms).view(cls) # Get the frequency .......................... - freq = corelib.check_freq(freq) + freq = check_freq(freq) + # Get the dates .............................. if dates is None: newdates = getattr(data, '_dates', None) @@ -301,8 +335,8 @@ if newdates is not None: if not hasattr(newdates, 'freq'): newdates = date_array(dlist=dates, freq=freq) - if freq is not None and newdates.freq != freq: - newdates = newdates.tofreq(freq) + if freq != _c.FR_UND and newdates.freq != freq: + newdates = newdates.asfreq(freq) else: dshape = _data.shape if len(dshape) > 0: @@ -311,10 +345,10 @@ newdates = date_array(start_date=start_date, length=length, freq=freq) else: - newdates = date_array([], freq=freq) + newdates = date_array([], freq=freq) # Get observed ............................... - observed = getattr(data, 'observed', corelib.fmtObserv(observed)) - + observed = getattr(data, 'observed', fmtObserv(observed)) + if _data is masked: assert(numeric.size(newdates)==1) return _data.view(cls) @@ -326,7 +360,7 @@ return _data #............................................ def __array_finalize__(self,obj): - MaskedArray.__array_finalize__(self, obj) + MaskedArray.__array_finalize__(self, obj) self._dates = getattr(obj, '_dates', []) self.observed = getattr(obj, 'observed', None) return @@ -400,7 +434,7 @@ # CHECK: use reshape, or set shape ? newshape = (list((1,)) + list(newdata.shape)) newdata.shape = newshape - newdata = newdata.view(type(self)) + newdata = newdata.view(type(self)) newdata._dates = newdate return newdata # CHECK : The implementation below should work, but does not. Why ? @@ -421,7 +455,7 @@ # newdata = newdata.reshape((list((1,)) + list(newdata.shape))) # if newmask is not nomask: # newmask.shape = newdata.shape -# newdata = newdata.view(type(self)) +# newdata = newdata.view(type(self)) # newdata._dates = newdates # newdata._mask = newmask # return newdata @@ -436,8 +470,8 @@ if self is masked: raise MAError, 'Cannot alter the masked element.' (sindx, dindx) = self.__checkindex(indx) - #.... - super(TimeSeries, self).__setitem__(sindx, value) + #.... + super(TimeSeries, self).__setitem__(sindx, value) #........................ def __getslice__(self, i, j): "Gets slice described by i, j" @@ -466,8 +500,8 @@ desc = """\ timeseries(data = %(data)s, - dates = - %(time)s, + dates = + %(time)s, freq = %(freq)s) """ desc_short = """\ @@ -507,7 +541,7 @@ __le__ = _tsmathmethod('__le__') __gt__ = _tsmathmethod('__gt__') __ge__ = _tsmathmethod('__ge__') - + reshape = _tsarraymethod('reshape', ondates=True) copy = _tsarraymethod('copy', ondates=True) compress = _tsarraymethod('compress', ondates=True) @@ -515,7 +549,7 @@ cumsum = _tsarraymethod('cumsum',ondates=False) cumprod = _tsarraymethod('cumprod',ondates=False) anom = _tsarraymethod('anom',ondates=False) - + sum = _tsaxismethod('sum') prod = _tsaxismethod('prod') mean = _tsaxismethod('mean') @@ -526,18 +560,18 @@ all = _tsaxismethod('all') any = _tsaxismethod('any') - + # def nonzero(self): # """Returns a tuple of ndarrays, one for each dimension of the array, # containing the indices of the non-zero elements in that dimension.""" # return self._series.nonzero() - + # filled = _tsarraymethod('filled', ondates=False) - - #............................................ + + #............................................ def ids (self): """Return the ids of the data, dates and mask areas""" - return (id(self._series), id(self.dates),) + return (id(self._series), id(self.dates),) #------------------------------------------------------ @property def series(self): @@ -556,39 +590,39 @@ """Returns the corresponding frequency (as a string).""" return self._dates.freqstr @property - def day(self): + def day(self): "Returns the day of month for each date in self._dates." return self._dates.day @property - def day_of_week(self): + def day_of_week(self): "Returns the day of week for each date in self._dates." return self._dates.day_of_week @property - def day_of_year(self): + def day_of_year(self): "Returns the day of year for each date in self._dates." return self._dates.day_of_year @property - def month(self): + def month(self): "Returns the month for each date in self._dates." return self._dates.month @property - def quarter(self): - "Returns the quarter for each date in self._dates." + def quarter(self): + "Returns the quarter for each date in self._dates." return self._dates.quarter @property - def year(self): + def year(self): "Returns the year for each date in self._dates." return self._dates.year @property - def second(self): - "Returns the seconds for each date in self._dates." + def second(self): + "Returns the seconds for each date in self._dates." return self._dates.second @property - def minute(self): - "Returns the minutes for each date in self._dates." + def minute(self): + "Returns the minutes for each date in self._dates." return self._dates.minute @property - def hour(self): + def hour(self): "Returns the hour for each date in self._dates." return self._dates.hour @property @@ -629,33 +663,33 @@ return _dates[-1] else: return Date(self.freq, _dates.flat[-1]) - + def isvalid(self): """Returns whether the series has no duplicate/missing dates.""" return self._dates.isvalid() - + def has_missing_dates(self): """Returns whether there's a date gap in the series.""" return self._dates.has_missing_dates() - + def isfull(self): """Returns whether there's no date gap in the series.""" return self._dates.isfull() - + def has_duplicated_dates(self): """Returns whether there are duplicated dates in the series.""" return self._dates.has_duplicated_dates() - + def date_to_index(self, date): "Returns the index corresponding to a given date, as an integer." - return self._dates.date_to_index(date) + return self._dates.date_to_index(date) #..................................................... def asfreq(self, freq=None): "Converts the dates to another frequency." if freq is None: return self return TimeSeries(self._series, dates=self._dates.asfreq(freq)) - + def convert(self, freq, func='auto', position='END'): "Converts the dates to another frequency, and adapt the data." return convert(self, freq, func=func, position=position) @@ -707,11 +741,11 @@ self.freq, ) return state - # + # def __setstate__(self, state): """Restores the internal state of the TimeSeries, for pickling purposes. `state` is typically the output of the ``__getstate__`` output, and is a 5-tuple: - + - class name - a tuple giving the shape of the data - a typecode for the data @@ -722,11 +756,11 @@ super(TimeSeries, self).__setstate__((ver, shp, typ, isf, raw, msk, flv)) self._dates.__setstate__((dsh, dtype(int_), isf, dtm)) self._dates.freq = frq -# +# def __reduce__(self): """Returns a 3-tuple for pickling a MaskedArray.""" return (_tsreconstruct, - (self.__class__, self._baseclass, + (self.__class__, self._baseclass, self.shape, self._dates.shape, self.dtype, self._fill_value), self.__getstate__()) @@ -737,17 +771,17 @@ _series = ndarray.__new__(baseclass, baseshape, basetype) _dates = ndarray.__new__(DateArray, dateshape, int_) _mask = ndarray.__new__(ndarray, baseshape, bool_) - return genclass.__new__(genclass, _series, dates=_dates, mask=_mask, + return genclass.__new__(genclass, _series, dates=_dates, mask=_mask, dtype=basetype, fill_value=fill_value) - + def _attrib_dict(series, exclude=[]): """this function is used for passing through attributes of one time series to a new one being created""" result = {'fill_value':series.fill_value, 'observed':series.observed} return dict(filter(lambda x: x[0] not in exclude, result.iteritems())) - - + + ##### -------------------------------------------------------------------------- ##--- ... Additional methods ... ##### -------------------------------------------------------------------------- @@ -789,7 +823,7 @@ try: return getattr(TimeSeries, self._methodname).__doc__ except: - return "???" + return "???" # def __call__ (self, caller, *args, **params): if hasattr(caller, self._methodname): @@ -832,7 +866,7 @@ if format_dates is None: format_dates = self.dates[0].default_fmtstr() oformat = "%%s%s%s" % (sep,format_dates) - for (_dates,_data) in numpy.broadcast(self._dates.ravel().asstrings(), + for (_dates,_data) in numpy.broadcast(self._dates.ravel().asstrings(), filled(self)): ofile.write('%s\n' % sep.join([oformat % (_dates, _data) ])) ofile.close() @@ -849,11 +883,11 @@ if flat.size > 0: return recfromarrays([_dates, flat._data, getmaskarray(flat)], dtype=desctype, - shape = (flat.size,), + shape = (flat.size,), ) else: - return recfromarrays([[], [], []], dtype=desctype, - shape = (flat.size,), + return recfromarrays([[], [], []], dtype=desctype, + shape = (flat.size,), ) TimeSeries.asrecords = asrecords @@ -892,11 +926,11 @@ dtype=None, copy=False, fill_value=None, keep_mask=True, small_mask=True, hard_mask=False): """Creates a TimeSeries object - + :Parameters: `dates` : ndarray Array of dates. - `data` : + `data` : Array of data. """ data = numeric.array(data, copy=False, subok=True) @@ -907,15 +941,15 @@ length = dshape[0] if len(dshape) > 0: dates = date_array(start_date=start_date, end_date=end_date, - length=length, include_last=include_last, - freq=freq) + length=length, include_last=include_last, + freq=freq) else: - dates = date_array([], freq=freq) + dates = date_array([], freq=freq) elif not isinstance(dates, DateArray): dates = date_array(dlist=dates, freq=freq) return TimeSeries(data=data, dates=dates, mask=mask, observed=observed, copy=copy, dtype=dtype, fill_value=fill_value, - keep_mask=keep_mask, small_mask=small_mask, + keep_mask=keep_mask, small_mask=small_mask, hard_mask=hard_mask,) @@ -928,7 +962,7 @@ ##### -------------------------------------------------------------------------- #---- ... Additional functions ... ##### -------------------------------------------------------------------------- -def mask_period(data, period=None, start_date=None, end_date=None, +def mask_period(data, period=None, start_date=None, end_date=None, inside=True, include_edges=True, inplace=False): """Returns x as an array masked where dates fall outside the selection period, as well as where data are initially missing (masked). @@ -961,9 +995,9 @@ # Check the period ..................... if period is not None: if isinstance(period, (tuple, list, ndarray)): - (start_date, end_date) = (period[0], period[-1]) + (start_date, end_date) = (period[0], period[-1]) else: - (start_date, end_date) = (period, start_date) + (start_date, end_date) = (period, start_date) # Check the starting date .............. if start_date is None: start_date = dates_lims[0] @@ -993,17 +1027,17 @@ data[selection] = masked return data -def mask_inside_period(data, start_date=None, end_date=None, +def mask_inside_period(data, start_date=None, end_date=None, include_edges=True, inplace=False): """Masks values falling inside a given range of dates.""" - return mask_period(data, start_date=start_date, end_date=end_date, + return mask_period(data, start_date=start_date, end_date=end_date, inside=True, include_edges=include_edges, inplace=inplace) -def mask_outside_period(data, start_date=None, end_date=None, +def mask_outside_period(data, start_date=None, end_date=None, include_edges=True, inplace=False): """Masks values falling outside a given range of dates.""" - return mask_period(data, start_date=start_date, end_date=end_date, + return mask_period(data, start_date=start_date, end_date=end_date, inside=False, include_edges=include_edges, inplace=inplace) - + #............................................................................... def compressed(series): """Suppresses missing values from a time series.""" @@ -1026,7 +1060,7 @@ #............................................................................... def adjust_endpoints(a, start_date=None, end_date=None): """Returns a TimeSeries going from `start_date` to `end_date`. - If `start_date` and `end_date` both fall into the initial range of dates, + If `start_date` and `end_date` both fall into the initial range of dates, the new series is NOT a copy. """ # Series validity tests ..................... @@ -1050,9 +1084,9 @@ # Skip the empty series case if dstart is None and (start_date is None or end_date is None): raise TimeSeriesError, "Both start_date and end_date must be specified"+\ - " to adjust endpoints of a zero length series!" + " to adjust endpoints of a zero length series!" #.... - if start_date is None: + if start_date is None: start_date = dstart start_lag = 0 else: @@ -1062,15 +1096,15 @@ start_lag = start_date - dstart else: start_lag = start_date - #.... - if end_date is None: + #.... + if end_date is None: end_date = dend end_lag = 0 else: if not isinstance(end_date, Date): raise TypeError, msg % ('end_date', type(end_date)) if dend is not None: - end_lag = end_date - dend + end_lag = end_date - dend else: end_lag = end_date # Check if the new range is included in the old one @@ -1081,11 +1115,11 @@ return a[start_lag:end_lag] # Create a new series ....................... newdates = date_array(start_date=start_date, end_date=end_date) - + newshape = list(shp_flat) newshape[0] = len(newdates) newshape = tuple(newshape) - + newseries = numeric.empty(newshape, dtype=a.dtype).view(type(a)) newseries.__setmask__(numeric.ones(newseries.shape, dtype=bool_)) newseries._dates = newdates @@ -1099,39 +1133,39 @@ def align_series(*series, **kwargs): """Aligns several TimeSeries, so that their starting and ending dates match. Series are resized and filled with mased values accordingly. - + The function accepts two extras parameters: - `start_date` forces the series to start at that given date, - `end_date` forces the series to end at that given date. By default, `start_date` and `end_date` are set to the smallest and largest - dates respectively. + dates respectively. """ if len(series) < 2: - return series + return series unique_freqs = numpy.unique([x.freqstr for x in series]) common_freq = _compare_frequencies(*series) valid_states = [x.isvalid() for x in series] if not numpy.all(valid_states): raise TimeSeriesError, \ "Cannot adjust a series with missing or duplicated dates." - - start_date = kwargs.pop('start_date', - min([x.start_date for x in series + + start_date = kwargs.pop('start_date', + min([x.start_date for x in series if x.start_date is not None])) if isinstance(start_date,str): start_date = Date(common_freq, string=start_date) - end_date = kwargs.pop('end_date', + end_date = kwargs.pop('end_date', max([x.end_date for x in series if x.end_date is not None])) if isinstance(end_date,str): end_date = Date(common_freq, string=end_date) - + return [adjust_endpoints(x, start_date, end_date) for x in series] aligned = align_series #.................................................................... def convert(series, freq, func='auto', position='END'): """Converts a series to a frequency. - + When converting to a lower frequency, func is a function that acts on a 1-d array and returns a scalar or 1-d array. func should handle masked values appropriately. If func is "auto", then an @@ -1139,7 +1173,7 @@ of the series. If func is None, then a 2D array is returned, where each column represents the values appropriately grouped into the new frequency. interp and position will be ignored in this case. - + When converting to a higher frequency, position is 'START' or 'END' and determines where the data point is in each period (eg. if going from monthly to daily, and position is 'END', then each data point is @@ -1150,33 +1184,31 @@ if not series.isvalid(): raise TimeSeriesError, \ "Cannot adjust a series with missing or duplicated dates." - - if position.upper() not in ('END','START'): + + if position.upper() not in ('END','START'): raise ValueError("invalid value for position argument: (%s)",str(position)) - - toFreq = corelib.check_freq(freq) + + toFreq = freq fromFreq = series.freq + start_date = series._dates[0] - - if fromFreq == toFreq: - return series.copy() - + if series.size == 0: - return TimeSeries(series, freq=toFreq, + return TimeSeries(series, freq=toFreq, start_date=start_date.asfreq(toFreq)) if func == 'auto': - func = corelib.obs_dict[series.observed] + func = obs_dict[series.observed] tempData = series._series.filled() tempMask = getmaskarray(series) - cRetVal = cseries.convert(tempData, fromFreq, toFreq, position, - int(start_date), tempMask) + cRetVal = cseries.TS_convert(tempData, fromFreq, toFreq, position, + int(start_date), tempMask) _values = cRetVal['values'] _mask = cRetVal['mask'] _startindex = cRetVal['startindex'] start_date = Date(freq=toFreq, value=_startindex) - + tempData = masked_array(_values, mask=_mask) if tempData.ndim == 2 and func is not None: @@ -1226,7 +1258,7 @@ """ #Backup series attributes options = _attrib_dict(series) - newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype), + newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype), mask=True) if copy: inidata = series._series.copy() @@ -1248,21 +1280,25 @@ #............................................................................... def fill_missing_dates(data, dates=None, freq=None,fill_value=None): """Finds and fills the missing dates in a time series. -The data corresponding to the initially missing dates are masked, or filled to +The data corresponding to the initially missing dates are masked, or filled to `fill_value`. - + :Parameters: `data` Initial array of data. - `dates` - Initial array of dates. + `dates` + Initial array of dates. `freq` : float *[None]* New date resolutions. If *None*, the initial resolution is used instead. `fill_value` : float *[None]* Default value for missing data. If None, the data are just masked. """ - (freq, freqstr) = corelib.check_freq(freq), corelib.check_freqstr(freq) - if freqstr == 'U': + + orig_freq = freq + freq = check_freq(freq) + + if orig_freq is not None and freq == _c.FR_UND: + freqstr = check_freq_str(freq) raise ValueError,\ "Unable to define a proper date resolution (found %s)." % freqstr if dates is None: @@ -1291,16 +1327,16 @@ newdates = date_array(start_date=tstart, end_date=tend, include_last=True) nsize = newdates.size #............................. - # Get the steps between consecutive data. + # Get the steps between consecutive data. delta = dflat.get_steps()-1 gap = delta.nonzero() slcid = numpy.r_[[0,], numpy.arange(1,n)[gap], [n,]] - oldslc = numpy.array([slice(i,e) + oldslc = numpy.array([slice(i,e) for (i,e) in numpy.broadcast(slcid[:-1],slcid[1:])]) addidx = delta[gap].astype(int_).cumsum() - newslc = numpy.r_[[oldslc[0]], + newslc = numpy.r_[[oldslc[0]], [slice(i+d,e+d) for (i,e,d) in \ - numpy.broadcast(slcid[1:-1],slcid[2:],addidx)] + numpy.broadcast(slcid[1:-1],slcid[2:],addidx)] ] #............................. # Just a quick check @@ -1322,7 +1358,7 @@ for (new,old) in zip(newslc,oldslc): newdatad[new] = datad[old] newdatam[new] = datam[old] - newdata = MA.masked_array(newdatad, mask=newdatam, fill_value=fill_value) + newdata = MA.masked_array(newdatad, mask=newdatam, fill_value=fill_value) # Get new shape .............. if data.ndim == 1: nshp = (newdates.size,) @@ -1334,7 +1370,7 @@ """performs a column_stack on the data from each series, and the resulting series has the same dates as each individual series. All series must be date compatible. - + :Parameters: `*series` : the series to be stacked """ @@ -1354,7 +1390,7 @@ end_date = max([s.end_date for s in series if s.end_date is not None]) newdtype = max([s.dtype for s in series]) whichone = numeric.zeros((end_date-start_date+1), dtype=int_) - newseries = time_series(numeric.empty((end_date-start_date+1), dtype=newdtype), + newseries = time_series(numeric.empty((end_date-start_date+1), dtype=newdtype), dates=date_array(start_date, end_date, freq=common_f), mask=True) newdata = newseries._data @@ -1379,41 +1415,41 @@ result = N.empty_like(series).view(type(series)) result._dates = series._dates result._mask = series._mask - return result - + return result + ################################################################################ if __name__ == '__main__': from maskedarray.testutils import assert_equal, assert_array_equal import numpy as N - + if 1: dlist = ['2007-01-%02i' % i for i in range(1,11)] dates = date_array_fromlist(dlist) data = masked_array(numeric.arange(10), mask=[1,0,0,0,0]*2, dtype=float_) - + if 0: ser1d = time_series(data, dlist) - + serfolded = ser1d.reshape((5,2)) assert_equal(serfolded._dates.shape, (5,2)) assert_equal(serfolded[0], time_series([0,1],mask=[1,0], start_date=dates[0])) - assert_equal(serfolded[:,0], + assert_equal(serfolded[:,0], time_series(ser1d[::2], dates=dates[::2])) sertrans = serfolded.transpose() assert_equal(sertrans.shape, (2,5)) - - if 1: + + if 1: data = dates series = time_series(data, dates) assert(isinstance(series, TimeSeries)) assert_equal(series._dates, dates) assert_equal(series._data, data) assert_equal(series.freqstr, 'D') - + series[5] = MA.masked - + # ensure that series can be represented by a string after masking a value - # (there was a bug before that prevented this from working when using a + # (there was a bug before that prevented this from working when using a # DateArray for the data) strrep = str(series) \ No newline at end of file From scipy-svn at scipy.org Tue Mar 20 13:34:55 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 20 Mar 2007 12:34:55 -0500 (CDT) Subject: [Scipy-svn] r2853 - trunk/Lib/sparse/tests Message-ID: <20070320173455.A714939C096@new.scipy.org> Author: cookedm Date: 2007-03-20 12:34:52 -0500 (Tue, 20 Mar 2007) New Revision: 2853 Modified: trunk/Lib/sparse/tests/test_sparse.py Log: Replace 2.4ism sorted Modified: trunk/Lib/sparse/tests/test_sparse.py =================================================================== --- trunk/Lib/sparse/tests/test_sparse.py 2007-03-20 14:44:08 UTC (rev 2852) +++ trunk/Lib/sparse/tests/test_sparse.py 2007-03-20 17:34:52 UTC (rev 2853) @@ -800,7 +800,9 @@ coo = coo_matrix((data,(row,col)),(4,3)) ndata,nrow,ncol = coo._normalize(rowfirst=True) - assert(zip(nrow,ncol,ndata) == sorted(zip(row,col,data))) #should sort by rows, then cols + sorted_rcd = zip(row, col, data) + sorted_rcd.sort() + assert(zip(nrow,ncol,ndata) == sorted_rcd) #should sort by rows, then cols assert_array_equal(coo.data, data) #coo.data has not changed assert_array_equal(coo.row, row) #coo.row has not changed assert_array_equal(coo.col, col) #coo.col has not changed From scipy-svn at scipy.org Tue Mar 20 13:38:38 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 20 Mar 2007 12:38:38 -0500 (CDT) Subject: [Scipy-svn] r2854 - trunk/Lib/sandbox/timeseries Message-ID: <20070320173838.27F3539C096@new.scipy.org> Author: mattknox_ca Date: 2007-03-20 12:38:34 -0500 (Tue, 20 Mar 2007) New Revision: 2854 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: added "check_observed" as alias of fmtObserv Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-03-20 17:34:52 UTC (rev 2853) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-03-20 17:38:34 UTC (rev 2854) @@ -51,7 +51,7 @@ 'tshift','fill_missing_dates', 'stack', 'concatenate_series','empty_like', 'day_of_week','day_of_year','day','month','quarter','year', 'hour','minute','second', -'tofile','asrecords','flatten', +'tofile','asrecords','flatten', 'check_observed', ] @@ -90,8 +90,8 @@ return fmtobs_revdict[obStr.upper()] else: raise ValueError("Invalid value for observed attribute: %s " % str(obStr)) +check_observed = fmtObserv - #### -------------------------------------------------------------------------- #--- ... TimeSeriesError class ... #### -------------------------------------------------------------------------- From scipy-svn at scipy.org Tue Mar 20 13:40:20 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 20 Mar 2007 12:40:20 -0500 (CDT) Subject: [Scipy-svn] r2855 - trunk/Lib/sandbox/timeseries Message-ID: <20070320174020.CD07D39C096@new.scipy.org> Author: mattknox_ca Date: 2007-03-20 12:40:17 -0500 (Tue, 20 Mar 2007) New Revision: 2855 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: removed some obsolete code from DateArray Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-20 17:38:34 UTC (rev 2854) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-20 17:40:17 UTC (rev 2855) @@ -169,15 +169,12 @@ >>> for d in DateArray(...): accesses the array element by element. Therefore, `d` is a Date object. """ - _defcachedinfo = dict(toobj=None, tostr=None, toord=None, - steps=None, full=None, hasdups=None) def __new__(cls, dates=None, freq=None, copy=False): # Get the frequency ...... if freq is None: _freq = getattr(dates, 'freq', _c.FR_UND) else: _freq = check_freq(freq) - cls._defaultfreq = check_freq(_freq) # Get the dates .......... _dates = numeric.array(dates, copy=copy, dtype=int_, subok=1) if _dates.ndim == 0: From scipy-svn at scipy.org Tue Mar 20 13:47:24 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 20 Mar 2007 12:47:24 -0500 (CDT) Subject: [Scipy-svn] r2856 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070320174724.7B11139C096@new.scipy.org> Author: mattknox_ca Date: 2007-03-20 12:47:20 -0500 (Tue, 20 Mar 2007) New Revision: 2856 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: added cseries_get_freq_group function Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-20 17:40:17 UTC (rev 2855) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-20 17:47:20 UTC (rev 2856) @@ -2463,6 +2463,20 @@ return result; } +static char cseries_get_freq_group_doc[] = +"translate user specified frequency into frequency group constant"; +static PyObject * +cseries_get_freq_group(PyObject *self, PyObject *args) { + + PyObject *freq; + int freq_val; + + if (!PyArg_ParseTuple(args, "O:get_freq_group(freq)", &freq)) return NULL; + if ((freq_val = check_freq(freq)) == INT_ERR_CODE) return NULL; + + return PyInt_FromLong(get_freq_group(freq_val)); +} + static char cseries_thisday_doc[] = "Returns today's date, at the given frequency\n\n" ":Parameters:\n" @@ -2860,6 +2874,7 @@ {"thisday", cseries_thisday, METH_VARARGS, cseries_thisday_doc}, {"check_freq", cseries_check_freq, METH_VARARGS, cseries_check_freq_doc}, {"check_freq_str", cseries_check_freq_str, METH_VARARGS, cseries_check_freq_str_doc}, + {"get_freq_group", cseries_get_freq_group, METH_VARARGS, cseries_get_freq_group_doc}, {"set_callback_DateFromString", set_callback_DateFromString, METH_VARARGS, set_callback_DateFromString_doc}, From scipy-svn at scipy.org Tue Mar 20 13:47:44 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 20 Mar 2007 12:47:44 -0500 (CDT) Subject: [Scipy-svn] r2857 - trunk/Lib/sandbox/timeseries Message-ID: <20070320174744.ECBE739C096@new.scipy.org> Author: mattknox_ca Date: 2007-03-20 12:47:42 -0500 (Tue, 20 Mar 2007) New Revision: 2857 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: added get_freq_group function Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-20 17:47:20 UTC (rev 2856) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-20 17:47:42 UTC (rev 2857) @@ -33,7 +33,7 @@ import const as _c import cseries -from cseries import Date, thisday, check_freq, check_freq_str +from cseries import Date, thisday, check_freq, check_freq_str, get_freq_group today = thisday __all__ = [ @@ -42,7 +42,7 @@ 'datearray','date_array', 'date_array_fromlist', 'date_array_fromrange', 'day_of_week','day_of_year','day','month','quarter','year','hour','minute', 'second','thisday','today','prevbusday','period_break', 'check_freq', -'check_freq_str' +'check_freq_str','get_freq_group' ] From scipy-svn at scipy.org Tue Mar 20 13:48:22 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 20 Mar 2007 12:48:22 -0500 (CDT) Subject: [Scipy-svn] r2858 - trunk/Lib/sandbox/timeseries/plotlib Message-ID: <20070320174822.4EDD939C096@new.scipy.org> Author: mattknox_ca Date: 2007-03-20 12:48:13 -0500 (Tue, 20 Mar 2007) New Revision: 2858 Modified: trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py Log: updated to work with new location of frequency constants Modified: trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py 2007-03-20 17:47:42 UTC (rev 2857) +++ trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py 2007-03-20 17:48:13 UTC (rev 2858) @@ -34,6 +34,7 @@ import timeseries import timeseries as TS from timeseries import date_array, Date, DateArray, TimeSeries +from timeseries import const as _c import warnings @@ -65,13 +66,13 @@ key.__hash__() except TypeError: key = str(key) - # + # if figure_instance._seen.has_key(key): ax = figure_instance._seen[key] figure_instance.sca(ax) return ax # - if not len(args): + if not len(args): return # if hasattr(args[0], '__array__'): # fixedargs = args[1:] @@ -90,7 +91,7 @@ a = PolarSubplot(figure_instance, *args, **kwargs) else: a = SubplotClass(figure_instance, *args, **kwargs) - + figure_instance.axes.append(a) figure_instance._axstack.push(a) figure_instance.sca(a) @@ -130,17 +131,17 @@ def _get_default_annual_spacing(nyears): """Returns a default spacing between consecutive ticks for annual data.""" - if nyears < 11: + if nyears < 11: (min_spacing, maj_spacing) = (1, 1) - elif nyears < 20: + elif nyears < 20: (min_spacing, maj_spacing) = (1, 2) - elif nyears < 50: + elif nyears < 50: (min_spacing, maj_spacing) = (1, 5) - elif nyears < 100: + elif nyears < 100: (min_spacing, maj_spacing) = (5, 10) - elif nyears < 200: + elif nyears < 200: (min_spacing, maj_spacing) = (5, 25) - elif nyears < 600: + elif nyears < 600: (min_spacing, maj_spacing) = (10, 50) else: factor = nyears // 1000 + 1 @@ -172,18 +173,18 @@ def _daily_finder(vmin, vmax, freq, aslocator): - if freq == TS.FR_BUS: + if freq == _c.FR_BUS: periodsperyear = 261 - elif freq == TS.FR_DAY: + elif freq == _c.FR_DAY: periodsperyear = 365 - else: + else: raise ValueError("unexpected frequency") (vmin, vmax) = (int(vmin), int(vmax)) span = vmax - vmin + 1 - dates = date_array(start_date=Date(freq,vmin), + dates = date_array(start_date=Date(freq,vmin), end_date=Date(freq, vmax)) - default = N.arange(vmin, vmax+1) + default = N.arange(vmin, vmax+1) # Initialize the output if not aslocator: format = N.empty(default.shape, dtype="|S10") @@ -206,14 +207,14 @@ format[year_start] = '%d\n%b\n%Y' if not has_level_label(year_start): if not has_level_label(month_start): - if dates.size > 1: + if dates.size > 1: idx = 1 - else: + else: idx = 0 format[idx] = '%d\n%b\n%Y' else: format[first_label(month_start)] = '%d\n%b\n%Y' - # Case 2. Less than three months + # Case 2. Less than three months elif span <= periodsperyear//4: month_start = period_break(dates,'month') if aslocator: @@ -233,7 +234,7 @@ format[first_label(month_start)] = '\n\n%b\n%Y' # Case 3. Less than 14 months ............... elif span <= 1.15 * periodsperyear: - + if aslocator: d_minus_1 = dates-1 @@ -304,14 +305,14 @@ return dict([(d,f) for (d,f) in zip(default[formatted],format[formatted])]) #............................................................................... def _monthly_finder(vmin, vmax, freq, aslocator): - if freq != TS.FR_MTH: + if freq != _c.FR_MTH: raise ValueError("unexpected frequency") periodsperyear = 12 (vmin, vmax) = (int(vmin), int(vmax)) span = vmax - vmin + 1 #............................................ - dates = N.arange(vmin, vmax+1) + dates = N.arange(vmin, vmax+1) format = N.empty(span, dtype="|S8") format.flat = '' year_start = (dates % 12 == 1).nonzero()[0] @@ -321,14 +322,14 @@ major = dates[year_start] minor = dates else: - + format[:] = '%b' format[year_start] = '%b\n%Y' if not has_level_label(year_start): - if dates.size > 1: + if dates.size > 1: idx = 1 - else: + else: idx = 0 format[idx] = '%b\n%Y' #........................ @@ -357,7 +358,7 @@ minor = dates[quarter_start] else: format[year_start] = '%Y' - #......................... + #......................... else: nyears = span/periodsperyear (min_anndef, maj_anndef) = _get_default_annual_spacing(nyears) @@ -376,13 +377,13 @@ return dict([(d,f) for (d,f) in zip(dates[formatted],format[formatted])]) #............................................................................... def _quarterly_finder(vmin, vmax, freq, aslocator): - if freq != TS.FR_QTR: + if freq != _c.FR_QTR: raise ValueError("unexpected frequency") - periodsperyear = 4 + periodsperyear = 4 (vmin, vmax) = (int(vmin), int(vmax)) span = vmax - vmin + 1 #............................................ - dates = N.arange(vmin, vmax+1) + dates = N.arange(vmin, vmax+1) format = N.empty(span, dtype="|S8") format.flat = '' year_start = (dates % 4 == 1).nonzero()[0] @@ -395,9 +396,9 @@ format[:] = 'Q%q' format[year_start] = 'Q%q\n%Y' if not has_level_label(year_start): - if dates.size > 1: + if dates.size > 1: idx = 1 - else: + else: idx = 0 format[idx] = 'Q%q\n%Y' #............................................ @@ -426,12 +427,12 @@ return dict([(d,f) for (d,f) in zip(dates[formatted],format[formatted])]) #............................................................................... def _annual_finder(vmin, vmax, freq, aslocator): - if TS.get_freq_group(freq) != TS.FR_ANN: - raise ValueError("unexpected frequency") + if TS.get_freq_group(freq) != _c.FR_ANN: + raise ValueError("unexpected frequency") (vmin, vmax) = (int(vmin), int(vmax+1)) span = vmax - vmin + 1 #............................................ - dates = N.arange(vmin, vmax+1) + dates = N.arange(vmin, vmax+1) format = N.empty(span, dtype="|S8") format.flat = '' #............................................ @@ -448,7 +449,7 @@ else: formatted = (format != '') return dict([(d,f) for (d,f) in zip(dates[formatted],format[formatted])]) - + #............................................................................... class TimeSeries_DateLocator(Locator): "Locates the ticks along an axis controlled by a DateArray." @@ -463,32 +464,32 @@ self.isdynamic = dynamic_mode self.offset = 0 #..... - if fgroup == TS.FR_ANN: + if fgroup == _c.FR_ANN: self.finder = _annual_finder - elif freq == TS.FR_QTR: + elif freq == _c.FR_QTR: self.finder = _quarterly_finder - elif freq == TS.FR_MTH: + elif freq == _c.FR_MTH: self.finder = _monthly_finder - elif freq in (TS.FR_BUS, TS.FR_DAY): + elif freq in (_c.FR_BUS, _c.FR_DAY): self.finder = _daily_finder - + def asminor(self): "Returns the locator set to minor mode." self.isminor = True return self - + def asmajor(self): "Returns the locator set to major mode." self.isminor = False return self - + def _get_default_locs(self, vmin, vmax): "Returns the default locations of ticks." (minor, major) = self.finder(vmin, vmax, self.freq, True) if self.isminor: return minor return major - + def __call__(self): 'Return the locations of the ticks.' self.verify_intervals() @@ -503,9 +504,9 @@ vmin = (d+1) * base locs = range(vmin, vmax+1, base) return locs - + def autoscale(self): - """Sets the view limits to the nearest multiples of base that contain + """Sets the view limits to the nearest multiples of base that contain the data. """ self.verify_intervals() @@ -515,14 +516,14 @@ if vmin == vmax: vmin -= 1 vmax += 1 - return nonsingular(vmin, vmax) + return nonsingular(vmin, vmax) #####--------------------------------------------------------------------------- #---- --- Formatter --- -#####--------------------------------------------------------------------------- +#####--------------------------------------------------------------------------- class TimeSeries_DateFormatter(Formatter): """Formats the ticks along a DateArray axis.""" - + def __init__(self, freq, minor_locator=False, dynamic_mode=True,): self.format = None self.freq = freq @@ -533,30 +534,30 @@ self.offset = 0 fgroup = TS.get_freq_group(freq) #..... - if fgroup == TS.FR_ANN: + if fgroup == _c.FR_ANN: self.finder = _annual_finder - elif freq == TS.FR_QTR: + elif freq == _c.FR_QTR: self.finder = _quarterly_finder - elif freq == TS.FR_MTH: + elif freq == _c.FR_MTH: self.finder = _monthly_finder - elif freq in (TS.FR_BUS, TS.FR_DAY): + elif freq in (_c.FR_BUS, _c.FR_DAY): self.finder = _daily_finder - + def asminor(self): "Returns the formatter set to minor mode." self.isminor = True return self - + def asmajor(self): "Returns the fromatter set to major mode." self.isminor = False return self - + def _set_default_format(self, vmin, vmax): "Returns the default ticks spacing." self.formatdict = self.finder(vmin, vmax, self.freq, False) return self.formatdict - + def set_locs(self, locs): 'Sets the locations of the ticks' self.locs = locs @@ -574,10 +575,10 @@ else: retval = '' return retval - + #####-------------------------------------------------------------------------- #---- --- TimeSeries plots --- #####-------------------------------------------------------------------------- @@ -590,11 +591,11 @@ :Parameters: `fig` : Figure Base figure. - + :Keywords: `series` : TimeSeries Data to plot - + """ # Retrieve the series ................... _series = kwargs.pop('series',None) @@ -609,13 +610,13 @@ self.xdata = _series.dates self.freq = _series.dates.freq self.xaxis.set_major_locator - + else: self._series = None self.xdata = None self.freq = None self._austoscale = False - # Get the data to plot + # Get the data to plot self.legendsymbols = [] self.legendlabels = [] #............................................ @@ -631,7 +632,7 @@ """Gets the base time series.""" return self._series ydata = property(fget=get_ydata, fset=set_ydata, doc='Time series') - #............................................ + #............................................ def _check_plot_params(self,*args): """Defines the plot coordinates (and basic plotting arguments).""" remaining = list(args) @@ -679,7 +680,7 @@ else: output.extend([a, self.ydata]) #... and it must be some data - else: + else: b = remaining.pop(0) if len(remaining) > 0: if isinstance(remaining[0], str): @@ -719,20 +720,20 @@ parms = self._check_plot_params(*parms) self.legendlabels.append(kwargs.get('label',None)) Subplot.plot(self, *parms,**kwargs) - #............................................ - def format_dateaxis(self,maj_spacing=None, min_spacing=None, + #............................................ + def format_dateaxis(self,maj_spacing=None, min_spacing=None, strformat="%Y", rotate=True): """Pretty-formats the date axis (x-axis). - + :Parameters: - `major` : Integer *[5]* + `major` : Integer *[5]* Major tick locator, in years (major tick every `major` years). - `minor` : Integer *[12]* + `minor` : Integer *[12]* Minor tick locator, in months (minor ticks every `minor` months). `strformat` : String *['%Y']* String format for major ticks ("%Y"). """ - # Get the locator class ................. + # Get the locator class ................. majlocator = TimeSeries_DateLocator(self.freq, dynamic_mode=True, minor_locator=False) minlocator = TimeSeries_DateLocator(self.freq, dynamic_mode=True, @@ -759,7 +760,7 @@ #####-------------------------------------------------------------------------- #---- --- TimeSeries Figures --- -#####-------------------------------------------------------------------------- +#####-------------------------------------------------------------------------- class TimeSeriesFigure(Figure): """Time Series Figure: all subplots share the same time series. """ @@ -773,14 +774,14 @@ def add_tsplot(self, *args, **kwargs): """Adds a `TimeSeriesPlot` subplot to the figure.""" kwargs.update(SubplotClass=TimeSeriesPlot, - series=self._series) + series=self._series) return add_generic_subplot(self, *args, **kwargs) add_plot = add_tsplot TSFigure = TimeSeriesFigure #................................................ -def tsfigure(series, **figargs): +def tsfigure(series, **figargs): """Creates a new `TimeSeriesFigure` object. - + :Parameters: `series` : TimeSeries object Input data. @@ -798,8 +799,8 @@ kwargs['series'] = None return add_generic_subplot(axes, *args, **kwargs) Figure.add_tsplot = add_tsplot - + def tsplot(*args, **kwargs): # allow callers to override the hold state by passing hold=True|False b = pylab.ishold() @@ -819,16 +820,15 @@ ################################################################################ if __name__ == '__main__': - da = date_array(start_date=Date(freq='B', year=2003, quarter=3, month=1, day=17), + da = date_array(start_date=Date(freq='B', year=2003, quarter=3, month=1, day=17), length=10) ser = timeseries.time_series(MA.arange(len(da)), dates=da) # ser[4] = MA.masked # ser_2 = timeseries.time_series(MA.arange(len(da)), dates=da.asfreq('Q')) - + pylab.figure() pylab.gcf().add_tsplot(111) pylab.gca().tsplot(ser, 'ko-') pylab.gca().format_dateaxis() # pylab.gca().tsplot(ser_2, 'rs') pylab.show() - \ No newline at end of file From scipy-svn at scipy.org Tue Mar 20 15:29:22 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 20 Mar 2007 14:29:22 -0500 (CDT) Subject: [Scipy-svn] r2859 - trunk/Lib/sandbox/timeseries Message-ID: <20070320192922.D5F9339C2A4@new.scipy.org> Author: mattknox_ca Date: 2007-03-20 14:29:14 -0500 (Tue, 20 Mar 2007) New Revision: 2859 Modified: trunk/Lib/sandbox/timeseries/__init__.py trunk/Lib/sandbox/timeseries/tdates.py Log: moved python callback initialization from __init__ script to tdates.py Modified: trunk/Lib/sandbox/timeseries/__init__.py =================================================================== --- trunk/Lib/sandbox/timeseries/__init__.py 2007-03-20 17:48:13 UTC (rev 2858) +++ trunk/Lib/sandbox/timeseries/__init__.py 2007-03-20 19:29:14 UTC (rev 2859) @@ -14,12 +14,6 @@ __date__ = '$Date$' # initialize python callbacks for C code -import cseries as cs -import parser -from parser import DateFromString, DateTimeFromString -cs.set_callback_DateFromString(DateFromString) -cs.set_callback_DateTimeFromString(DateTimeFromString) - import tcore from tcore import * import const @@ -34,8 +28,8 @@ from addons import filters, interpolate -__all__ = ['const', 'tdates','parser','tseries','tmulti','reportlib','filters', - 'interpolate','DateFromString','DateTimeFromString'] +__all__ = ['const', 'tdates','tseries','tmulti','reportlib','filters', + 'interpolate'] __all__ += tdates.__all__ __all__ += tseries.__all__ __all__ += tmulti.__all__ Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-20 17:48:13 UTC (rev 2858) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-20 19:29:14 UTC (rev 2859) @@ -33,6 +33,9 @@ import const as _c import cseries +cseries.set_callback_DateFromString(DateFromString) +cseries.set_callback_DateTimeFromString(DateTimeFromString) + from cseries import Date, thisday, check_freq, check_freq_str, get_freq_group today = thisday From scipy-svn at scipy.org Tue Mar 20 15:31:22 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 20 Mar 2007 14:31:22 -0500 (CDT) Subject: [Scipy-svn] r2860 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070320193122.3A83C39C020@new.scipy.org> Author: mattknox_ca Date: 2007-03-20 14:31:18 -0500 (Tue, 20 Mar 2007) New Revision: 2860 Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py Log: Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-03-20 19:29:14 UTC (rev 2859) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-03-20 19:31:18 UTC (rev 2860) @@ -26,6 +26,7 @@ from maskedarray.testutils import assert_equal, assert_array_equal import timeseries as ts +from timeseries.parser import DateFromString, DateTimeFromString from timeseries import * from timeseries.cseries import freq_dict From scipy-svn at scipy.org Wed Mar 21 17:28:09 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Mar 2007 16:28:09 -0500 (CDT) Subject: [Scipy-svn] r2861 - in trunk/Lib/sandbox/maskedarray: . alternative_versions tests Message-ID: <20070321212809.733F439C00C@new.scipy.org> Author: pierregm Date: 2007-03-21 16:28:05 -0500 (Wed, 21 Mar 2007) New Revision: 2861 Added: trunk/Lib/sandbox/maskedarray/alternative_versions/test_mrecarray.py Modified: trunk/Lib/sandbox/maskedarray/core.py trunk/Lib/sandbox/maskedarray/mrecords.py trunk/Lib/sandbox/maskedarray/tests/test_subclassing.py trunk/Lib/sandbox/maskedarray/testutils.py Log: fixed a pb w/ mask propagation force the update of __dict__ w/ the __dict__ of data moved test_mrecarray to 'alternative_versions' Added: trunk/Lib/sandbox/maskedarray/alternative_versions/test_mrecarray.py =================================================================== --- trunk/Lib/sandbox/maskedarray/alternative_versions/test_mrecarray.py 2007-03-20 19:31:18 UTC (rev 2860) +++ trunk/Lib/sandbox/maskedarray/alternative_versions/test_mrecarray.py 2007-03-21 21:28:05 UTC (rev 2861) @@ -0,0 +1,128 @@ +# pylint: disable-msg=W0611, W0612, W0511,R0201 +"""Tests suite for mrecarray. + +:author: Pierre Gerard-Marchant +:contact: pierregm_at_uga_dot_edu +:version: $Id: test_mrecarray.py 68 2007-01-10 17:46:04Z backtopop $ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__version__ = '1.0' +__revision__ = "$Revision: 68 $" +__date__ = '$Date: 2007-01-10 12:46:04 -0500 (Wed, 10 Jan 2007) $' + +import types + +import numpy as N +import numpy.core.fromnumeric as fromnumeric +from numpy.testing import NumpyTest, NumpyTestCase +from numpy.testing.utils import build_err_msg + +import maskedarray.testutils +from maskedarray.testutils import * + +import maskedarray.core as MA +import maskedarray.mrecords +from maskedarray.mrecords import mrecarray, fromarrays, fromtextfile, fromrecords + + +#.............................................................................. +class test_mrecarray(NumpyTestCase): + "Base test class for MaskedArrays." + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + self.setup() + + def setup(self): + "Generic setup" + d = N.arange(5) + m = MA.make_mask([1,0,0,1,1]) + base_d = N.r_[d,d[::-1]].reshape(2,-1).T + base_m = N.r_[[m, m[::-1]]].T + base = MA.array(base_d, mask=base_m) + mrec = fromarrays(base.T,) + self.data = [d, m, mrec] + + def test_get(self): + "Tests fields retrieval" + [d, m, mrec] = self.data + assert_equal(mrec.f0, MA.array(d,mask=m)) + assert_equal(mrec.f1, MA.array(d[::-1],mask=m[::-1])) + assert((mrec._fieldmask == N.core.records.fromarrays([m, m[::-1]])).all()) + assert_equal(mrec._mask, N.r_[[m,m[::-1]]].all(0)) + assert_equal(mrec.f0, mrec['f0']) + + def test_set(self): + "Tests setting fields/attributes." + [d, m, mrec] = self.data + mrec.f0_data = 5 + assert_equal(mrec['f0_data'], [5,5,5,5,5]) + mrec.f0 = 1 + assert_equal(mrec['f0_data'], [1]*5) + assert_equal(mrec['f0_mask'], [0]*5) + mrec.f1 = MA.masked + assert_equal(mrec.f1.mask, [1]*5) + assert_equal(mrec['f1_mask'], [1]*5) + mrec._mask = MA.masked + assert_equal(mrec['f1_mask'], [1]*5) + assert_equal(mrec['f0_mask'],mrec['f1_mask']) + mrec._mask = MA.nomask + assert_equal(mrec['f1_mask'], [0]*5) + assert_equal(mrec['f0_mask'],mrec['f1_mask']) + + def test_hardmask(self): + "Test hardmask" + [d, m, mrec] = self.data + print mrec._mask + mrec.harden_mask() + assert(mrec._hardmask) + mrec._mask = nomask + assert_equal(mrec._mask, N.r_[[m,m[::-1]]].all(0)) + mrec.soften_mask() + assert(not mrec._hardmask) + mrec._mask = nomask + assert_equal(mrec['f1_mask'], [0]*5) + assert_equal(mrec['f0_mask'],mrec['f1_mask']) + + def test_fromtextfile(self): + "Tests reading from a text file." + fcontent = """# +'One (S)','Two (I)','Three (F)','Four (M)','Five (-)','Six (C)' +'strings',1,1.0,'mixed column',,1 +'with embedded "double quotes"',2,2.0,1.0,,1 +'strings',3,3.0E5,3,,1 +'strings',4,-1e-10,,,1 +""" + import os + from datetime import datetime + fname = 'tmp%s' % datetime.now().strftime("%y%m%d%H%M%S%s") + f = open(fname, 'w') + f.write(fcontent) + f.close() + mrectxt = fromtextfile(fname,delimitor=',',varnames='ABCDEFG') + os.unlink(fname) + # + assert(isinstance(mrectxt, mrecarray)) + assert_equal(mrectxt.F, [1,1,1,1]) + assert_equal(mrectxt.E._mask, [1,1,1,1]) + assert_equal(mrectxt.C, [1,2,3.e+5,-1e-10]) + + def test_fromrecords(self): + "Test from recarray." + [d, m, mrec] = self.data + nrec = N.core.records.fromarrays(N.r_[[d,d[::-1]]]) + mrecfr = fromrecords(nrec.tolist()) + assert_equal(mrecfr.f0, mrec.f0) + assert_equal(mrecfr.dtype, mrec.dtype) + #.................... + mrecfr = fromrecords(nrec) + assert_equal(mrecfr.f0, mrec.f0) + assert_equal(mrecfr.dtype, mrec.dtype) + #.................... + tmp = mrec[::-1] #.tolist() + mrecfr = fromrecords(tmp) + assert_equal(mrecfr.f0, mrec.f0[::-1]) + +############################################################################### +#------------------------------------------------------------------------------ +if __name__ == "__main__": + NumpyTest().run() \ No newline at end of file Modified: trunk/Lib/sandbox/maskedarray/core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/core.py 2007-03-20 19:31:18 UTC (rev 2860) +++ trunk/Lib/sandbox/maskedarray/core.py 2007-03-21 21:28:05 UTC (rev 2861) @@ -990,22 +990,25 @@ DeprecationWarning) small_mask = flag # Process data............ - _data = numeric.array(data, dtype=dtype, copy=copy, subok=True) - _baseclass = getattr(_data, '_baseclass', type(_data)) - if not isinstance(data, MaskedArray) or not subok: + _data = numeric.array(data, dtype=dtype, copy=copy, subok=subok) + _baseclass = getattr(data, '_baseclass', type(_data)) + _basedict = getattr(data, '_basedict', getattr(data, '__dict__', None)) + if not isinstance(data, MaskedArray): _data = _data.view(cls) - # Process mask ........... - # Backwards compat + elif not subok: + _data = _data.view(cls) + else: + _data = _data.view(type(data)) + # Backwards compat ....... if hasattr(data,'_mask') and not isinstance(data, ndarray): _data._mask = data._mask - _data._sharedmask = True + _sharedmask = True + # Process mask ........... if mask is nomask: - if _data._mask is not nomask: - if copy: - _data._mask = data._mask.copy() - _data._sharedmask = False - if not keep_mask: - _data._mask = nomask + if not keep_mask: + _data._mask = nomask + if copy: + _data._mask = _data._mask.copy() else: mask = numeric.array(mask, dtype=MaskType, copy=copy) if mask.shape != _data.shape: @@ -1018,21 +1021,27 @@ msg = "Mask and data not compatible: data size is %i, "+\ "mask size is %i." raise MAError, msg % (nd, nm) - if _data._mask is nomask or not keep_mask: + if _data._mask is nomask: _data._mask = mask _data._sharedmask = True else: - _data._mask = _data._mask.copy() - _data._mask.__ior__(mask) + # Make a copy of the mask to avoid propagation _data._sharedmask = False - # Process extra options .. - # Update fille_value + if not keep_mask: + _data._mask = mask + else: + _data._mask = umath.logical_or(mask, _data._mask) + + + # Update fill_value....... _data._fill_value = getattr(data, '_fill_value', fill_value) if _data._fill_value is None: _data._fill_value = default_fill_value(_data) + # Process extra options .. _data._hardmask = hard_mask _data._smallmask = small_mask _data._baseclass = _baseclass + _data._basedict = _basedict return _data #........................ def __array_finalize__(self,obj): @@ -1048,6 +1057,10 @@ self._sharedmask = True self._baseclass = getattr(obj, '_baseclass', type(obj)) self._fill_value = getattr(obj, '_fill_value', None) + # Update special attributes ... + self._basedict = getattr(obj, '_basedict', getattr(obj, '__dict__', None)) + if self._basedict is not None: + self.__dict__.update(self._basedict) return #.................................. def __array_wrap__(self, obj, context=None): @@ -1179,7 +1192,7 @@ self._mask.flat = newmask if self._mask.shape: self._mask = numeric.reshape(self._mask, self.shape) - _setmask = __setmask__ + _set_mask = __setmask__ def _get_mask(self): """Returns the current mask.""" Modified: trunk/Lib/sandbox/maskedarray/mrecords.py =================================================================== --- trunk/Lib/sandbox/maskedarray/mrecords.py 2007-03-20 19:31:18 UTC (rev 2860) +++ trunk/Lib/sandbox/maskedarray/mrecords.py 2007-03-21 21:28:05 UTC (rev 2861) @@ -226,7 +226,7 @@ # We want a field ........ if isinstance(indx, str): obj = _data[indx].view(MaskedArray) - obj._setmask(_localdict['_fieldmask'][indx]) + obj._set_mask(_localdict['_fieldmask'][indx]) return obj # We want some elements .. obj = ndarray.__getitem__(self, indx).view(type(self)) Modified: trunk/Lib/sandbox/maskedarray/tests/test_subclassing.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_subclassing.py 2007-03-20 19:31:18 UTC (rev 2860) +++ trunk/Lib/sandbox/maskedarray/tests/test_subclassing.py 2007-03-21 21:28:05 UTC (rev 2861) @@ -114,10 +114,15 @@ assert isinstance(z._data, SubArray) assert z._data.info['added'] > 0 # - ym._setmask([1,0,0,0,1]) + ym._set_mask([1,0,0,0,1]) assert_equal(ym._mask, [1,0,0,0,1]) - ym._series._setmask([0,0,0,0,1]) + ym._series._set_mask([0,0,0,0,1]) assert_equal(ym._mask, [0,0,0,0,1]) + # + xsub = subarray(x, info={'name':'x'}) + mxsub = masked_array(xsub) + assert hasattr(mxsub, 'info') + assert_equal(mxsub.info, xsub.info) def check_subclasspreservation(self): "Checks that masked_array(...,subok=True) preserves the class." @@ -126,13 +131,13 @@ xinfo = [(i,j) for (i,j) in zip(x,m)] xsub = MSubArray(x, mask=m, info={'xsub':xinfo}) # + mxsub = masked_array(xsub, subok=False) + assert not isinstance(mxsub, MSubArray) + assert isinstance(mxsub, MaskedArray) + # mxsub = masked_array(xsub, subok=True) assert isinstance(mxsub, MSubArray) assert_equal(mxsub.info, xsub.info) - # - mxsub = masked_array(xsub, subok=False) - assert not isinstance(mxsub, MSubArray) - assert isinstance(mxsub, MaskedArray) ################################################################################ Modified: trunk/Lib/sandbox/maskedarray/testutils.py =================================================================== --- trunk/Lib/sandbox/maskedarray/testutils.py 2007-03-20 19:31:18 UTC (rev 2860) +++ trunk/Lib/sandbox/maskedarray/testutils.py 2007-03-21 21:28:05 UTC (rev 2861) @@ -178,7 +178,7 @@ number of decimals.""" def compare(x, y): "Returns the result of the loose comparison between x and y)." - return approx(x,y) + return approx(x,y, rtol=10.**-decimal) assert_array_compare(compare, x, y, err_msg=err_msg, header='Arrays are not almost equal') #............................ From scipy-svn at scipy.org Wed Mar 21 17:28:20 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Mar 2007 16:28:20 -0500 (CDT) Subject: [Scipy-svn] r2862 - trunk/Lib/sandbox/maskedarray/tests Message-ID: <20070321212820.D52DF39C00C@new.scipy.org> Author: pierregm Date: 2007-03-21 16:28:18 -0500 (Wed, 21 Mar 2007) New Revision: 2862 Modified: trunk/Lib/sandbox/maskedarray/tests/test_core.py Log: Modified: trunk/Lib/sandbox/maskedarray/tests/test_core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_core.py 2007-03-21 21:28:05 UTC (rev 2861) +++ trunk/Lib/sandbox/maskedarray/tests/test_core.py 2007-03-21 21:28:18 UTC (rev 2862) @@ -1001,7 +1001,7 @@ assert_equal(mx.mask, [0,1,0]) mx = masked_array(x, mask=[0,1,0], keep_mask=True) assert_equal(mx.mask, [1,1,0]) - #We default to true + # We default to true mx = masked_array(x, mask=[0,1,0]) assert_equal(mx.mask, [1,1,0]) From scipy-svn at scipy.org Wed Mar 21 18:54:13 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Mar 2007 17:54:13 -0500 (CDT) Subject: [Scipy-svn] r2863 - in trunk/Lib/sandbox/pyloess: . src tests Message-ID: <20070321225413.6709D39C187@new.scipy.org> Author: pierregm Date: 2007-03-21 17:53:54 -0500 (Wed, 21 Mar 2007) New Revision: 2863 Added: trunk/Lib/sandbox/pyloess/LICENSE.txt trunk/Lib/sandbox/pyloess/src/S.h trunk/Lib/sandbox/pyloess/src/_loess.c trunk/Lib/sandbox/pyloess/src/_loess.pyx trunk/Lib/sandbox/pyloess/src/c_loess.pxd trunk/Lib/sandbox/pyloess/src/c_numpy.pxd trunk/Lib/sandbox/pyloess/src/c_python.pxd trunk/Lib/sandbox/pyloess/src/cloess.h trunk/Lib/sandbox/pyloess/src/linpack_lite.f trunk/Lib/sandbox/pyloess/src/loess.c trunk/Lib/sandbox/pyloess/src/loess.h trunk/Lib/sandbox/pyloess/src/loessc.c trunk/Lib/sandbox/pyloess/src/loessf.f trunk/Lib/sandbox/pyloess/src/misc.c trunk/Lib/sandbox/pyloess/src/predict.c trunk/Lib/sandbox/pyloess/tests/gas_data trunk/Lib/sandbox/pyloess/tests/gas_result trunk/Lib/sandbox/pyloess/tests/madeup_data trunk/Lib/sandbox/pyloess/tests/madeup_result Modified: trunk/Lib/sandbox/pyloess/README trunk/Lib/sandbox/pyloess/__init__.py trunk/Lib/sandbox/pyloess/pyloess.py trunk/Lib/sandbox/pyloess/setup.py trunk/Lib/sandbox/pyloess/tests/test_pyloess.py Log: moved loess from the sandbox to the base package deleted the sandbox directory added tests for loess (2D and 1D) Added: trunk/Lib/sandbox/pyloess/LICENSE.txt =================================================================== --- trunk/Lib/sandbox/pyloess/LICENSE.txt 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/LICENSE.txt 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,16 @@ +From the original C package: + +/* + * The authors of this software are Cleveland, Grosse, and Shyu. + * Copyright (c) 1989, 1992 by AT&T. + * Permission to use, copy, modify, and distribute this software for any + * purpose without fee is hereby granted, provided that this entire notice + * is included in all copies of any software which is or includes a copy + * or modification of this software and in all copies of the supporting + * documentation for such software. + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY + * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. + */ + Modified: trunk/Lib/sandbox/pyloess/README =================================================================== --- trunk/Lib/sandbox/pyloess/README 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/README 2007-03-21 22:53:54 UTC (rev 2863) @@ -14,3 +14,8 @@ The initial file is available at: http://netlib.bell-labs.com/netlib/a/stl.gz Simple to double precision conversion by Pierre GERARD-MARCHANT, 2007/03. + + +Note : +The sandbox subfolder contains a pre-alpha version of the loess routines. These +routines are not fully tested, but they run. Modified: trunk/Lib/sandbox/pyloess/__init__.py =================================================================== --- trunk/Lib/sandbox/pyloess/__init__.py 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/__init__.py 2007-03-21 22:53:54 UTC (rev 2863) @@ -1,10 +1,16 @@ """ -Numpy wrappers for lowess and stl. +Numpy wrappers for lowess, loess and stl. + + +:author: Pierre GF Gerard-Marchant +:contact: pierregm_at_uga_edu +:date: $Date$ +:version: $Id$ """ __author__ = "Pierre GF Gerard-Marchant" __version__ = '1.0' -__revision__ = "$Revision: 150 $" -__date__ = '$Date: 2007-02-28 23:42:16 -0500 (Wed, 28 Feb 2007) $' +__revision__ = "$Revision$" +__date__ = '$Date$' import pyloess -from pyloess import lowess, stl \ No newline at end of file +from pyloess import lowess, stl, loess, loess_anova \ No newline at end of file Property changes on: trunk/Lib/sandbox/pyloess/__init__.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Modified: trunk/Lib/sandbox/pyloess/pyloess.py =================================================================== --- trunk/Lib/sandbox/pyloess/pyloess.py 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/pyloess.py 2007-03-21 22:53:54 UTC (rev 2863) @@ -8,35 +8,43 @@ initial author: W. S. Cleveland, 1979. Simple to double precision conversion of the Fortran code by Pierre -GERARD-MARCHANT, 2007/03. +Gerard-Marchant, 2007/03. STL: Initial Fortran code available at: http://netlib.bell-labs.com/netlib/a/stl.gz Initial Authors: R. B. Cleveland, W. S. Cleveland, J. E. McRae, and I. Terpenning, 1990. -Simple-to-double precision conversion of the Fortran code by Pierre -GERARD-MARCHANT, 2007/03. +Simple-to-double precision conversion of the Fortran code by Pierre +Gerard-Marchant, 2007/03. +LOESS: +Initial C/Fortran package avialable at +http://netlib.bell-labs.com/netlib/a/dloess.gz +Initial authors: W. S. Cleveland, E. Grosse and Shyu +Adaptation to Pyrex/Python by Pierre Gerard-Marchant, 2007/03 :author: Pierre GF Gerard-Marchant :contact: pierregm_at_uga_edu -:date: $Date: 2007-02-28 02:23:25 -0500 (Wed, 28 Feb 2007) $ -:version: $Id: generic.py 145 2007-02-28 07:23:25Z backtopop $ +:date: $Date$ +:version: $Id$ """ -__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__author__ = "Pierre GF Gerard-Marchant ($Author$)" __version__ = '1.0' -__revision__ = "$Revision: 145 $" -__date__ = '$Date: 2007-02-28 02:23:25 -0500 (Wed, 28 Feb 2007) $' +__revision__ = "$Revision$" +__date__ = '$Date$' import numpy from numpy import bool_, complex_, float_, int_, str_, object_ import numpy.core.numeric as numeric from numpy.core.records import recarray -import _lowess, _stl +import _lowess, _stl, _loess +#####--------------------------------------------------------------------------- +#--- --- STL --- +#####--------------------------------------------------------------------------- def lowess(x,y,f=0.5,nsteps=2,delta=0): """Performs a robust locally weighted regression (lowess). @@ -141,9 +149,9 @@ return numeric.fromiter(zip(*_lowess.lowess(x,y,f,nsteps,delta,)), dtype=dtyp).view(recarray) -#-------------------------------------------------------------------------- +#####--------------------------------------------------------------------------- #--- --- STL --- -#####---------------------------------------------------------------------- +#####--------------------------------------------------------------------------- def stl(y, np=12, ns=7, nt=None, nl=13, isdeg=1, itdeg=1, ildeg=1, nsjump=None,ntjump=None,nljump=None, robust=True, ni=None,no=None): """Decomposes a time series into seasonal and trend components. @@ -264,5 +272,124 @@ result = numeric.fromiter(zip(trn,szn,y-trn-szn,rw), dtype=dtyp) return result.view(recarray) -################################################################################ +#####--------------------------------------------------------------------------- +#--- --- Loess --- +#####--------------------------------------------------------------------------- +loess = _loess.loess +""" +loess : locally weighted estimates. Multi-variate version +:Keywords: + x : ndarray + A (n,p) ndarray of independent variables, with n the number of observations + and p the number of variables. + y : ndarray + A (n,) ndarray of observations + weights : ndarray + A (n,) ndarray of weights to be given to individual observations in the + sum of squared residuals that forms the local fitting criterion. If not + None, the weights should be non negative. If the different observations + have non-equal variances, the weights should be inversely proportional + to the variances. + By default, an unweighted fit is carried out (all the weights are one). + surface : string ["interpolate"] + Determines whether the fitted surface is computed directly at all points + ("direct") or whether an interpolation method is used ("interpolate"). + The default ("interpolate") is what most users should use unless special + circumstances warrant. + statistics : string ["approximate"] + Determines whether the statistical quantities are computed exactly + ("exact") or approximately ("approximate"). "exact" should only be used + for testing the approximation in statistical development and is not meant + for routine usage because computation time can be horrendous. + trace_hat : string ["wait.to.decide"] + Determines how the trace of the hat matrix should be computed. The hat + matrix is used in the computation of the statistical quantities. + If "exact", an exact computation is done; this could be slow when the + number of observations n becomes large. If "wait.to.decide" is selected, + then a default is "exact" for n < 500 and "approximate" otherwise. + This option is only useful when the fitted surface is interpolated. If + surface is "exact", an exact computation is always done for the trace. + Setting trace_hat to "approximate" for large dataset will substantially + reduce the computation time. + iterations : integer + Number of iterations of the robust fitting method. If the family is + "gaussian", the number of iterations is set to 0. + cell : integer + Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span), + where n is the number of observations, and span the smoothing parameter. + Then, a cell is further divided if the number of observations within it + is greater than or equal to k. This option is only used if the surface + is interpolated. + span : float [0.75] + Smoothing factor, as a fraction of the number of points to take into + account. + degree : integer [2] + Overall degree of locally-fitted polynomial. 1 is locally-linear + fitting and 2 is locally-quadratic fitting. Degree should be 2 at most. + normalize : boolean [True] + Determines whether the independent variables should be normalized. + If True, the normalization is performed by setting the 10% trimmed + standard deviation to one. If False, no normalization is carried out. + This option is only useful for more than one variable. For spatial + coordinates predictors or variables with a common scale, it should be + set to False. + family : string ["gaussian"] + Determines the assumed distribution of the errors. The values are + "gaussian" or "symmetric". If "gaussian" is selected, the fit is + performed with least-squares. If "symmetric" is selected, the fit + is performed robustly by redescending M-estimators. + parametric_flags : sequence [ [False]*p ] + Indicates which independent variables should be conditionally-parametric + (if there are two or more independent variables). The argument should + be a sequence of booleans, with the same size as the number of independent + variables, specified in the order of the predictor group ordered in x. + drop_square : sequence [ [False]* p] + When there are two or more independent variables and when a 2nd order + polynomial is used, "drop_square_flags" specifies those numeric predictors + whose squares should be dropped from the set of fitting variables. + The method of specification is the same as for parametric. + +:Outputs: + fitted_values : ndarray + The (n,) ndarray of fitted values. + fitted_residuals : ndarray + The (n,) ndarray of fitted residuals (observations - fitted values). + enp : float + Equivalent number of parameters. + s : float + Estimate of the scale of residuals. + one_delta: float + Statistical parameter used in the computation of standard errors. + two_delta : float + Statistical parameter used in the computation of standard errors. + pseudovalues : ndarray + The (n,) ndarray of adjusted values of the response when robust estimation + is used. + trace_hat : float + Trace of the operator hat matrix. + diagonal : + Diagonal of the operator hat matrix. + robust : ndarray + The (n,) ndarray of robustness weights for robust fitting. + divisor : ndarray + The (p,) array of normalization divisors for numeric predictors. + + + newdata : ndarray + The (m,p) array of independent variables where the surface must be estimated. + values : ndarray + The (m,) ndarray of loess values evaluated at newdata + stderr : ndarray + The (m,) ndarray of the estimates of the standard error on the estimated + values. + residual_scale : float + Estimate of the scale of the residuals + df : integer + Degrees of freedom of the t-distribution used to compute pointwise + confidence intervals for the evaluated surface. + nest : integer + Number of new observations. +""" + +loess_anova = _loess.anova Property changes on: trunk/Lib/sandbox/pyloess/pyloess.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Modified: trunk/Lib/sandbox/pyloess/setup.py =================================================================== --- trunk/Lib/sandbox/pyloess/setup.py 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/setup.py 2007-03-21 22:53:54 UTC (rev 2863) @@ -1,22 +1,43 @@ #!/usr/bin/env python +__author__ = "Pierre GF Gerard-Marchant ($Author$)" __version__ = '1.0' -__revision__ = "$Revision: 2811 $" -__date__ = '$Date: 2007-03-02 06:30:02 -0500 (Fri, 02 Mar 2007) $' +__revision__ = "$Revision$" +__date__ = '$Date$' import os from os.path import join def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration + from numpy.distutils.system_info import get_info, dict_append confgr = Configuration('pyloess',parent_package,top_path) + # Configuration of LOWESS confgr.add_extension('_lowess', sources=[join('src', 'f_lowess.pyf'), join('src', 'lowess.f'),] ) + # Configuration of STL confgr.add_extension('_stl', sources=[join('src', 'f_stl.pyf'), join('src', 'stl.f')], ) + # Configuration of LOESS + f_sources = ('loessf.f', 'linpack_lite.f') + confgr.add_library('floess', + sources = [join('src',x) for x in f_sources]) + blas_info = get_info('blas_opt') + build_info = {} + dict_append(build_info, **blas_info) + dict_append(build_info, libraries=['floess']) + c_sources = ['_loess.c', 'loess.c', 'loessc.c', 'misc.c', 'predict.c',] + confgr.add_extension('_loess', + sources=[join('src', x) for x in c_sources], + depends = [join('src','*.h'), + join('src','*.pyx'), + join('src','*.pxd') + ], + **build_info + ) confgr.add_data_dir('tests') return confgr Property changes on: trunk/Lib/sandbox/pyloess/setup.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Added: trunk/Lib/sandbox/pyloess/src/S.h =================================================================== --- trunk/Lib/sandbox/pyloess/src/S.h 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/S.h 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,32 @@ +#include +#include + +#define Calloc(n,t) (t *)calloc((unsigned)(n),sizeof(t)) +#define Free(p) free((char *)(p)) + +/* the mapping from f77 to C intermediate code -- may be machine dependent + * the first definition satisfies lint's narrowminded preprocessing & should + * stay the same for all implementations. The __STDC__ definition is for + * ANSI standard conforming C compilers. The #else definition should + * generate the version of the fortran subroutine & common block names x + * handed to the local loader; e.g., "x_" in system V, Berkeley & 9th edition + */ + +#ifdef lint +#define F77_SUB(x) x +#define F77_COM(x) x +#else +#ifdef __STDC__ +#define F77_SUB(x) x##_ +#define F77_COM(x) x##_ +#else +#define F77_SUB(x) x/**/_ +#define F77_COM(x) x/**/_ +#endif +#endif + +#define NULL_ENTRY ((int *)NULL) + + + + Added: trunk/Lib/sandbox/pyloess/src/_loess.c =================================================================== --- trunk/Lib/sandbox/pyloess/src/_loess.c 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/_loess.c 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,6287 @@ +/* Generated by Pyrex 0.9.5.1a on Wed Mar 21 17:37:22 2007 */ + +#include "Python.h" +#include "structmember.h" +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifdef __cplusplus +#define __PYX_EXTERN_C extern "C" +#else +#define __PYX_EXTERN_C extern +#endif +__PYX_EXTERN_C double pow(double, double); +#include "stdlib.h" +#include "numpy/arrayobject.h" +#include "loess.h" +#include "cloess.h" + + +typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ +typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ + +static PyObject *__pyx_m; +static PyObject *__pyx_b; +static int __pyx_lineno; +static char *__pyx_filename; +static char **__pyx_f; + +static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/ + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ + +static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ + +static PyObject *__Pyx_UnpackItem(PyObject *); /*proto*/ +static int __Pyx_EndUnpack(PyObject *); /*proto*/ + +static int __Pyx_PrintItem(PyObject *); /*proto*/ +static int __Pyx_PrintNewline(void); /*proto*/ + +static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ + +static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ + +static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/ + +static void __Pyx_AddTraceback(char *funcname); /*proto*/ + +/* Declarations from c_python */ + + +/* Declarations from c_numpy */ + +static PyTypeObject *__pyx_ptype_7c_numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_7c_numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_7c_numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_7c_numpy_broadcast = 0; + +/* Declarations from c_loess */ + + +/* Declarations from _loess */ + + +struct __pyx_obj_6_loess_loess_inputs { + PyObject_HEAD + loess_inputs (*_base); +}; + + +struct __pyx_obj_6_loess_loess_control { + PyObject_HEAD + loess_control (*_base); +}; + + +struct __pyx_obj_6_loess_loess_kd_tree { + PyObject_HEAD + loess_kd_tree (*_base); +}; + + +struct __pyx_obj_6_loess_loess_model { + PyObject_HEAD + struct __pyx_vtabstruct_6_loess_loess_model *__pyx_vtab; + loess_model (*_base); + long npar; +}; + +struct __pyx_vtabstruct_6_loess_loess_model { + PyObject *((*setup)(struct __pyx_obj_6_loess_loess_model *,loess_model (*),long )); +}; +static struct __pyx_vtabstruct_6_loess_loess_model *__pyx_vtabptr_6_loess_loess_model; + + +struct __pyx_obj_6_loess_loess_outputs { + PyObject_HEAD + loess_outputs (*_base); + long nobs; + long npar; + int activated; +}; + + +struct __pyx_obj_6_loess_conf_intervals { + PyObject_HEAD + struct __pyx_vtabstruct_6_loess_conf_intervals *__pyx_vtab; + conf_inv _base; + PyArrayObject *lower; + PyArrayObject *fit; + PyArrayObject *upper; +}; + +struct __pyx_vtabstruct_6_loess_conf_intervals { + PyObject *((*setup)(struct __pyx_obj_6_loess_conf_intervals *,conf_inv ,long )); +}; +static struct __pyx_vtabstruct_6_loess_conf_intervals *__pyx_vtabptr_6_loess_conf_intervals; + + +struct __pyx_obj_6_loess_loess_predicted { + PyObject_HEAD + struct __pyx_vtabstruct_6_loess_loess_predicted *__pyx_vtab; + prediction _base; + long nest; + struct __pyx_obj_6_loess_conf_intervals *confidence_intervals; +}; + +struct __pyx_vtabstruct_6_loess_loess_predicted { + PyObject *((*setup)(struct __pyx_obj_6_loess_loess_predicted *,prediction ,long )); +}; +static struct __pyx_vtabstruct_6_loess_loess_predicted *__pyx_vtabptr_6_loess_loess_predicted; + + +struct __pyx_obj_6_loess_loess { + PyObject_HEAD + loess _base; + struct __pyx_obj_6_loess_loess_inputs *inputs; + struct __pyx_obj_6_loess_loess_model *model; + struct __pyx_obj_6_loess_loess_control *control; + struct __pyx_obj_6_loess_loess_kd_tree *kd_tree; + struct __pyx_obj_6_loess_loess_outputs *outputs; + struct __pyx_obj_6_loess_loess_predicted *predicted; + long nobs; + long npar; +}; + + +struct __pyx_obj_6_loess_anova { + PyObject_HEAD + double dfn; + double dfd; + double F_value; + double Pr_F; +}; + +static PyTypeObject *__pyx_ptype_6_loess_loess_inputs = 0; +static PyTypeObject *__pyx_ptype_6_loess_loess_control = 0; +static PyTypeObject *__pyx_ptype_6_loess_loess_kd_tree = 0; +static PyTypeObject *__pyx_ptype_6_loess_loess_model = 0; +static PyTypeObject *__pyx_ptype_6_loess_loess_outputs = 0; +static PyTypeObject *__pyx_ptype_6_loess_conf_intervals = 0; +static PyTypeObject *__pyx_ptype_6_loess_loess_predicted = 0; +static PyTypeObject *__pyx_ptype_6_loess_loess = 0; +static PyTypeObject *__pyx_ptype_6_loess_anova = 0; +static PyObject *__pyx_k32; +static PyObject *__pyx_k33; +static PyObject *__pyx_k34; +static PyObject *(__pyx_f_6_loess_floatarray_from_data(int ,int ,double (*))); /*proto*/ +static PyObject *(__pyx_f_6_loess_boolarray_from_data(int ,int ,int (*))); /*proto*/ + + +/* Implementation of _loess */ + +static char (__pyx_k1[]) = "A (n,) ndarray of weights to be given to individual observations in the \n sum of squared residuals that forms the local fitting criterion. If not\n None, the weights should be non negative. If the different observations\n have non-equal variances, the weights should be inversely proportional \n to the variances.\n By default, an unweighted fit is carried out (all the weights are one).\n "; +static char (__pyx_k2[]) = "Number of observations."; +static char (__pyx_k3[]) = "Number of independent variables."; +static char (__pyx_k4[]) = "\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n "; +static char (__pyx_k5[]) = "\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n "; +static char (__pyx_k6[]) = "\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n "; +static char (__pyx_k7[]) = "\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n "; +static char (__pyx_k8[]) = "\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n "; +static char (__pyx_k9[]) = "\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n "; +static char (__pyx_k10[]) = "Smoothing factor, as a fraction of the number of points to take into\n account. By default, span=0.75."; +static char (__pyx_k11[]) = "\n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n "; +static char (__pyx_k12[]) = "\n family : string [\"gaussian\"]\n Determines the assumed distribution of the errors. The values are \n \"gaussian\" or \"symmetric\". If \"gaussian\" is selected, the fit is \n performed with least-squares. If \"symmetric\" is selected, the fit\n is performed robustly by redescending M-estimators.\n "; +static char (__pyx_k13[]) = "\n parametric_flags : sequence [ [False]*p ]\n Indicates which independent variables should be conditionally-parametric\n (if there are two or more independent variables). The argument should \n be a sequence of booleans, with the same size as the number of independent \n variables, specified in the order of the predictor group ordered in x. \n "; +static char (__pyx_k14[]) = "\n drop_square : sequence [ [False]* p]\n When there are two or more independent variables and when a 2nd order\n polynomial is used, \"drop_square_flags\" specifies those numeric predictors \n whose squares should be dropped from the set of fitting variables. \n The method of specification is the same as for parametric. \n "; +static char (__pyx_k15[]) = "\n fitted_values : ndarray\n The (n,) ndarray of fitted values.\n "; +static char (__pyx_k16[]) = "\n fitted_residuals : ndarray\n The (n,) ndarray of fitted residuals (observations - fitted values).\n "; +static char (__pyx_k17[]) = "\n pseudovalues : ndarray\n The (n,) ndarray of adjusted values of the response when robust estimation \n is used.\n "; +static char (__pyx_k18[]) = "\n diagonal :\n Diagonal of the operator hat matrix.\n "; +static char (__pyx_k19[]) = "\n robust : ndarray\n The (n,) ndarray of robustness weights for robust fitting.\n "; +static char (__pyx_k20[]) = "Equivalent number of parameters."; +static char (__pyx_k21[]) = "\n enp : float\n Equivalent number of parameters.\n "; +static char (__pyx_k22[]) = "\n s : float\n Estimate of the scale of residuals.\n "; +static char (__pyx_k23[]) = "\n one_delta: float\n Statistical parameter used in the computation of standard errors.\n "; +static char (__pyx_k24[]) = "\n two_delta : float\n Statistical parameter used in the computation of standard errors.\n "; +static char (__pyx_k25[]) = "\n trace_hat : float \n Trace of the operator hat matrix.\n "; +static char (__pyx_k26[]) = "\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n "; +static char (__pyx_k27[]) = "\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n "; +static char (__pyx_k28[]) = "\n residual_scale : float\n Estimate of the scale of the residuals\n "; +static char (__pyx_k29[]) = "\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n "; +static char (__pyx_k31[]) = "\n:Keywords:\n x : ndarray\n A (n,p) ndarray of independent variables, with n the number of observations\n and p the number of variables.\n y : ndarray\n A (n,) ndarray of observations\n weights : ndarray\n A (n,) ndarray of weights to be given to individual observations in the \n sum of squared residuals that forms the local fitting criterion. If not\n None, the weights should be non negative. If the different observations\n have non-equal variances, the weights should be inversely proportional \n to the variances.\n By default, an unweighted fit is carried out (all the weights are one).\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n span : float [0.75]\n Smoothing factor, as a fraction of the number of points to take into\n account. \n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n family : string [\"gaussian\"]\n Determines the assumed distribution of the errors. The values are \n \"gaussian\" or \"symmetric\". If \"gaussian\" is selected, the fit is \n performed with least-squares. If \"symmetric\" is selected, the fit\n is performed robustly by redescending M-estimators.\n parametric_flags : sequence [ [False]*p ]\n Indicates which independent variables should be conditionally-parametric\n (if there are two or more independent variables). The argument should \n be a sequence of booleans, with the same size as the number of independent \n variables, specified in the order of the predictor group ordered in x. \n drop_square : sequence [ [False]* p]\n When there are two or more independent variables and when a 2nd order\n polynomial is used, \"drop_square_flags\" specifies those numeric predictors \n whose squares should be dropped from the set of fitting variables. \n The method of specification is the same as for parametric. \n \n:Outputs:\n fitted_values : ndarray\n The (n,) ndarray of fitted values.\n fitted_residuals : ndarray\n The (n,) ndarray of fitted residuals (observations - fitted values).\n enp : float\n Equivalent number of parameters.\n s : float\n Estimate of the scale of residuals.\n one_delta: float\n Statistical parameter used in the computation of standard errors.\n two_delta : float\n Statistical parameter used in the computation of standard errors.\n pseudovalues : ndarray\n The (n,) ndarray of adjusted values of the response when robust estimation \n is used.\n trace_hat : float \n Trace of the operator hat matrix.\n diagonal :\n Diagonal of the operator hat matrix.\n robust : ndarray\n The (n,) ndarray of robustness weights for robust fitting.\n divisor : ndarray\n The (p,) array of normalization divisors for numeric predictors.\n \n\n newdata : ndarray\n The (m,p) array of independent variables where the surface must be estimated.\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n residual_scale : float\n Estimate of the scale of the residuals\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n nest : integer\n Number of new observations.\n \n \n"; + +static PyObject *__pyx_n_c_python; +static PyObject *__pyx_n_c_numpy; +static PyObject *__pyx_n_numpy; +static PyObject *__pyx_n_narray; +static PyObject *__pyx_n_c_loess; +static PyObject *__pyx_n_array; +static PyObject *__pyx_n_False; + +static PyObject *__pyx_n_shape; + +static PyObject *__pyx_f_6_loess_floatarray_from_data(int __pyx_v_rows,int __pyx_v_cols,double (*__pyx_v_data)) { + PyArrayObject *__pyx_v_a_ndr; + npy_intp __pyx_v_size; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + __pyx_v_a_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":19 */ + __pyx_v_size = (__pyx_v_rows * __pyx_v_cols); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":20 */ + __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_1)); + Py_DECREF(((PyObject *)__pyx_v_a_ndr)); + __pyx_v_a_ndr = ((PyArrayObject *)((PyObject *)__pyx_1)); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":21 */ + __pyx_2 = (__pyx_v_cols > 1); + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":22 */ + __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); + PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3); + __pyx_1 = 0; + __pyx_3 = 0; + if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":23 */ + Py_INCREF(((PyObject *)__pyx_v_a_ndr)); + __pyx_r = ((PyObject *)__pyx_v_a_ndr); + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.floatarray_from_data"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_a_ndr); + return __pyx_r; +} + +static PyObject *__pyx_n_astype; +static PyObject *__pyx_n_bool; + +static PyObject *__pyx_f_6_loess_boolarray_from_data(int __pyx_v_rows,int __pyx_v_cols,int (*__pyx_v_data)) { + PyArrayObject *__pyx_v_a_ndr; + npy_intp __pyx_v_size; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + __pyx_v_a_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":28 */ + __pyx_v_size = (__pyx_v_rows * __pyx_v_cols); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":29 */ + __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_1)); + Py_DECREF(((PyObject *)__pyx_v_a_ndr)); + __pyx_v_a_ndr = ((PyArrayObject *)((PyObject *)__pyx_1)); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":30 */ + __pyx_2 = (__pyx_v_cols > 1); + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":31 */ + __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); + PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3); + __pyx_1 = 0; + __pyx_3 = 0; + if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":32 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_astype); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_bool); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4); + __pyx_4 = 0; + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.boolarray_from_data"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_a_ndr); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_12loess_inputs_1x___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_12loess_inputs_1x___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":198 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->n,((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->p,((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->x); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_inputs.x.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_12loess_inputs_1y___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_12loess_inputs_1y___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":202 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->n,1,((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->y); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_inputs.y.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_12loess_inputs_7weights___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_12loess_inputs_7weights___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":213 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->n,1,((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->weights); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_inputs.weights.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_ndim; +static PyObject *__pyx_n_size; +static PyObject *__pyx_n_ValueError; + +static PyObject *__pyx_k35p; + +static char (__pyx_k35[]) = "Invalid size of the 'weights' vector!"; + +static int __pyx_f_6_loess_12loess_inputs_7weights___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_w); /*proto*/ +static int __pyx_f_6_loess_12loess_inputs_7weights___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_w) { + PyArrayObject *__pyx_v_w_ndr; + int __pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_w); + __pyx_v_w_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":218 */ + __pyx_1 = PyArray_FROMANY(__pyx_v_w,NPY_DOUBLE,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;} + Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + Py_DECREF(((PyObject *)__pyx_v_w_ndr)); + __pyx_v_w_ndr = ((PyArrayObject *)__pyx_1); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":219 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_ndim); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} + __pyx_2 = __pyx_2 > 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__pyx_2) { + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} + __pyx_2 = __pyx_2 != 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + } + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":220 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;} + __Pyx_Raise(__pyx_1, __pyx_k35p, 0); + Py_DECREF(__pyx_1); __pyx_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":221 */ + ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->weights = ((double (*))__pyx_v_w_ndr->data); + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_loess.loess_inputs.weights.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_w_ndr); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_w); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_12loess_inputs_4nobs___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_12loess_inputs_4nobs___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":226 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_inputs.nobs.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_12loess_inputs_4npar___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_12loess_inputs_4npar___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":231 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_inputs.npar.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_control_7surface___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_control_7surface___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":248 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_control.surface.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_lower; +static PyObject *__pyx_n_interpolate; +static PyObject *__pyx_n_direct; + +static PyObject *__pyx_k38p; +static PyObject *__pyx_k39p; + +static char (__pyx_k38[]) = "Invalid value for the 'surface' argument: "; +static char (__pyx_k39[]) = "should be in ('interpolate', 'direct')."; + +static int __pyx_f_6_loess_13loess_control_7surface___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_surface); /*proto*/ +static int __pyx_f_6_loess_13loess_control_7surface___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_surface) { + PyObject *__pyx_v_tmpx; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + PyObject *__pyx_4 = 0; + char (*__pyx_5); + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_surface); + __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":250 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;} + Py_INCREF(__pyx_n_interpolate); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_interpolate); + Py_INCREF(__pyx_n_direct); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_direct); + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;} + __pyx_3 = !__pyx_3; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":251 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + __pyx_1 = PyNumber_Add(__pyx_k38p, __pyx_k39p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); + __pyx_1 = 0; + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_1, 0, 0); + Py_DECREF(__pyx_1); __pyx_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":253 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_tmpx); + __pyx_v_tmpx = __pyx_4; + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":254 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->surface = __pyx_5; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.loess_control.surface.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_tmpx); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_surface); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_control_10statistics___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_control_10statistics___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":265 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_control.statistics.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_approximate; +static PyObject *__pyx_n_exact; + +static PyObject *__pyx_k42p; + +static char (__pyx_k42[]) = "Invalid value for the 'statistics' argument: should be in ('approximate', 'exact')."; + +static int __pyx_f_6_loess_13loess_control_10statistics___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_statistics); /*proto*/ +static int __pyx_f_6_loess_13loess_control_10statistics___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_statistics) { + PyObject *__pyx_v_tmpx; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + PyObject *__pyx_4 = 0; + char (*__pyx_5); + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_statistics); + __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":267 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + Py_INCREF(__pyx_n_approximate); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_approximate); + Py_INCREF(__pyx_n_exact); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_exact); + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + __pyx_3 = !__pyx_3; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":268 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + Py_INCREF(__pyx_k42p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k42p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":270 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_tmpx); + __pyx_v_tmpx = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":271 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->statistics = __pyx_5; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.loess_control.statistics.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_tmpx); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_statistics); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_control_9trace_hat___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_control_9trace_hat___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":287 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_control.trace_hat.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k45p; + +static char (__pyx_k45[]) = "Invalid value for the 'trace_hat' argument: should be in ('approximate', 'exact')."; + +static int __pyx_f_6_loess_13loess_control_9trace_hat___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_trace_hat); /*proto*/ +static int __pyx_f_6_loess_13loess_control_9trace_hat___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_trace_hat) { + PyObject *__pyx_v_tmpx; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + PyObject *__pyx_4 = 0; + char (*__pyx_5); + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_trace_hat); + __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":289 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + Py_INCREF(__pyx_n_approximate); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_approximate); + Py_INCREF(__pyx_n_exact); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_exact); + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + __pyx_3 = !__pyx_3; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":290 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + Py_INCREF(__pyx_k45p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k45p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":292 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_tmpx); + __pyx_v_tmpx = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":293 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->trace_hat = __pyx_5; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.loess_control.trace_hat.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_tmpx); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_trace_hat); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_control_10iterations___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_control_10iterations___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":302 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_control.iterations.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k46p; + +static char (__pyx_k46[]) = "Invalid number of iterations: should be positive"; + +static int __pyx_f_6_loess_13loess_control_10iterations___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_iterations); /*proto*/ +static int __pyx_f_6_loess_13loess_control_10iterations___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_iterations) { + int __pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_iterations); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":304 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_iterations, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;} + __pyx_2 = __pyx_2 < 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":305 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} + Py_INCREF(__pyx_k46p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k46p); + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":306 */ + __pyx_2 = PyInt_AsLong(__pyx_v_iterations); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->iterations = __pyx_2; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.loess_control.iterations.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_iterations); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_control_4cell___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_control_4cell___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":318 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_control.cell.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k47p; + +static char (__pyx_k47[]) = "Invalid value for the cell argument: should be positive"; + +static int __pyx_f_6_loess_13loess_control_4cell___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_cell); /*proto*/ +static int __pyx_f_6_loess_13loess_control_4cell___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_cell) { + int __pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + double __pyx_5; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_cell); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":320 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_cell, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; goto __pyx_L1;} + __pyx_2 = __pyx_2 <= 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":321 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;} + Py_INCREF(__pyx_k47p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k47p); + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":322 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_cell); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->cell = __pyx_5; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.loess_control.cell.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_cell); + return __pyx_r; +} + +static PyObject *__pyx_n_get; +static PyObject *__pyx_n_surface; +static PyObject *__pyx_n_statistics; +static PyObject *__pyx_n_trace_hat; +static PyObject *__pyx_n_iterations; +static PyObject *__pyx_n_cell; +static PyObject *__pyx_n_parametric_flags; + + +static PyObject *__pyx_f_6_loess_13loess_control_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6_loess_13loess_control_update[] = "Updates several parameters at once."; +static PyObject *__pyx_f_6_loess_13loess_control_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_cellargs = 0; + PyObject *__pyx_v_surface; + PyObject *__pyx_v_statistics; + PyObject *__pyx_v_trace_hat; + PyObject *__pyx_v_iterations; + PyObject *__pyx_v_cell; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + int __pyx_4; + static char *__pyx_argnames[] = {0}; + if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, 0, &__pyx_v_cellargs) < 0) return 0; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) { + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + Py_XDECREF(__pyx_v_cellargs); + return 0; + } + Py_INCREF(__pyx_v_self); + __pyx_v_surface = Py_None; Py_INCREF(Py_None); + __pyx_v_statistics = Py_None; Py_INCREF(Py_None); + __pyx_v_trace_hat = Py_None; Py_INCREF(Py_None); + __pyx_v_iterations = Py_None; Py_INCREF(Py_None); + __pyx_v_cell = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":326 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} + Py_INCREF(__pyx_n_surface); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_surface); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_surface); + __pyx_v_surface = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":327 */ + __pyx_4 = __pyx_v_surface != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":328 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_surface, __pyx_v_surface) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":330 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;} + Py_INCREF(__pyx_n_statistics); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_statistics); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_statistics); + __pyx_v_statistics = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":331 */ + __pyx_4 = __pyx_v_statistics != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":332 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_statistics, __pyx_v_statistics) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":334 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;} + Py_INCREF(__pyx_n_trace_hat); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_trace_hat); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_trace_hat); + __pyx_v_trace_hat = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":335 */ + __pyx_4 = __pyx_v_trace_hat != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":336 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_trace_hat, __pyx_v_trace_hat) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;} + goto __pyx_L4; + } + __pyx_L4:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":338 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;} + Py_INCREF(__pyx_n_iterations); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_iterations); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_iterations); + __pyx_v_iterations = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":339 */ + __pyx_4 = __pyx_v_iterations != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":340 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_iterations, __pyx_v_iterations) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":342 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;} + Py_INCREF(__pyx_n_cell); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_cell); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_cell); + __pyx_v_cell = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":343 */ + __pyx_4 = __pyx_v_cell != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":344 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;} + goto __pyx_L6; + } + __pyx_L6:; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_loess.loess_control.update"); + __pyx_r = 0; + __pyx_L0:; + Py_XDECREF(__pyx_v_cellargs); + Py_DECREF(__pyx_v_surface); + Py_DECREF(__pyx_v_statistics); + Py_DECREF(__pyx_v_trace_hat); + Py_DECREF(__pyx_v_iterations); + Py_DECREF(__pyx_v_cell); + Py_DECREF(__pyx_v_self); + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + return __pyx_r; +} + +static PyObject *__pyx_n_join; + +static PyObject *__pyx_k53p; +static PyObject *__pyx_k54p; +static PyObject *__pyx_k55p; +static PyObject *__pyx_k56p; +static PyObject *__pyx_k57p; +static PyObject *__pyx_k58p; +static PyObject *__pyx_k59p; + +static char (__pyx_k53[]) = "Control :"; +static char (__pyx_k54[]) = "Surface type : %s"; +static char (__pyx_k55[]) = "Statistics : %s"; +static char (__pyx_k56[]) = "Trace estimation : %s"; +static char (__pyx_k57[]) = "Cell size : %s"; +static char (__pyx_k58[]) = "Nb iterations : %s"; +static char (__pyx_k59[]) = "\n"; + +static PyObject *__pyx_f_6_loess_13loess_control___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_control___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_strg; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_strg = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":348 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k54p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k55p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k56p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k57p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;} + __pyx_6 = PyNumber_Remainder(__pyx_k58p, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyList_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;} + Py_INCREF(__pyx_k53p); + PyList_SET_ITEM(__pyx_1, 0, __pyx_k53p); + PyList_SET_ITEM(__pyx_1, 1, __pyx_2); + PyList_SET_ITEM(__pyx_1, 2, __pyx_3); + PyList_SET_ITEM(__pyx_1, 3, __pyx_4); + PyList_SET_ITEM(__pyx_1, 4, __pyx_5); + PyList_SET_ITEM(__pyx_1, 5, __pyx_6); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_6 = 0; + Py_DECREF(__pyx_v_strg); + __pyx_v_strg = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":354 */ + __pyx_2 = PyObject_GetAttr(__pyx_k59p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;} + Py_INCREF(__pyx_v_strg); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + __Pyx_AddTraceback("_loess.loess_control.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_strg); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_11loess_model_setup(struct __pyx_obj_6_loess_loess_model *__pyx_v_self,loess_model (*__pyx_v_base),long __pyx_v_npar) { + PyObject *__pyx_r; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":375 */ + __pyx_v_self->_base = __pyx_v_base; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":376 */ + __pyx_v_self->npar = __pyx_v_npar; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":386 */ + Py_INCREF(((PyObject *)__pyx_v_self)); + __pyx_r = ((PyObject *)__pyx_v_self); + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_11loess_model_9normalize___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_11loess_model_9normalize___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":399 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_bool); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->normalize); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); + __pyx_2 = 0; + __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_2; + __pyx_2 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_loess.loess_model.normalize.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static int __pyx_f_6_loess_11loess_model_9normalize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_normalize); /*proto*/ +static int __pyx_f_6_loess_11loess_model_9normalize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_normalize) { + int __pyx_r; + int __pyx_1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_normalize); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":401 */ + __pyx_1 = PyInt_AsLong(__pyx_v_normalize); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->normalize = __pyx_1; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + __Pyx_AddTraceback("_loess.loess_model.normalize.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_normalize); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_11loess_model_4span___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_11loess_model_4span___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":407 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_model.span.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k60p; + +static char (__pyx_k60[]) = "Span should be between 0 and 1!"; + +static int __pyx_f_6_loess_11loess_model_4span___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_span); /*proto*/ +static int __pyx_f_6_loess_11loess_model_4span___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_span) { + int __pyx_r; + int __pyx_1; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + double __pyx_5; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_span); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":409 */ + __pyx_2 = PyFloat_FromDouble(0.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} + __pyx_1 = __pyx_1 <= 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (!__pyx_1) { + __pyx_2 = PyFloat_FromDouble(1.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} + __pyx_1 = __pyx_1 > 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + } + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":410 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;} + Py_INCREF(__pyx_k60p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k60p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":411 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_span); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->span = __pyx_5; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.loess_model.span.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_span); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_11loess_model_6degree___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_11loess_model_6degree___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":420 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_model.degree.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k61p; + +static char (__pyx_k61[]) = "Degree should be between 0 and 2!"; + +static int __pyx_f_6_loess_11loess_model_6degree___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_degree); /*proto*/ +static int __pyx_f_6_loess_11loess_model_6degree___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_degree) { + int __pyx_r; + int __pyx_1; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_degree); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":422 */ + __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} + __pyx_1 = __pyx_1 < 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (!__pyx_1) { + __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} + __pyx_1 = __pyx_1 > 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + } + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":423 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} + Py_INCREF(__pyx_k61p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k61p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.loess_model.degree.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_degree); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_11loess_model_6family___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_11loess_model_6family___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":434 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_model.family.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_symmetric; +static PyObject *__pyx_n_gaussian; + +static PyObject *__pyx_k64p; + +static char (__pyx_k64[]) = "Invalid value for the 'family' argument: should be in ('symmetric', 'gaussian')."; + +static int __pyx_f_6_loess_11loess_model_6family___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_family); /*proto*/ +static int __pyx_f_6_loess_11loess_model_6family___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_family) { + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + PyObject *__pyx_4 = 0; + char (*__pyx_5); + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_family); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":436 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_family, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} + Py_INCREF(__pyx_n_symmetric); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_symmetric); + Py_INCREF(__pyx_n_gaussian); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_gaussian); + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} + __pyx_3 = !__pyx_3; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":437 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + Py_INCREF(__pyx_k64p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k64p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":439 */ + __pyx_5 = PyString_AsString(__pyx_v_family); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->family = __pyx_5; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.loess_model.family.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_family); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_11loess_model_16parametric_flags___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_11loess_model_16parametric_flags___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":450 */ + __pyx_1 = __pyx_f_6_loess_boolarray_from_data(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->parametric); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_model.parametric_flags.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_atleast_1d; +static PyObject *__pyx_n_copy; +static PyObject *__pyx_n_True; +static PyObject *__pyx_n_subok; +static PyObject *__pyx_n_dtype; +static PyObject *__pyx_n_min; + + +static int __pyx_f_6_loess_11loess_model_16parametric_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_paramf); /*proto*/ +static int __pyx_f_6_loess_11loess_model_16parametric_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_paramf) { + PyArrayObject *__pyx_v_p_ndr; + int __pyx_v_i; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + long __pyx_7; + int __pyx_8; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_paramf); + __pyx_v_p_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":454 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_atleast_1d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + Py_INCREF(__pyx_v_paramf); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_paramf); + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_bool); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (PyDict_SetItem(__pyx_4, __pyx_n_dtype, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5); + __pyx_5 = 0; + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_6); __pyx_6 = 0; + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_p_ndr)); + __pyx_v_p_ndr = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":456 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); + PyTuple_SET_ITEM(__pyx_2, 1, __pyx_5); + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_7 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_7; ++__pyx_v_i) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":457 */ + __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; goto __pyx_L1;} + __pyx_4 = PyObject_GetItem(((PyObject *)__pyx_v_p_ndr), __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_8 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + (((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->parametric[__pyx_v_i]) = __pyx_8; + } + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + __Pyx_AddTraceback("_loess.loess_model.parametric_flags.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_p_ndr); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_paramf); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_11loess_model_17drop_square_flags___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_11loess_model_17drop_square_flags___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":468 */ + __pyx_1 = __pyx_f_6_loess_boolarray_from_data(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->drop_square); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_model.drop_square_flags.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + + +static int __pyx_f_6_loess_11loess_model_17drop_square_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_drop_sq); /*proto*/ +static int __pyx_f_6_loess_11loess_model_17drop_square_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_drop_sq) { + PyArrayObject *__pyx_v_d_ndr; + int __pyx_v_i; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + long __pyx_7; + int __pyx_8; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_drop_sq); + __pyx_v_d_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":472 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_atleast_1d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + Py_INCREF(__pyx_v_drop_sq); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_drop_sq); + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_bool); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (PyDict_SetItem(__pyx_4, __pyx_n_dtype, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5); + __pyx_5 = 0; + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_6); __pyx_6 = 0; + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_d_ndr)); + __pyx_v_d_ndr = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":474 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_d_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); + PyTuple_SET_ITEM(__pyx_2, 1, __pyx_5); + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_7 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_7; ++__pyx_v_i) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":475 */ + __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; goto __pyx_L1;} + __pyx_4 = PyObject_GetItem(((PyObject *)__pyx_v_d_ndr), __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_8 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + (((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->drop_square[__pyx_v_i]) = __pyx_8; + } + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + __Pyx_AddTraceback("_loess.loess_model.drop_square_flags.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_d_ndr); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_drop_sq); + return __pyx_r; +} + +static PyObject *__pyx_n_family; +static PyObject *__pyx_n_span; +static PyObject *__pyx_n_degree; +static PyObject *__pyx_n_normalize; +static PyObject *__pyx_n_parametric; +static PyObject *__pyx_n_drop_square; +static PyObject *__pyx_n_drop_square_flags; + + +static PyObject *__pyx_f_6_loess_11loess_model_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6_loess_11loess_model_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_modelargs = 0; + PyObject *__pyx_v_family; + PyObject *__pyx_v_span; + PyObject *__pyx_v_degree; + PyObject *__pyx_v_normalize; + PyObject *__pyx_v_parametric; + PyObject *__pyx_v_drop_square; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + int __pyx_4; + static char *__pyx_argnames[] = {0}; + if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, 0, &__pyx_v_modelargs) < 0) return 0; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) { + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + Py_XDECREF(__pyx_v_modelargs); + return 0; + } + Py_INCREF(__pyx_v_self); + __pyx_v_family = Py_None; Py_INCREF(Py_None); + __pyx_v_span = Py_None; Py_INCREF(Py_None); + __pyx_v_degree = Py_None; Py_INCREF(Py_None); + __pyx_v_normalize = Py_None; Py_INCREF(Py_None); + __pyx_v_parametric = Py_None; Py_INCREF(Py_None); + __pyx_v_drop_square = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":478 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} + Py_INCREF(__pyx_n_family); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_family); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_family); + __pyx_v_family = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":479 */ + __pyx_4 = __pyx_v_family != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":480 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_family, __pyx_v_family) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":482 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; goto __pyx_L1;} + Py_INCREF(__pyx_n_span); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_span); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_span); + __pyx_v_span = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":483 */ + __pyx_4 = __pyx_v_span != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":484 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_span, __pyx_v_span) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":486 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;} + Py_INCREF(__pyx_n_degree); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_degree); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_degree); + __pyx_v_degree = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":487 */ + __pyx_4 = __pyx_v_degree != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":488 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_degree, __pyx_v_degree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; goto __pyx_L1;} + goto __pyx_L4; + } + __pyx_L4:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":490 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; goto __pyx_L1;} + Py_INCREF(__pyx_n_normalize); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_normalize); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_normalize); + __pyx_v_normalize = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":491 */ + __pyx_4 = __pyx_v_normalize != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":492 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_normalize, __pyx_v_normalize) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":494 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} + Py_INCREF(__pyx_n_parametric); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_parametric); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_parametric); + __pyx_v_parametric = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":495 */ + __pyx_4 = __pyx_v_parametric != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":496 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_parametric) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":498 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; goto __pyx_L1;} + Py_INCREF(__pyx_n_drop_square); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_drop_square); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_drop_square); + __pyx_v_drop_square = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":499 */ + __pyx_4 = __pyx_v_drop_square != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":500 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_drop_square_flags, __pyx_v_drop_square) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; goto __pyx_L1;} + goto __pyx_L7; + } + __pyx_L7:; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_loess.loess_model.update"); + __pyx_r = 0; + __pyx_L0:; + Py_XDECREF(__pyx_v_modelargs); + Py_DECREF(__pyx_v_family); + Py_DECREF(__pyx_v_span); + Py_DECREF(__pyx_v_degree); + Py_DECREF(__pyx_v_normalize); + Py_DECREF(__pyx_v_parametric); + Py_DECREF(__pyx_v_drop_square); + Py_DECREF(__pyx_v_self); + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + return __pyx_r; +} + +static PyObject *__pyx_n_id; + +static PyObject *__pyx_k77p; + +static char (__pyx_k77[]) = "loess model parameters @%s"; + +static PyObject *__pyx_f_6_loess_11loess_model___repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_11loess_model___repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":503 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;} + Py_INCREF(__pyx_v_self); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = PyNumber_Remainder(__pyx_k77p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_loess.loess_model.__repr__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k78p; +static PyObject *__pyx_k79p; +static PyObject *__pyx_k80p; +static PyObject *__pyx_k81p; +static PyObject *__pyx_k82p; +static PyObject *__pyx_k83p; +static PyObject *__pyx_k84p; +static PyObject *__pyx_k85p; + +static char (__pyx_k78[]) = "Model parameters....."; +static char (__pyx_k79[]) = "family : %s"; +static char (__pyx_k80[]) = "span : %s"; +static char (__pyx_k81[]) = "degree : %s"; +static char (__pyx_k82[]) = "normalized : %s"; +static char (__pyx_k83[]) = "parametric : %s"; +static char (__pyx_k84[]) = "drop_square : %s"; +static char (__pyx_k85[]) = "\n"; + +static PyObject *__pyx_f_6_loess_11loess_model___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_11loess_model___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_strg; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + PyObject *__pyx_7 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_strg = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":506 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k79p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k80p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k81p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_normalize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k82p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_parametric_flags); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; goto __pyx_L1;} + __pyx_6 = PySequence_GetSlice(__pyx_1, 0, ((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyNumber_Remainder(__pyx_k83p, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_drop_square_flags); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;} + __pyx_7 = PySequence_GetSlice(__pyx_6, 0, ((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_6 = PyNumber_Remainder(__pyx_k84p, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;} + Py_DECREF(__pyx_7); __pyx_7 = 0; + __pyx_7 = PyList_New(7); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; goto __pyx_L1;} + Py_INCREF(__pyx_k78p); + PyList_SET_ITEM(__pyx_7, 0, __pyx_k78p); + PyList_SET_ITEM(__pyx_7, 1, __pyx_2); + PyList_SET_ITEM(__pyx_7, 2, __pyx_3); + PyList_SET_ITEM(__pyx_7, 3, __pyx_4); + PyList_SET_ITEM(__pyx_7, 4, __pyx_5); + PyList_SET_ITEM(__pyx_7, 5, __pyx_1); + PyList_SET_ITEM(__pyx_7, 6, __pyx_6); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_1 = 0; + __pyx_6 = 0; + Py_DECREF(__pyx_v_strg); + __pyx_v_strg = __pyx_7; + __pyx_7 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":514 */ + __pyx_2 = PyObject_GetAttr(__pyx_k85p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;} + Py_INCREF(__pyx_v_strg); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + Py_XDECREF(__pyx_7); + __Pyx_AddTraceback("_loess.loess_model.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_strg); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_outputs_13fitted_values___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_outputs_13fitted_values___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":530 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->fitted_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_outputs.fitted_values.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_outputs_16fitted_residuals___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_outputs_16fitted_residuals___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":538 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->fitted_residuals); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_outputs.fitted_residuals.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_outputs_12pseudovalues___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_outputs_12pseudovalues___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":547 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->pseudovalues); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_outputs.pseudovalues.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_outputs_8diagonal___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_outputs_8diagonal___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":555 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->diagonal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_outputs.diagonal.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_outputs_6robust___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_outputs_6robust___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":563 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->robust); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_outputs.robust.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_outputs_7divisor___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_outputs_7divisor___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":568 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->npar,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->divisor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_outputs.divisor.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_outputs_3enp___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_outputs_3enp___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":576 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_outputs.enp.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_outputs_1s___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_outputs_1s___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":584 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_outputs.s.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_outputs_9one_delta___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_outputs_9one_delta___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":592 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_outputs.one_delta.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_outputs_9two_delta___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_outputs_9two_delta___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":600 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->two_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_outputs.two_delta.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_13loess_outputs_9trace_hat___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_outputs_9trace_hat___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":608 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_outputs.trace_hat.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_fitted_values; +static PyObject *__pyx_n_fitted_residuals; +static PyObject *__pyx_n_enp; +static PyObject *__pyx_n_s; +static PyObject *__pyx_n_one_delta; +static PyObject *__pyx_n_two_delta; +static PyObject *__pyx_n_divisor; + +static PyObject *__pyx_k86p; +static PyObject *__pyx_k87p; +static PyObject *__pyx_k88p; +static PyObject *__pyx_k89p; +static PyObject *__pyx_k90p; +static PyObject *__pyx_k91p; +static PyObject *__pyx_k92p; +static PyObject *__pyx_k93p; + +static char (__pyx_k86[]) = "Outputs................"; +static char (__pyx_k87[]) = "Fitted values : %s\n"; +static char (__pyx_k88[]) = "Fitted residuals : %s\n"; +static char (__pyx_k89[]) = "Eqv. nb of parameters : %s"; +static char (__pyx_k90[]) = "Residual error : %s"; +static char (__pyx_k91[]) = "Deltas : %s - %s"; +static char (__pyx_k92[]) = "Normalization factors : %s"; +static char (__pyx_k93[]) = "\n"; + +static PyObject *__pyx_f_6_loess_13loess_outputs___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_13loess_outputs___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_strg; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + PyObject *__pyx_7 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_strg = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":611 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k87p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_residuals); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k88p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k89p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k90p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_two_delta); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; goto __pyx_L1;} + __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1); + PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6); + __pyx_1 = 0; + __pyx_6 = 0; + __pyx_1 = PyNumber_Remainder(__pyx_k91p, __pyx_7); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; goto __pyx_L1;} + Py_DECREF(__pyx_7); __pyx_7 = 0; + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_divisor); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; goto __pyx_L1;} + __pyx_7 = PyNumber_Remainder(__pyx_k92p, __pyx_6); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_6 = PyList_New(7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;} + Py_INCREF(__pyx_k86p); + PyList_SET_ITEM(__pyx_6, 0, __pyx_k86p); + PyList_SET_ITEM(__pyx_6, 1, __pyx_2); + PyList_SET_ITEM(__pyx_6, 2, __pyx_3); + PyList_SET_ITEM(__pyx_6, 3, __pyx_4); + PyList_SET_ITEM(__pyx_6, 4, __pyx_5); + PyList_SET_ITEM(__pyx_6, 5, __pyx_1); + PyList_SET_ITEM(__pyx_6, 6, __pyx_7); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_1 = 0; + __pyx_7 = 0; + Py_DECREF(__pyx_v_strg); + __pyx_v_strg = __pyx_6; + __pyx_6 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":618 */ + __pyx_2 = PyObject_GetAttr(__pyx_k93p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;} + Py_INCREF(__pyx_v_strg); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + Py_XDECREF(__pyx_7); + __Pyx_AddTraceback("_loess.loess_outputs.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_strg); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_14conf_intervals_setup(struct __pyx_obj_6_loess_conf_intervals *__pyx_v_self,conf_inv __pyx_v_base,long __pyx_v_nest) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":633 */ + __pyx_v_self->_base = __pyx_v_base; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":634 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_self->fit)); + __pyx_v_self->fit = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":635 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.upper); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_self->upper)); + __pyx_v_self->upper = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":636 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_self->lower)); + __pyx_v_self->lower = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.conf_intervals.setup"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_r_; +static PyObject *__pyx_n_T; + +static PyObject *__pyx_k94p; + +static char (__pyx_k94[]) = "Confidence intervals....\nLower b./ fit / upper b.\n%s"; + +static PyObject *__pyx_f_6_loess_14conf_intervals___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_14conf_intervals___str__(PyObject *__pyx_v_self) { + PyArrayObject *__pyx_v_tmp_ndr; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_tmp_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":640 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_r_); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyList_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_conf_intervals *)__pyx_v_self)->lower)); + PyList_SET_ITEM(__pyx_1, 0, ((PyObject *)((struct __pyx_obj_6_loess_conf_intervals *)__pyx_v_self)->lower)); + Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_conf_intervals *)__pyx_v_self)->fit)); + PyList_SET_ITEM(__pyx_1, 1, ((PyObject *)((struct __pyx_obj_6_loess_conf_intervals *)__pyx_v_self)->fit)); + Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_conf_intervals *)__pyx_v_self)->upper)); + PyList_SET_ITEM(__pyx_1, 2, ((PyObject *)((struct __pyx_obj_6_loess_conf_intervals *)__pyx_v_self)->upper)); + __pyx_3 = PyObject_GetItem(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_T); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_tmp_ndr)); + __pyx_v_tmp_ndr = ((PyArrayObject *)__pyx_2); + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":641 */ + __pyx_1 = PyNumber_Remainder(__pyx_k94p, ((PyObject *)__pyx_v_tmp_ndr)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_loess.conf_intervals.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_tmp_ndr); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static void __pyx_f_6_loess_15loess_predicted___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_f_6_loess_15loess_predicted___dealloc__(PyObject *__pyx_v_self) { + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":655 */ + pred_free_mem((&((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base)); + + Py_DECREF(__pyx_v_self); +} + +static PyObject *__pyx_f_6_loess_15loess_predicted_setup(struct __pyx_obj_6_loess_loess_predicted *__pyx_v_self,prediction __pyx_v_base,long __pyx_v_nest) { + PyObject *__pyx_r; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":658 */ + __pyx_v_self->_base = __pyx_v_base; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":659 */ + __pyx_v_self->nest = __pyx_v_nest; + + __pyx_r = Py_None; Py_INCREF(Py_None); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_15loess_predicted_6values___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_15loess_predicted_6values___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":693 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base.fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_predicted.values.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_15loess_predicted_6stderr___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_15loess_predicted_6stderr___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":702 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base.se_fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_predicted.stderr.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_15loess_predicted_14residual_scale___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_15loess_predicted_14residual_scale___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":710 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base.residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_predicted.residual_scale.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_15loess_predicted_2df___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_15loess_predicted_2df___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":719 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base.df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_predicted.df.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k95p; + +static char (__pyx_k95[]) = "The coverage precentage should be between 0 and 1!"; + +static PyObject *__pyx_f_6_loess_15loess_predicted_confidence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6_loess_15loess_predicted_confidence[] = "Returns the pointwise confidence intervals for each predicted values,\nat the given confidence interval coverage.\n \n:Parameters:\n coverage : float\n Confidence level of the confidence intervals limits, as a fraction.\n "; +static PyObject *__pyx_f_6_loess_15loess_predicted_confidence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_coverage = 0; + conf_inv __pyx_v__confintv; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + double __pyx_5; + static char *__pyx_argnames[] = {"coverage",0}; + __pyx_v_coverage = __pyx_k32; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_coverage)) return 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_coverage); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":730 */ + __pyx_1 = PyFloat_FromDouble(0.5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; goto __pyx_L1;} + __pyx_2 = __pyx_2 < 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":731 */ + __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;} + __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_v_coverage); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_v_coverage); + __pyx_v_coverage = __pyx_3; + __pyx_3 = 0; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":732 */ + __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} + __pyx_2 = __pyx_2 > 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":733 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} + Py_INCREF(__pyx_k95p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k95p); + __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":734 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_coverage); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; goto __pyx_L1;} + pointwise((&((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base),((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->nest,__pyx_5,(&__pyx_v__confintv)); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":735 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_conf_intervals), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6_loess_conf_intervals)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals)); + ((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals = ((struct __pyx_obj_6_loess_conf_intervals *)__pyx_3); + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":736 */ + __pyx_1 = ((struct __pyx_vtabstruct_6_loess_conf_intervals *)((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals->__pyx_vtab)->setup(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals,__pyx_v__confintv,((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":737 */ + Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals)); + __pyx_r = ((PyObject *)((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals); + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.loess_predicted.confidence"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_coverage); + return __pyx_r; +} + +static PyObject *__pyx_n_values; +static PyObject *__pyx_n_stderr; +static PyObject *__pyx_n_residual_scale; +static PyObject *__pyx_n_df; + +static PyObject *__pyx_k96p; +static PyObject *__pyx_k97p; +static PyObject *__pyx_k98p; +static PyObject *__pyx_k99p; +static PyObject *__pyx_k100p; +static PyObject *__pyx_k101p; + +static char (__pyx_k96[]) = "Outputs................"; +static char (__pyx_k97[]) = "Predicted values : %s\n"; +static char (__pyx_k98[]) = "Predicted std error : %s\n"; +static char (__pyx_k99[]) = "Residual scale : %s"; +static char (__pyx_k100[]) = "Degrees of freedom : %s"; +static char (__pyx_k101[]) = "\n"; + +static PyObject *__pyx_f_6_loess_15loess_predicted___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_6_loess_15loess_predicted___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_strg; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_strg = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":740 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k97p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_stderr); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k98p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k99p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k100p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyList_New(5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; goto __pyx_L1;} + Py_INCREF(__pyx_k96p); + PyList_SET_ITEM(__pyx_1, 0, __pyx_k96p); + PyList_SET_ITEM(__pyx_1, 1, __pyx_2); + PyList_SET_ITEM(__pyx_1, 2, __pyx_3); + PyList_SET_ITEM(__pyx_1, 3, __pyx_4); + PyList_SET_ITEM(__pyx_1, 4, __pyx_5); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + Py_DECREF(__pyx_v_strg); + __pyx_v_strg = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":747 */ + __pyx_2 = PyObject_GetAttr(__pyx_k101p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;} + Py_INCREF(__pyx_v_strg); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("_loess.loess_predicted.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_strg); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_order; +static PyObject *__pyx_n_C; +static PyObject *__pyx_n_len; +static PyObject *__pyx_n_iteritems; +static PyObject *__pyx_n_update; + +static PyObject *__pyx_k110p; + +static char (__pyx_k110[]) = "Incompatible size between the response array (%i) and the predictor array (%i)"; + +static int __pyx_f_6_loess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_6_loess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_x = 0; + PyObject *__pyx_v_y = 0; + PyObject *__pyx_v_weights = 0; + PyObject *__pyx_v_options = 0; + PyArrayObject *__pyx_v_x_ndr; + PyArrayObject *__pyx_v_y_ndr; + double (*__pyx_v_x_dat); + double (*__pyx_v_y_dat); + PyObject *__pyx_v_n; + PyObject *__pyx_v_p; + PyObject *__pyx_v_modelopt; + PyObject *__pyx_v_controlopt; + PyObject *__pyx_v_k; + PyObject *__pyx_v_v; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + long __pyx_5; + int __pyx_6; + long __pyx_7; + static char *__pyx_argnames[] = {"x","y","weights",0}; + __pyx_v_weights = __pyx_k33; + if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 3, 0, &__pyx_v_options) < 0) return -1; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_weights)) { + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + Py_XDECREF(__pyx_v_options); + return -1; + } + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_x); + Py_INCREF(__pyx_v_y); + Py_INCREF(__pyx_v_weights); + __pyx_v_x_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + __pyx_v_y_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + __pyx_v_n = Py_None; Py_INCREF(Py_None); + __pyx_v_p = Py_None; Py_INCREF(Py_None); + __pyx_v_modelopt = Py_None; Py_INCREF(Py_None); + __pyx_v_controlopt = Py_None; Py_INCREF(Py_None); + __pyx_v_k = Py_None; Py_INCREF(Py_None); + __pyx_v_v = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":769 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + Py_INCREF(__pyx_v_x); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_x_ndr)); + __pyx_v_x_ndr = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":770 */ + __pyx_v_x_dat = ((double (*))__pyx_v_x_ndr->data); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":771 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_v_x_ndr)); + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_x_ndr)); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_n); + __pyx_v_n = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":772 */ + __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_x_ndr), __pyx_n_size); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} + __pyx_1 = PyNumber_Divide(__pyx_4, __pyx_v_n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_v_p); + __pyx_v_p = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":773 */ + __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->npar = __pyx_5; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":774 */ + __pyx_5 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->nobs = __pyx_5; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":776 */ + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_p, __pyx_2, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;} + __pyx_6 = __pyx_6 > 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__pyx_6) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":777 */ + __pyx_3 = PyNumber_Multiply(__pyx_v_n, __pyx_v_p); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + if (PyObject_SetAttr(((PyObject *)__pyx_v_x_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":779 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + Py_INCREF(__pyx_v_y); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_y); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_y_ndr)); + __pyx_v_y_ndr = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":780 */ + __pyx_v_y_dat = ((double (*))__pyx_v_y_ndr->data); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":781 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_y_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_v_n, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;} + __pyx_6 = __pyx_6 != 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_6) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":782 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_v_y_ndr)); + PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_y_ndr)); + Py_INCREF(__pyx_v_n); + PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_n); + __pyx_4 = PyNumber_Remainder(__pyx_k110p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_4); + __pyx_4 = 0; + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":785 */ + __pyx_5 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;} + __pyx_7 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;} + loess_setup(__pyx_v_x_dat,__pyx_v_y_dat,__pyx_5,__pyx_7,(&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base)); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":787 */ + __pyx_4 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_inputs), 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_6_loess_loess_inputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs)); + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs = ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_4); + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":788 */ + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs->_base = (&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.inputs); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":790 */ + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_model), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6_loess_loess_model)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model)); + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model = ((struct __pyx_obj_6_loess_loess_model *)__pyx_2); + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":791 */ + __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;} + __pyx_1 = ((struct __pyx_vtabstruct_6_loess_loess_model *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model->__pyx_vtab)->setup(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model,(&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.model),__pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":795 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_control), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6_loess_loess_control)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->control)); + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->control = ((struct __pyx_obj_6_loess_loess_control *)__pyx_3); + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":796 */ + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->control->_base = (&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.control); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":798 */ + __pyx_4 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_kd_tree), 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_6_loess_loess_kd_tree)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->kd_tree)); + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->kd_tree = ((struct __pyx_obj_6_loess_loess_kd_tree *)__pyx_4); + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":799 */ + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->kd_tree->_base = (&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.kd_tree); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":801 */ + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_outputs), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6_loess_loess_outputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs)); + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs = ((struct __pyx_obj_6_loess_loess_outputs *)__pyx_2); + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":802 */ + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->_base = (&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.outputs); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":803 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;} + __pyx_6 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->activated = __pyx_6; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":804 */ + __pyx_7 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->nobs = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":805 */ + __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->npar = __pyx_5; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":807 */ + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;} + Py_DECREF(__pyx_v_modelopt); + __pyx_v_modelopt = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":808 */ + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} + Py_DECREF(__pyx_v_controlopt); + __pyx_v_controlopt = __pyx_4; + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":809 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_options, __pyx_n_iteritems); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = PyObject_GetIter(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + for (;;) { + __pyx_4 = PyIter_Next(__pyx_3); + if (!__pyx_4) { + if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + break; + } + __pyx_2 = PyObject_GetIter(__pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_1 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + Py_DECREF(__pyx_v_k); + __pyx_v_k = __pyx_1; + __pyx_1 = 0; + __pyx_4 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + Py_DECREF(__pyx_v_v); + __pyx_v_v = __pyx_4; + __pyx_4 = 0; + if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":810 */ + __pyx_1 = PyTuple_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;} + Py_INCREF(__pyx_n_family); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_family); + Py_INCREF(__pyx_n_span); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_span); + Py_INCREF(__pyx_n_degree); + PyTuple_SET_ITEM(__pyx_1, 2, __pyx_n_degree); + Py_INCREF(__pyx_n_normalize); + PyTuple_SET_ITEM(__pyx_1, 3, __pyx_n_normalize); + Py_INCREF(__pyx_n_parametric); + PyTuple_SET_ITEM(__pyx_1, 4, __pyx_n_parametric); + Py_INCREF(__pyx_n_drop_square); + PyTuple_SET_ITEM(__pyx_1, 5, __pyx_n_drop_square); + __pyx_6 = PySequence_Contains(__pyx_1, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_6) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":812 */ + if (PyObject_SetItem(__pyx_v_modelopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;} + goto __pyx_L6; + } + __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;} + Py_INCREF(__pyx_n_surface); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_surface); + Py_INCREF(__pyx_n_statistics); + PyTuple_SET_ITEM(__pyx_4, 1, __pyx_n_statistics); + Py_INCREF(__pyx_n_trace_hat); + PyTuple_SET_ITEM(__pyx_4, 2, __pyx_n_trace_hat); + Py_INCREF(__pyx_n_iterations); + PyTuple_SET_ITEM(__pyx_4, 3, __pyx_n_iterations); + Py_INCREF(__pyx_n_cell); + PyTuple_SET_ITEM(__pyx_4, 4, __pyx_n_cell); + __pyx_6 = PySequence_Contains(__pyx_4, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (__pyx_6) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":815 */ + if (PyObject_SetItem(__pyx_v_controlopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} + goto __pyx_L6; + } + __pyx_L6:; + } + Py_DECREF(__pyx_3); __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":816 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->control), __pyx_n_update); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_v_controlopt); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":817 */ + __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model), __pyx_n_update); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + __pyx_1 = PyEval_CallObjectWithKeywords(__pyx_3, __pyx_2, __pyx_v_modelopt); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.loess.__init__"); + __pyx_r = -1; + __pyx_L0:; + Py_XDECREF(__pyx_v_options); + Py_DECREF(__pyx_v_x_ndr); + Py_DECREF(__pyx_v_y_ndr); + Py_DECREF(__pyx_v_n); + Py_DECREF(__pyx_v_p); + Py_DECREF(__pyx_v_modelopt); + Py_DECREF(__pyx_v_controlopt); + Py_DECREF(__pyx_v_k); + Py_DECREF(__pyx_v_v); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_x); + Py_DECREF(__pyx_v_y); + Py_DECREF(__pyx_v_weights); + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + return __pyx_r; +} + +static PyObject *__pyx_f_6_loess_5loess_fit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6_loess_5loess_fit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + static char *__pyx_argnames[] = {0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":820 */ + loess_fit((&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base)); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":821 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;} + __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->activated = __pyx_2; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":822 */ + __pyx_2 = ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_status; + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":823 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + __pyx_3 = PyString_FromString(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":824 */ + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.loess.fit"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_nobs; + +static PyObject *__pyx_k122p; +static PyObject *__pyx_k123p; +static PyObject *__pyx_k125p; +static PyObject *__pyx_k126p; + +static char (__pyx_k122[]) = "Number of Observations : %d"; +static char (__pyx_k123[]) = "Equivalent Number of Parameters: %.1f"; +static char (__pyx_k125[]) = "Residual Standard Error : %.4f"; +static char (__pyx_k126[]) = "Residual Scale Estimate : %.4f"; + +static PyObject *__pyx_f_6_loess_5loess_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_6_loess_5loess_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + static char *__pyx_argnames[] = {0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":827 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs), __pyx_n_nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k122p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":828 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs), __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k123p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":829 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model), __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_n_gaussian, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; goto __pyx_L1;} + __pyx_3 = __pyx_3 == 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":830 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k125p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;} + goto __pyx_L2; + } + /*else*/ { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":832 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k126p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} + } + __pyx_L2:; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + __Pyx_AddTraceback("_loess.loess.summary"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_ravel; +static PyObject *__pyx_n_divmod; + +static PyObject *__pyx_k131p; +static PyObject *__pyx_k132p; + +static char (__pyx_k131[]) = "Can't predict without input data !"; +static char (__pyx_k132[]) = "Incompatible data size: there should be as many rows as parameters"; + +static PyObject *__pyx_f_6_loess_5loess_predict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6_loess_5loess_predict[] = "\n newdata: ndarray\n A (m,p) ndarray specifying the values of the predictors at which the \n evaluation is to be carried out.\n stderr: Boolean\n Logical flag for computing standard errors at newdata.\n "; +static PyObject *__pyx_f_6_loess_5loess_predict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_newdata = 0; + PyObject *__pyx_v_stderror = 0; + PyArrayObject *__pyx_v_p_ndr; + double (*__pyx_v_p_dat); + prediction __pyx_v__prediction; + int __pyx_v_m; + PyObject *__pyx_v_notOK; + PyObject *__pyx_r; + int __pyx_1; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + static char *__pyx_argnames[] = {"newdata","stderror",0}; + __pyx_v_stderror = __pyx_k34; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_newdata, &__pyx_v_stderror)) return 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_newdata); + Py_INCREF(__pyx_v_stderror); + __pyx_v_p_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + __pyx_v_notOK = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":847 */ + __pyx_1 = (((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->activated == 0); + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":848 */ + loess_fit((&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base)); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":849 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;} + __pyx_1 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->activated = __pyx_1; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":850 */ + __pyx_1 = ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_status; + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":851 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} + __pyx_3 = PyString_FromString(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":853 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + Py_INCREF(__pyx_v_newdata); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_newdata); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_ravel); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_p_ndr)); + __pyx_v_p_ndr = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":854 */ + __pyx_v_p_dat = ((double (*))__pyx_v_p_ndr->data); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":856 */ + __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; goto __pyx_L1;} + __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_3, __pyx_5, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; goto __pyx_L1;} + __pyx_1 = __pyx_1 == 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":857 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} + Py_INCREF(__pyx_k131p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k131p); + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} + goto __pyx_L4; + } + __pyx_L4:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":858 */ + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_divmod); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_v_p_ndr)); + PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_p_ndr)); + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->npar); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2); + __pyx_3 = 0; + __pyx_2 = 0; + __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_2 = PyObject_GetIter(__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_1 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_v_m = __pyx_1; + __pyx_4 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + Py_DECREF(__pyx_v_notOK); + __pyx_v_notOK = __pyx_4; + __pyx_4 = 0; + if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":859 */ + __pyx_1 = PyObject_IsTrue(__pyx_v_notOK); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":860 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} + Py_INCREF(__pyx_k132p); + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k132p); + __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":863 */ + __pyx_1 = PyInt_AsLong(__pyx_v_stderror); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; goto __pyx_L1;} + predict(__pyx_v_p_dat,__pyx_v_m,(&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base),(&__pyx_v__prediction),__pyx_1); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":864 */ + __pyx_1 = ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_status; + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":865 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} + __pyx_3 = PyString_FromString(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3); + __pyx_3 = 0; + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":866 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_predicted), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6_loess_loess_predicted)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->predicted)); + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->predicted = ((struct __pyx_obj_6_loess_loess_predicted *)__pyx_3); + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":867 */ + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->predicted->_base = __pyx_v__prediction; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":868 */ + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->predicted->nest = __pyx_v_m; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":870 */ + Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->predicted)); + __pyx_r = ((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->predicted); + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("_loess.loess.predict"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_p_ndr); + Py_DECREF(__pyx_v_notOK); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_newdata); + Py_DECREF(__pyx_v_stderror); + return __pyx_r; +} + +static void __pyx_f_6_loess_5loess___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_f_6_loess_5loess___dealloc__(PyObject *__pyx_v_self) { + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":873 */ + loess_free_mem((&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base)); + + Py_DECREF(__pyx_v_self); +} + +static PyObject *__pyx_n_isinstance; +static PyObject *__pyx_n_type; +static PyObject *__pyx_n_outputs; +static PyObject *__pyx_n_abs; + +static PyObject *__pyx_k133p; + +static char (__pyx_k133[]) = "Arguments should be valid loess objects!got '%s' instead"; + +static int __pyx_f_6_loess_5anova___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_6_loess_5anova___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_loess_one = 0; + PyObject *__pyx_v_loess_two = 0; + double __pyx_v_one_d1; + double __pyx_v_one_d2; + double __pyx_v_one_s; + double __pyx_v_two_d1; + double __pyx_v_two_d2; + double __pyx_v_two_s; + double __pyx_v_rssdiff; + double __pyx_v_d1diff; + double __pyx_v_tmp; + double __pyx_v_df1; + double __pyx_v_df2; + PyObject *__pyx_v_out_one; + PyObject *__pyx_v_out_two; + PyObject *__pyx_v_F_value; + int __pyx_r; + int __pyx_1; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + int __pyx_5; + PyObject *__pyx_6 = 0; + double __pyx_7; + static char *__pyx_argnames[] = {"loess_one","loess_two",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_loess_one, &__pyx_v_loess_two)) return -1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_loess_one); + Py_INCREF(__pyx_v_loess_two); + __pyx_v_out_one = Py_None; Py_INCREF(Py_None); + __pyx_v_out_two = Py_None; Py_INCREF(Py_None); + __pyx_v_F_value = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":887 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + Py_INCREF(__pyx_v_loess_one); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_loess_one); + Py_INCREF(((PyObject*)__pyx_ptype_6_loess_loess)); + PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_6_loess_loess)); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_1 = (!__pyx_5); + if (!__pyx_1) { + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + Py_INCREF(__pyx_v_loess_two); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_loess_two); + Py_INCREF(((PyObject*)__pyx_ptype_6_loess_loess)); + PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_6_loess_loess)); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_1 = (!__pyx_5); + } + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":888 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;} + Py_INCREF(__pyx_v_loess_one); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_loess_one); + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_3 = PyNumber_Remainder(__pyx_k133p, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_6, 0, 0); + Py_DECREF(__pyx_6); __pyx_6 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":891 */ + __pyx_3 = PyObject_GetAttr(__pyx_v_loess_one, __pyx_n_outputs); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;} + Py_DECREF(__pyx_v_out_one); + __pyx_v_out_one = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":892 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_loess_two, __pyx_n_outputs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; goto __pyx_L1;} + Py_DECREF(__pyx_v_out_two); + __pyx_v_out_two = __pyx_2; + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":894 */ + __pyx_4 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_one_delta); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_v_one_d1 = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":895 */ + __pyx_6 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_two_delta); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_v_one_d2 = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":896 */ + __pyx_3 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_s); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_v_one_s = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":898 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_one_delta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_v_two_d1 = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":899 */ + __pyx_4 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_two_delta); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_v_two_d2 = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":900 */ + __pyx_6 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_s); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_v_two_s = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":902 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + __pyx_2 = PyFloat_FromDouble((((__pyx_v_one_s * __pyx_v_one_s) * __pyx_v_one_d1) - ((__pyx_v_two_s * __pyx_v_two_s) * __pyx_v_two_d1))); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2); + __pyx_2 = 0; + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_v_rssdiff = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":903 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} + __pyx_3 = PyFloat_FromDouble((__pyx_v_one_d1 - __pyx_v_two_d1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_v_d1diff = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":904 */ + __pyx_3 = PyFloat_FromDouble((__pyx_v_d1diff * __pyx_v_d1diff)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + __pyx_4 = PyFloat_FromDouble((__pyx_v_one_d2 - __pyx_v_two_d2)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_6, 0, __pyx_4); + __pyx_4 = 0; + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_2 = PyNumber_Divide(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_7 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->dfn = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":905 */ + __pyx_v_df1 = ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->dfn; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":907 */ + __pyx_6 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_enp); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_enp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_6, __pyx_3, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;} + __pyx_5 = __pyx_5 > 0; + Py_DECREF(__pyx_6); __pyx_6 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__pyx_5) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":908 */ + ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->dfd = ((__pyx_v_one_d1 * __pyx_v_one_d1) / __pyx_v_one_d2); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":909 */ + __pyx_v_tmp = __pyx_v_one_s; + goto __pyx_L3; + } + /*else*/ { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":911 */ + ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->dfd = ((__pyx_v_two_d1 * __pyx_v_two_d1) / __pyx_v_two_d2); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":912 */ + __pyx_v_tmp = __pyx_v_two_s; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":913 */ + __pyx_v_df2 = ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->dfd; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":914 */ + __pyx_4 = PyFloat_FromDouble(((__pyx_v_rssdiff / __pyx_v_d1diff) / (__pyx_v_tmp * __pyx_v_tmp))); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; goto __pyx_L1;} + Py_DECREF(__pyx_v_F_value); + __pyx_v_F_value = __pyx_4; + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":916 */ + __pyx_2 = PyFloat_FromDouble(__pyx_v_df1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + __pyx_6 = PyNumber_Multiply(__pyx_v_F_value, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = PyFloat_FromDouble(__pyx_v_df2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + __pyx_4 = PyFloat_FromDouble(__pyx_v_df1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + __pyx_2 = PyNumber_Multiply(__pyx_v_F_value, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = PyNumber_Add(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = PyNumber_Divide(__pyx_6, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->Pr_F = (1. - ibeta(__pyx_7,(__pyx_v_df1 / 2),(__pyx_v_df2 / 2))); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":917 */ + __pyx_7 = PyFloat_AsDouble(__pyx_v_F_value); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->F_value = __pyx_7; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_6); + __Pyx_AddTraceback("_loess.anova.__init__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_out_one); + Py_DECREF(__pyx_v_out_two); + Py_DECREF(__pyx_v_F_value); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_loess_one); + Py_DECREF(__pyx_v_loess_two); + return __pyx_r; +} + +static __Pyx_InternTabEntry __pyx_intern_tab[] = { + {&__pyx_n_C, "C"}, + {&__pyx_n_False, "False"}, + {&__pyx_n_T, "T"}, + {&__pyx_n_True, "True"}, + {&__pyx_n_ValueError, "ValueError"}, + {&__pyx_n_abs, "abs"}, + {&__pyx_n_approximate, "approximate"}, + {&__pyx_n_array, "array"}, + {&__pyx_n_astype, "astype"}, + {&__pyx_n_atleast_1d, "atleast_1d"}, + {&__pyx_n_bool, "bool"}, + {&__pyx_n_c_loess, "c_loess"}, + {&__pyx_n_c_numpy, "c_numpy"}, + {&__pyx_n_c_python, "c_python"}, + {&__pyx_n_cell, "cell"}, + {&__pyx_n_copy, "copy"}, + {&__pyx_n_degree, "degree"}, + {&__pyx_n_df, "df"}, + {&__pyx_n_direct, "direct"}, + {&__pyx_n_divisor, "divisor"}, + {&__pyx_n_divmod, "divmod"}, + {&__pyx_n_drop_square, "drop_square"}, + {&__pyx_n_drop_square_flags, "drop_square_flags"}, + {&__pyx_n_dtype, "dtype"}, + {&__pyx_n_enp, "enp"}, + {&__pyx_n_exact, "exact"}, + {&__pyx_n_family, "family"}, + {&__pyx_n_fitted_residuals, "fitted_residuals"}, + {&__pyx_n_fitted_values, "fitted_values"}, + {&__pyx_n_gaussian, "gaussian"}, + {&__pyx_n_get, "get"}, + {&__pyx_n_id, "id"}, + {&__pyx_n_interpolate, "interpolate"}, + {&__pyx_n_isinstance, "isinstance"}, + {&__pyx_n_iterations, "iterations"}, + {&__pyx_n_iteritems, "iteritems"}, + {&__pyx_n_join, "join"}, + {&__pyx_n_len, "len"}, + {&__pyx_n_lower, "lower"}, + {&__pyx_n_min, "min"}, + {&__pyx_n_narray, "narray"}, + {&__pyx_n_ndim, "ndim"}, + {&__pyx_n_nobs, "nobs"}, + {&__pyx_n_normalize, "normalize"}, + {&__pyx_n_numpy, "numpy"}, + {&__pyx_n_one_delta, "one_delta"}, + {&__pyx_n_order, "order"}, + {&__pyx_n_outputs, "outputs"}, + {&__pyx_n_parametric, "parametric"}, + {&__pyx_n_parametric_flags, "parametric_flags"}, + {&__pyx_n_r_, "r_"}, + {&__pyx_n_ravel, "ravel"}, + {&__pyx_n_residual_scale, "residual_scale"}, + {&__pyx_n_s, "s"}, + {&__pyx_n_shape, "shape"}, + {&__pyx_n_size, "size"}, + {&__pyx_n_span, "span"}, + {&__pyx_n_statistics, "statistics"}, + {&__pyx_n_stderr, "stderr"}, + {&__pyx_n_subok, "subok"}, + {&__pyx_n_surface, "surface"}, + {&__pyx_n_symmetric, "symmetric"}, + {&__pyx_n_trace_hat, "trace_hat"}, + {&__pyx_n_two_delta, "two_delta"}, + {&__pyx_n_type, "type"}, + {&__pyx_n_update, "update"}, + {&__pyx_n_values, "values"}, + {0, 0} +}; + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_k35p, __pyx_k35, sizeof(__pyx_k35)}, + {&__pyx_k38p, __pyx_k38, sizeof(__pyx_k38)}, + {&__pyx_k39p, __pyx_k39, sizeof(__pyx_k39)}, + {&__pyx_k42p, __pyx_k42, sizeof(__pyx_k42)}, + {&__pyx_k45p, __pyx_k45, sizeof(__pyx_k45)}, + {&__pyx_k46p, __pyx_k46, sizeof(__pyx_k46)}, + {&__pyx_k47p, __pyx_k47, sizeof(__pyx_k47)}, + {&__pyx_k53p, __pyx_k53, sizeof(__pyx_k53)}, + {&__pyx_k54p, __pyx_k54, sizeof(__pyx_k54)}, + {&__pyx_k55p, __pyx_k55, sizeof(__pyx_k55)}, + {&__pyx_k56p, __pyx_k56, sizeof(__pyx_k56)}, + {&__pyx_k57p, __pyx_k57, sizeof(__pyx_k57)}, + {&__pyx_k58p, __pyx_k58, sizeof(__pyx_k58)}, + {&__pyx_k59p, __pyx_k59, sizeof(__pyx_k59)}, + {&__pyx_k60p, __pyx_k60, sizeof(__pyx_k60)}, + {&__pyx_k61p, __pyx_k61, sizeof(__pyx_k61)}, + {&__pyx_k64p, __pyx_k64, sizeof(__pyx_k64)}, + {&__pyx_k77p, __pyx_k77, sizeof(__pyx_k77)}, + {&__pyx_k78p, __pyx_k78, sizeof(__pyx_k78)}, + {&__pyx_k79p, __pyx_k79, sizeof(__pyx_k79)}, + {&__pyx_k80p, __pyx_k80, sizeof(__pyx_k80)}, + {&__pyx_k81p, __pyx_k81, sizeof(__pyx_k81)}, + {&__pyx_k82p, __pyx_k82, sizeof(__pyx_k82)}, + {&__pyx_k83p, __pyx_k83, sizeof(__pyx_k83)}, + {&__pyx_k84p, __pyx_k84, sizeof(__pyx_k84)}, + {&__pyx_k85p, __pyx_k85, sizeof(__pyx_k85)}, + {&__pyx_k86p, __pyx_k86, sizeof(__pyx_k86)}, + {&__pyx_k87p, __pyx_k87, sizeof(__pyx_k87)}, + {&__pyx_k88p, __pyx_k88, sizeof(__pyx_k88)}, + {&__pyx_k89p, __pyx_k89, sizeof(__pyx_k89)}, + {&__pyx_k90p, __pyx_k90, sizeof(__pyx_k90)}, + {&__pyx_k91p, __pyx_k91, sizeof(__pyx_k91)}, + {&__pyx_k92p, __pyx_k92, sizeof(__pyx_k92)}, + {&__pyx_k93p, __pyx_k93, sizeof(__pyx_k93)}, + {&__pyx_k94p, __pyx_k94, sizeof(__pyx_k94)}, + {&__pyx_k95p, __pyx_k95, sizeof(__pyx_k95)}, + {&__pyx_k96p, __pyx_k96, sizeof(__pyx_k96)}, + {&__pyx_k97p, __pyx_k97, sizeof(__pyx_k97)}, + {&__pyx_k98p, __pyx_k98, sizeof(__pyx_k98)}, + {&__pyx_k99p, __pyx_k99, sizeof(__pyx_k99)}, + {&__pyx_k100p, __pyx_k100, sizeof(__pyx_k100)}, + {&__pyx_k101p, __pyx_k101, sizeof(__pyx_k101)}, + {&__pyx_k110p, __pyx_k110, sizeof(__pyx_k110)}, + {&__pyx_k122p, __pyx_k122, sizeof(__pyx_k122)}, + {&__pyx_k123p, __pyx_k123, sizeof(__pyx_k123)}, + {&__pyx_k125p, __pyx_k125, sizeof(__pyx_k125)}, + {&__pyx_k126p, __pyx_k126, sizeof(__pyx_k126)}, + {&__pyx_k131p, __pyx_k131, sizeof(__pyx_k131)}, + {&__pyx_k132p, __pyx_k132, sizeof(__pyx_k132)}, + {&__pyx_k133p, __pyx_k133, sizeof(__pyx_k133)}, + {0, 0, 0} +}; + +static PyObject *__pyx_tp_new_6_loess_loess_inputs(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + return o; +} + +static void __pyx_tp_dealloc_6_loess_loess_inputs(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6_loess_loess_inputs(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_6_loess_loess_inputs(PyObject *o) { + return 0; +} + +static PyObject *__pyx_getprop_6_loess_12loess_inputs_x(PyObject *o, void *x) { + return __pyx_f_6_loess_12loess_inputs_1x___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_12loess_inputs_y(PyObject *o, void *x) { + return __pyx_f_6_loess_12loess_inputs_1y___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_12loess_inputs_weights(PyObject *o, void *x) { + return __pyx_f_6_loess_12loess_inputs_7weights___get__(o); +} + +static int __pyx_setprop_6_loess_12loess_inputs_weights(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6_loess_12loess_inputs_7weights___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6_loess_12loess_inputs_nobs(PyObject *o, void *x) { + return __pyx_f_6_loess_12loess_inputs_4nobs___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_12loess_inputs_npar(PyObject *o, void *x) { + return __pyx_f_6_loess_12loess_inputs_4npar___get__(o); +} + +static struct PyMethodDef __pyx_methods_6_loess_loess_inputs[] = { + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6_loess_loess_inputs[] = { + {"x", __pyx_getprop_6_loess_12loess_inputs_x, 0, 0, 0}, + {"y", __pyx_getprop_6_loess_12loess_inputs_y, 0, 0, 0}, + {"weights", __pyx_getprop_6_loess_12loess_inputs_weights, __pyx_setprop_6_loess_12loess_inputs_weights, __pyx_k1, 0}, + {"nobs", __pyx_getprop_6_loess_12loess_inputs_nobs, 0, __pyx_k2, 0}, + {"npar", __pyx_getprop_6_loess_12loess_inputs_npar, 0, __pyx_k3, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_inputs = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_inputs = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_inputs = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_inputs = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6_loess_loess_inputs = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_loess.loess_inputs", /*tp_name*/ + sizeof(struct __pyx_obj_6_loess_loess_inputs), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6_loess_loess_inputs, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_inputs, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_inputs, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_inputs, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_inputs, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6_loess_loess_inputs, /*tp_traverse*/ + __pyx_tp_clear_6_loess_loess_inputs, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6_loess_loess_inputs, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6_loess_loess_inputs, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6_loess_loess_inputs, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_6_loess_loess_control(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + return o; +} + +static void __pyx_tp_dealloc_6_loess_loess_control(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6_loess_loess_control(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_6_loess_loess_control(PyObject *o) { + return 0; +} + +static PyObject *__pyx_getprop_6_loess_13loess_control_surface(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_control_7surface___get__(o); +} + +static int __pyx_setprop_6_loess_13loess_control_surface(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6_loess_13loess_control_7surface___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6_loess_13loess_control_statistics(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_control_10statistics___get__(o); +} + +static int __pyx_setprop_6_loess_13loess_control_statistics(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6_loess_13loess_control_10statistics___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6_loess_13loess_control_trace_hat(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_control_9trace_hat___get__(o); +} + +static int __pyx_setprop_6_loess_13loess_control_trace_hat(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6_loess_13loess_control_9trace_hat___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6_loess_13loess_control_iterations(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_control_10iterations___get__(o); +} + +static int __pyx_setprop_6_loess_13loess_control_iterations(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6_loess_13loess_control_10iterations___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6_loess_13loess_control_cell(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_control_4cell___get__(o); +} + +static int __pyx_setprop_6_loess_13loess_control_cell(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6_loess_13loess_control_4cell___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static struct PyMethodDef __pyx_methods_6_loess_loess_control[] = { + {"update", (PyCFunction)__pyx_f_6_loess_13loess_control_update, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6_loess_13loess_control_update}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6_loess_loess_control[] = { + {"surface", __pyx_getprop_6_loess_13loess_control_surface, __pyx_setprop_6_loess_13loess_control_surface, __pyx_k4, 0}, + {"statistics", __pyx_getprop_6_loess_13loess_control_statistics, __pyx_setprop_6_loess_13loess_control_statistics, __pyx_k5, 0}, + {"trace_hat", __pyx_getprop_6_loess_13loess_control_trace_hat, __pyx_setprop_6_loess_13loess_control_trace_hat, __pyx_k6, 0}, + {"iterations", __pyx_getprop_6_loess_13loess_control_iterations, __pyx_setprop_6_loess_13loess_control_iterations, __pyx_k7, 0}, + {"cell", __pyx_getprop_6_loess_13loess_control_cell, __pyx_setprop_6_loess_13loess_control_cell, __pyx_k8, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_control = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_control = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_control = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_control = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6_loess_loess_control = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_loess.loess_control", /*tp_name*/ + sizeof(struct __pyx_obj_6_loess_loess_control), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6_loess_loess_control, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_control, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_control, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_control, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_f_6_loess_13loess_control___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_control, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6_loess_loess_control, /*tp_traverse*/ + __pyx_tp_clear_6_loess_loess_control, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6_loess_loess_control, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6_loess_loess_control, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6_loess_loess_control, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_6_loess_loess_kd_tree(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + return o; +} + +static void __pyx_tp_dealloc_6_loess_loess_kd_tree(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6_loess_loess_kd_tree(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_6_loess_loess_kd_tree(PyObject *o) { + return 0; +} + +static struct PyMethodDef __pyx_methods_6_loess_loess_kd_tree[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_kd_tree = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_kd_tree = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_kd_tree = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_kd_tree = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6_loess_loess_kd_tree = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_loess.loess_kd_tree", /*tp_name*/ + sizeof(struct __pyx_obj_6_loess_loess_kd_tree), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6_loess_loess_kd_tree, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_kd_tree, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_kd_tree, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_kd_tree, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_kd_tree, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6_loess_loess_kd_tree, /*tp_traverse*/ + __pyx_tp_clear_6_loess_loess_kd_tree, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6_loess_loess_kd_tree, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6_loess_loess_kd_tree, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; +static struct __pyx_vtabstruct_6_loess_loess_model __pyx_vtable_6_loess_loess_model; + +static PyObject *__pyx_tp_new_6_loess_loess_model(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_6_loess_loess_model *p = (struct __pyx_obj_6_loess_loess_model *)o; + *(struct __pyx_vtabstruct_6_loess_loess_model **)&p->__pyx_vtab = __pyx_vtabptr_6_loess_loess_model; + return o; +} + +static void __pyx_tp_dealloc_6_loess_loess_model(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6_loess_loess_model(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_6_loess_loess_model(PyObject *o) { + return 0; +} + +static PyObject *__pyx_getprop_6_loess_11loess_model_normalize(PyObject *o, void *x) { + return __pyx_f_6_loess_11loess_model_9normalize___get__(o); +} + +static int __pyx_setprop_6_loess_11loess_model_normalize(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6_loess_11loess_model_9normalize___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6_loess_11loess_model_span(PyObject *o, void *x) { + return __pyx_f_6_loess_11loess_model_4span___get__(o); +} + +static int __pyx_setprop_6_loess_11loess_model_span(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6_loess_11loess_model_4span___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6_loess_11loess_model_degree(PyObject *o, void *x) { + return __pyx_f_6_loess_11loess_model_6degree___get__(o); +} + +static int __pyx_setprop_6_loess_11loess_model_degree(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6_loess_11loess_model_6degree___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6_loess_11loess_model_family(PyObject *o, void *x) { + return __pyx_f_6_loess_11loess_model_6family___get__(o); +} + +static int __pyx_setprop_6_loess_11loess_model_family(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6_loess_11loess_model_6family___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6_loess_11loess_model_parametric_flags(PyObject *o, void *x) { + return __pyx_f_6_loess_11loess_model_16parametric_flags___get__(o); +} + +static int __pyx_setprop_6_loess_11loess_model_parametric_flags(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6_loess_11loess_model_16parametric_flags___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_6_loess_11loess_model_drop_square_flags(PyObject *o, void *x) { + return __pyx_f_6_loess_11loess_model_17drop_square_flags___get__(o); +} + +static int __pyx_setprop_6_loess_11loess_model_drop_square_flags(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_6_loess_11loess_model_17drop_square_flags___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static struct PyMethodDef __pyx_methods_6_loess_loess_model[] = { + {"update", (PyCFunction)__pyx_f_6_loess_11loess_model_update, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6_loess_loess_model[] = { + {"normalize", __pyx_getprop_6_loess_11loess_model_normalize, __pyx_setprop_6_loess_11loess_model_normalize, __pyx_k9, 0}, + {"span", __pyx_getprop_6_loess_11loess_model_span, __pyx_setprop_6_loess_11loess_model_span, __pyx_k10, 0}, + {"degree", __pyx_getprop_6_loess_11loess_model_degree, __pyx_setprop_6_loess_11loess_model_degree, __pyx_k11, 0}, + {"family", __pyx_getprop_6_loess_11loess_model_family, __pyx_setprop_6_loess_11loess_model_family, __pyx_k12, 0}, + {"parametric_flags", __pyx_getprop_6_loess_11loess_model_parametric_flags, __pyx_setprop_6_loess_11loess_model_parametric_flags, __pyx_k13, 0}, + {"drop_square_flags", __pyx_getprop_6_loess_11loess_model_drop_square_flags, __pyx_setprop_6_loess_11loess_model_drop_square_flags, __pyx_k14, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_model = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_model = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_model = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_model = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6_loess_loess_model = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_loess.loess_model", /*tp_name*/ + sizeof(struct __pyx_obj_6_loess_loess_model), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6_loess_loess_model, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + __pyx_f_6_loess_11loess_model___repr__, /*tp_repr*/ + &__pyx_tp_as_number_loess_model, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_model, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_model, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_f_6_loess_11loess_model___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_model, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6_loess_loess_model, /*tp_traverse*/ + __pyx_tp_clear_6_loess_loess_model, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6_loess_loess_model, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_6_loess_loess_model, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6_loess_loess_model, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_6_loess_loess_outputs(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + return o; +} + +static void __pyx_tp_dealloc_6_loess_loess_outputs(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6_loess_loess_outputs(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_6_loess_loess_outputs(PyObject *o) { + return 0; +} + +static PyObject *__pyx_getprop_6_loess_13loess_outputs_fitted_values(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_outputs_13fitted_values___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_13loess_outputs_fitted_residuals(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_outputs_16fitted_residuals___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_13loess_outputs_pseudovalues(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_outputs_12pseudovalues___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_13loess_outputs_diagonal(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_outputs_8diagonal___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_13loess_outputs_robust(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_outputs_6robust___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_13loess_outputs_divisor(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_outputs_7divisor___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_13loess_outputs_enp(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_outputs_3enp___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_13loess_outputs_s(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_outputs_1s___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_13loess_outputs_one_delta(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_outputs_9one_delta___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_13loess_outputs_two_delta(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_outputs_9two_delta___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_13loess_outputs_trace_hat(PyObject *o, void *x) { + return __pyx_f_6_loess_13loess_outputs_9trace_hat___get__(o); +} + +static struct PyMethodDef __pyx_methods_6_loess_loess_outputs[] = { + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_6_loess_loess_outputs[] = { + {"activated", T_INT, offsetof(struct __pyx_obj_6_loess_loess_outputs, activated), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6_loess_loess_outputs[] = { + {"fitted_values", __pyx_getprop_6_loess_13loess_outputs_fitted_values, 0, __pyx_k15, 0}, + {"fitted_residuals", __pyx_getprop_6_loess_13loess_outputs_fitted_residuals, 0, __pyx_k16, 0}, + {"pseudovalues", __pyx_getprop_6_loess_13loess_outputs_pseudovalues, 0, __pyx_k17, 0}, + {"diagonal", __pyx_getprop_6_loess_13loess_outputs_diagonal, 0, __pyx_k18, 0}, + {"robust", __pyx_getprop_6_loess_13loess_outputs_robust, 0, __pyx_k19, 0}, + {"divisor", __pyx_getprop_6_loess_13loess_outputs_divisor, 0, __pyx_k20, 0}, + {"enp", __pyx_getprop_6_loess_13loess_outputs_enp, 0, __pyx_k21, 0}, + {"s", __pyx_getprop_6_loess_13loess_outputs_s, 0, __pyx_k22, 0}, + {"one_delta", __pyx_getprop_6_loess_13loess_outputs_one_delta, 0, __pyx_k23, 0}, + {"two_delta", __pyx_getprop_6_loess_13loess_outputs_two_delta, 0, __pyx_k24, 0}, + {"trace_hat", __pyx_getprop_6_loess_13loess_outputs_trace_hat, 0, __pyx_k25, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_outputs = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_outputs = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_outputs = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_outputs = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6_loess_loess_outputs = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_loess.loess_outputs", /*tp_name*/ + sizeof(struct __pyx_obj_6_loess_loess_outputs), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6_loess_loess_outputs, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_outputs, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_outputs, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_outputs, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_f_6_loess_13loess_outputs___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_outputs, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6_loess_loess_outputs, /*tp_traverse*/ + __pyx_tp_clear_6_loess_loess_outputs, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6_loess_loess_outputs, /*tp_methods*/ + __pyx_members_6_loess_loess_outputs, /*tp_members*/ + __pyx_getsets_6_loess_loess_outputs, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6_loess_loess_outputs, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; +static struct __pyx_vtabstruct_6_loess_conf_intervals __pyx_vtable_6_loess_conf_intervals; + +static PyObject *__pyx_tp_new_6_loess_conf_intervals(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_6_loess_conf_intervals *p = (struct __pyx_obj_6_loess_conf_intervals *)o; + *(struct __pyx_vtabstruct_6_loess_conf_intervals **)&p->__pyx_vtab = __pyx_vtabptr_6_loess_conf_intervals; + p->lower = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->fit = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->upper = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6_loess_conf_intervals(PyObject *o) { + struct __pyx_obj_6_loess_conf_intervals *p = (struct __pyx_obj_6_loess_conf_intervals *)o; + Py_XDECREF(((PyObject *)p->lower)); + Py_XDECREF(((PyObject *)p->fit)); + Py_XDECREF(((PyObject *)p->upper)); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6_loess_conf_intervals(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6_loess_conf_intervals *p = (struct __pyx_obj_6_loess_conf_intervals *)o; + if (p->lower) { + e = (*v)(((PyObject*)p->lower), a); if (e) return e; + } + if (p->fit) { + e = (*v)(((PyObject*)p->fit), a); if (e) return e; + } + if (p->upper) { + e = (*v)(((PyObject*)p->upper), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6_loess_conf_intervals(PyObject *o) { + struct __pyx_obj_6_loess_conf_intervals *p = (struct __pyx_obj_6_loess_conf_intervals *)o; + Py_XDECREF(((PyObject *)p->lower)); + p->lower = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->fit)); + p->fit = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->upper)); + p->upper = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return 0; +} + +static struct PyMethodDef __pyx_methods_6_loess_conf_intervals[] = { + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_6_loess_conf_intervals[] = { + {"lower", T_OBJECT, offsetof(struct __pyx_obj_6_loess_conf_intervals, lower), READONLY, 0}, + {"fit", T_OBJECT, offsetof(struct __pyx_obj_6_loess_conf_intervals, fit), READONLY, 0}, + {"upper", T_OBJECT, offsetof(struct __pyx_obj_6_loess_conf_intervals, upper), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_conf_intervals = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_conf_intervals = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_conf_intervals = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_conf_intervals = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6_loess_conf_intervals = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_loess.conf_intervals", /*tp_name*/ + sizeof(struct __pyx_obj_6_loess_conf_intervals), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6_loess_conf_intervals, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_conf_intervals, /*tp_as_number*/ + &__pyx_tp_as_sequence_conf_intervals, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_conf_intervals, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_f_6_loess_14conf_intervals___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_conf_intervals, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6_loess_conf_intervals, /*tp_traverse*/ + __pyx_tp_clear_6_loess_conf_intervals, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6_loess_conf_intervals, /*tp_methods*/ + __pyx_members_6_loess_conf_intervals, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6_loess_conf_intervals, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; +static struct __pyx_vtabstruct_6_loess_loess_predicted __pyx_vtable_6_loess_loess_predicted; + +static PyObject *__pyx_tp_new_6_loess_loess_predicted(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_6_loess_loess_predicted *p = (struct __pyx_obj_6_loess_loess_predicted *)o; + *(struct __pyx_vtabstruct_6_loess_loess_predicted **)&p->__pyx_vtab = __pyx_vtabptr_6_loess_loess_predicted; + p->confidence_intervals = ((struct __pyx_obj_6_loess_conf_intervals *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6_loess_loess_predicted(PyObject *o) { + struct __pyx_obj_6_loess_loess_predicted *p = (struct __pyx_obj_6_loess_loess_predicted *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++o->ob_refcnt; + __pyx_f_6_loess_15loess_predicted___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --o->ob_refcnt; + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(((PyObject *)p->confidence_intervals)); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6_loess_loess_predicted(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6_loess_loess_predicted *p = (struct __pyx_obj_6_loess_loess_predicted *)o; + if (p->confidence_intervals) { + e = (*v)(((PyObject*)p->confidence_intervals), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6_loess_loess_predicted(PyObject *o) { + struct __pyx_obj_6_loess_loess_predicted *p = (struct __pyx_obj_6_loess_loess_predicted *)o; + Py_XDECREF(((PyObject *)p->confidence_intervals)); + p->confidence_intervals = ((struct __pyx_obj_6_loess_conf_intervals *)Py_None); Py_INCREF(Py_None); + return 0; +} + +static PyObject *__pyx_getprop_6_loess_15loess_predicted_values(PyObject *o, void *x) { + return __pyx_f_6_loess_15loess_predicted_6values___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_15loess_predicted_stderr(PyObject *o, void *x) { + return __pyx_f_6_loess_15loess_predicted_6stderr___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_15loess_predicted_residual_scale(PyObject *o, void *x) { + return __pyx_f_6_loess_15loess_predicted_14residual_scale___get__(o); +} + +static PyObject *__pyx_getprop_6_loess_15loess_predicted_df(PyObject *o, void *x) { + return __pyx_f_6_loess_15loess_predicted_2df___get__(o); +} + +static struct PyMethodDef __pyx_methods_6_loess_loess_predicted[] = { + {"confidence", (PyCFunction)__pyx_f_6_loess_15loess_predicted_confidence, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6_loess_15loess_predicted_confidence}, + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_6_loess_loess_predicted[] = { + {"nest", T_LONG, offsetof(struct __pyx_obj_6_loess_loess_predicted, nest), READONLY, 0}, + {"confidence_intervals", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess_predicted, confidence_intervals), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_6_loess_loess_predicted[] = { + {"values", __pyx_getprop_6_loess_15loess_predicted_values, 0, __pyx_k26, 0}, + {"stderr", __pyx_getprop_6_loess_15loess_predicted_stderr, 0, __pyx_k27, 0}, + {"residual_scale", __pyx_getprop_6_loess_15loess_predicted_residual_scale, 0, __pyx_k28, 0}, + {"df", __pyx_getprop_6_loess_15loess_predicted_df, 0, __pyx_k29, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_predicted = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_predicted = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_predicted = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_predicted = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6_loess_loess_predicted = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_loess.loess_predicted", /*tp_name*/ + sizeof(struct __pyx_obj_6_loess_loess_predicted), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6_loess_loess_predicted, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_predicted, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_predicted, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_predicted, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_f_6_loess_15loess_predicted___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_predicted, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6_loess_loess_predicted, /*tp_traverse*/ + __pyx_tp_clear_6_loess_loess_predicted, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6_loess_loess_predicted, /*tp_methods*/ + __pyx_members_6_loess_loess_predicted, /*tp_members*/ + __pyx_getsets_6_loess_loess_predicted, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6_loess_loess_predicted, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_6_loess_loess(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_6_loess_loess *p = (struct __pyx_obj_6_loess_loess *)o; + p->inputs = ((struct __pyx_obj_6_loess_loess_inputs *)Py_None); Py_INCREF(Py_None); + p->model = ((struct __pyx_obj_6_loess_loess_model *)Py_None); Py_INCREF(Py_None); + p->control = ((struct __pyx_obj_6_loess_loess_control *)Py_None); Py_INCREF(Py_None); + p->kd_tree = ((struct __pyx_obj_6_loess_loess_kd_tree *)Py_None); Py_INCREF(Py_None); + p->outputs = ((struct __pyx_obj_6_loess_loess_outputs *)Py_None); Py_INCREF(Py_None); + p->predicted = ((struct __pyx_obj_6_loess_loess_predicted *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_6_loess_loess(PyObject *o) { + struct __pyx_obj_6_loess_loess *p = (struct __pyx_obj_6_loess_loess *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++o->ob_refcnt; + __pyx_f_6_loess_5loess___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --o->ob_refcnt; + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(((PyObject *)p->inputs)); + Py_XDECREF(((PyObject *)p->model)); + Py_XDECREF(((PyObject *)p->control)); + Py_XDECREF(((PyObject *)p->kd_tree)); + Py_XDECREF(((PyObject *)p->outputs)); + Py_XDECREF(((PyObject *)p->predicted)); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6_loess_loess(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6_loess_loess *p = (struct __pyx_obj_6_loess_loess *)o; + if (p->inputs) { + e = (*v)(((PyObject*)p->inputs), a); if (e) return e; + } + if (p->model) { + e = (*v)(((PyObject*)p->model), a); if (e) return e; + } + if (p->control) { + e = (*v)(((PyObject*)p->control), a); if (e) return e; + } + if (p->kd_tree) { + e = (*v)(((PyObject*)p->kd_tree), a); if (e) return e; + } + if (p->outputs) { + e = (*v)(((PyObject*)p->outputs), a); if (e) return e; + } + if (p->predicted) { + e = (*v)(((PyObject*)p->predicted), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_6_loess_loess(PyObject *o) { + struct __pyx_obj_6_loess_loess *p = (struct __pyx_obj_6_loess_loess *)o; + Py_XDECREF(((PyObject *)p->inputs)); + p->inputs = ((struct __pyx_obj_6_loess_loess_inputs *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->model)); + p->model = ((struct __pyx_obj_6_loess_loess_model *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->control)); + p->control = ((struct __pyx_obj_6_loess_loess_control *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->kd_tree)); + p->kd_tree = ((struct __pyx_obj_6_loess_loess_kd_tree *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->outputs)); + p->outputs = ((struct __pyx_obj_6_loess_loess_outputs *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->predicted)); + p->predicted = ((struct __pyx_obj_6_loess_loess_predicted *)Py_None); Py_INCREF(Py_None); + return 0; +} + +static struct PyMethodDef __pyx_methods_6_loess_loess[] = { + {"fit", (PyCFunction)__pyx_f_6_loess_5loess_fit, METH_VARARGS|METH_KEYWORDS, 0}, + {"summary", (PyCFunction)__pyx_f_6_loess_5loess_summary, METH_VARARGS|METH_KEYWORDS, 0}, + {"predict", (PyCFunction)__pyx_f_6_loess_5loess_predict, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6_loess_5loess_predict}, + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_6_loess_loess[] = { + {"inputs", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess, inputs), READONLY, 0}, + {"model", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess, model), READONLY, 0}, + {"control", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess, control), READONLY, 0}, + {"kd_tree", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess, kd_tree), READONLY, 0}, + {"outputs", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess, outputs), READONLY, 0}, + {"predicted", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess, predicted), READONLY, 0}, + {"nobs", T_LONG, offsetof(struct __pyx_obj_6_loess_loess, nobs), 0, 0}, + {"npar", T_LONG, offsetof(struct __pyx_obj_6_loess_loess, npar), 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6_loess_loess = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_loess.loess", /*tp_name*/ + sizeof(struct __pyx_obj_6_loess_loess), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6_loess_loess, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6_loess_loess, /*tp_traverse*/ + __pyx_tp_clear_6_loess_loess, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6_loess_loess, /*tp_methods*/ + __pyx_members_6_loess_loess, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_f_6_loess_5loess___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6_loess_loess, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_6_loess_anova(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + return o; +} + +static void __pyx_tp_dealloc_6_loess_anova(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_6_loess_anova(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_6_loess_anova(PyObject *o) { + return 0; +} + +static struct PyMethodDef __pyx_methods_6_loess_anova[] = { + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_6_loess_anova[] = { + {"dfn", T_DOUBLE, offsetof(struct __pyx_obj_6_loess_anova, dfn), READONLY, 0}, + {"dfd", T_DOUBLE, offsetof(struct __pyx_obj_6_loess_anova, dfd), READONLY, 0}, + {"F_value", T_DOUBLE, offsetof(struct __pyx_obj_6_loess_anova, F_value), READONLY, 0}, + {"Pr_F", T_DOUBLE, offsetof(struct __pyx_obj_6_loess_anova, Pr_F), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_anova = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_anova = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_anova = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_anova = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_6_loess_anova = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_loess.anova", /*tp_name*/ + sizeof(struct __pyx_obj_6_loess_anova), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_6_loess_anova, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_anova, /*tp_as_number*/ + &__pyx_tp_as_sequence_anova, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_anova, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_anova, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_6_loess_anova, /*tp_traverse*/ + __pyx_tp_clear_6_loess_anova, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_6_loess_anova, /*tp_methods*/ + __pyx_members_6_loess_anova, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_f_6_loess_5anova___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_6_loess_anova, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static struct PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +static void __pyx_init_filenames(void); /*proto*/ + +PyMODINIT_FUNC init_loess(void); /*proto*/ +PyMODINIT_FUNC init_loess(void) { + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + __pyx_init_filenames(); + __pyx_m = Py_InitModule4("_loess", __pyx_methods, 0, 0, PYTHON_API_VERSION); + if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + __pyx_b = PyImport_AddModule("__builtin__"); + if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + if (PyType_Ready(&__pyx_type_6_loess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_inputs", (PyObject *)&__pyx_type_6_loess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;} + __pyx_ptype_6_loess_loess_inputs = &__pyx_type_6_loess_loess_inputs; + if (PyType_Ready(&__pyx_type_6_loess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_control", (PyObject *)&__pyx_type_6_loess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;} + __pyx_ptype_6_loess_loess_control = &__pyx_type_6_loess_loess_control; + if (PyType_Ready(&__pyx_type_6_loess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_kd_tree", (PyObject *)&__pyx_type_6_loess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; goto __pyx_L1;} + __pyx_ptype_6_loess_loess_kd_tree = &__pyx_type_6_loess_loess_kd_tree; + __pyx_vtabptr_6_loess_loess_model = &__pyx_vtable_6_loess_loess_model; + *(void(**)())&__pyx_vtable_6_loess_loess_model.setup = (void(*)())__pyx_f_6_loess_11loess_model_setup; + if (PyType_Ready(&__pyx_type_6_loess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_6_loess_loess_model.tp_dict, __pyx_vtabptr_6_loess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_model", (PyObject *)&__pyx_type_6_loess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} + __pyx_ptype_6_loess_loess_model = &__pyx_type_6_loess_loess_model; + if (PyType_Ready(&__pyx_type_6_loess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_outputs", (PyObject *)&__pyx_type_6_loess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;} + __pyx_ptype_6_loess_loess_outputs = &__pyx_type_6_loess_loess_outputs; + __pyx_vtabptr_6_loess_conf_intervals = &__pyx_vtable_6_loess_conf_intervals; + *(void(**)())&__pyx_vtable_6_loess_conf_intervals.setup = (void(*)())__pyx_f_6_loess_14conf_intervals_setup; + __pyx_type_6_loess_conf_intervals.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_6_loess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_6_loess_conf_intervals.tp_dict, __pyx_vtabptr_6_loess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "conf_intervals", (PyObject *)&__pyx_type_6_loess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; goto __pyx_L1;} + __pyx_ptype_6_loess_conf_intervals = &__pyx_type_6_loess_conf_intervals; + __pyx_vtabptr_6_loess_loess_predicted = &__pyx_vtable_6_loess_loess_predicted; + *(void(**)())&__pyx_vtable_6_loess_loess_predicted.setup = (void(*)())__pyx_f_6_loess_15loess_predicted_setup; + __pyx_type_6_loess_loess_predicted.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_6_loess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_6_loess_loess_predicted.tp_dict, __pyx_vtabptr_6_loess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_predicted", (PyObject *)&__pyx_type_6_loess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;} + __pyx_ptype_6_loess_loess_predicted = &__pyx_type_6_loess_loess_predicted; + __pyx_type_6_loess_loess.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_6_loess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess", (PyObject *)&__pyx_type_6_loess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; goto __pyx_L1;} + __pyx_ptype_6_loess_loess = &__pyx_type_6_loess_loess; + if (PyType_Ready(&__pyx_type_6_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "anova", (PyObject *)&__pyx_type_6_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; goto __pyx_L1;} + __pyx_ptype_6_loess_anova = &__pyx_type_6_loess_anova; + __pyx_ptype_7c_numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (!__pyx_ptype_7c_numpy_dtype) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; goto __pyx_L1;} + __pyx_ptype_7c_numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (!__pyx_ptype_7c_numpy_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 81; goto __pyx_L1;} + __pyx_ptype_7c_numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject)); if (!__pyx_ptype_7c_numpy_flatiter) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 90; goto __pyx_L1;} + __pyx_ptype_7c_numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject)); if (!__pyx_ptype_7c_numpy_broadcast) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":8 */ + __pyx_1 = __Pyx_Import(__pyx_n_numpy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_numpy, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":9 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (PyObject_SetAttr(__pyx_m, __pyx_n_narray, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":12 */ + import_array(); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":73 */ + __pyx_k31; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":721 */ + __pyx_1 = PyFloat_FromDouble(0.95); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;} + __pyx_k32 = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":763 */ + Py_INCREF(Py_None); + __pyx_k33 = Py_None; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":834 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; goto __pyx_L1;} + __pyx_k34 = __pyx_2; + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":883 */ + return; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + __Pyx_AddTraceback("_loess"); +} + +static char *__pyx_filenames[] = { + "_loess.pyx", + "c_numpy.pxd", +}; + +/* Runtime support code */ + +static void __pyx_init_filenames(void) { + __pyx_f = __pyx_filenames; +} + +static int __Pyx_GetStarArgs( + PyObject **args, + PyObject **kwds, + char *kwd_list[], + int nargs, + PyObject **args2, + PyObject **kwds2) +{ + PyObject *x = 0, *args1 = 0, *kwds1 = 0; + + if (args2) + *args2 = 0; + if (kwds2) + *kwds2 = 0; + + if (args2) { + args1 = PyTuple_GetSlice(*args, 0, nargs); + if (!args1) + goto bad; + *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_Size(*args)); + if (!*args2) + goto bad; + } + else { + args1 = *args; + Py_INCREF(args1); + } + + if (kwds2) { + if (*kwds) { + char **p; + kwds1 = PyDict_New(); + if (!kwds) + goto bad; + *kwds2 = PyDict_Copy(*kwds); + if (!*kwds2) + goto bad; + for (p = kwd_list; *p; p++) { + x = PyDict_GetItemString(*kwds, *p); + if (x) { + if (PyDict_SetItemString(kwds1, *p, x) < 0) + goto bad; + if (PyDict_DelItemString(*kwds2, *p) < 0) + goto bad; + } + } + } + else { + *kwds2 = PyDict_New(); + if (!*kwds2) + goto bad; + } + } + else { + kwds1 = *kwds; + Py_XINCREF(kwds1); + } + + *args = args1; + *kwds = kwds1; + return 0; +bad: + Py_XDECREF(args1); + Py_XDECREF(kwds1); + if (*args2) { + Py_XDECREF(*args2); + } + if (*kwds2) { + Py_XDECREF(*kwds2); + } + return -1; +} + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) { + PyObject *__import__ = 0; + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + __import__ = PyObject_GetAttrString(__pyx_b, "__import__"); + if (!__import__) + goto bad; + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + module = PyObject_CallFunction(__import__, "OOOO", + name, global_dict, empty_dict, list); +bad: + Py_XDECREF(empty_list); + Py_XDECREF(__import__); + Py_XDECREF(empty_dict); + return module; +} + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { + PyObject *result; + result = PyObject_GetAttr(dict, name); + if (!result) + PyErr_SetObject(PyExc_NameError, name); + return result; +} + +static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (obj == Py_None || PyObject_TypeCheck(obj, type)) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s", + obj->ob_type->tp_name, type->tp_name); + return 0; +} + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { + Py_XINCREF(type); + Py_XINCREF(value); + Py_XINCREF(tb); + /* First, check the traceback argument, replacing None with NULL. */ + if (tb == Py_None) { + Py_DECREF(tb); + tb = 0; + } + else if (tb != NULL && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + /* Next, replace a missing value with None */ + if (value == NULL) { + value = Py_None; + Py_INCREF(value); + } + /* Next, repeatedly, replace a tuple exception with its first item */ + while (PyTuple_Check(type) && PyTuple_Size(type) > 0) { + PyObject *tmp = type; + type = PyTuple_GET_ITEM(type, 0); + Py_INCREF(type); + Py_DECREF(tmp); + } + if (PyString_Check(type)) { + if (PyErr_Warn(PyExc_DeprecationWarning, + "raising a string exception is deprecated")) + goto raise_error; + } + else if (PyType_Check(type) || PyClass_Check(type)) + ; /*PyErr_NormalizeException(&type, &value, &tb);*/ + else { + /* Raising an instance. The value should be a dummy. */ + if (value != Py_None) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + /* Normalize to raise , */ + Py_DECREF(value); + value = type; + if (PyInstance_Check(type)) + type = (PyObject*) ((PyInstanceObject*)type)->in_class; + else + type = (PyObject*) type->ob_type; + Py_INCREF(type); + } + PyErr_Restore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} + +static void __Pyx_UnpackError(void) { + PyErr_SetString(PyExc_ValueError, "unpack sequence of wrong size"); +} + +static PyObject *__Pyx_UnpackItem(PyObject *iter) { + PyObject *item; + if (!(item = PyIter_Next(iter))) { + if (!PyErr_Occurred()) + __Pyx_UnpackError(); + } + return item; +} + +static int __Pyx_EndUnpack(PyObject *iter) { + PyObject *item; + if ((item = PyIter_Next(iter))) { + Py_DECREF(item); + __Pyx_UnpackError(); + return -1; + } + else if (!PyErr_Occurred()) + return 0; + else + return -1; +} + +static PyObject *__Pyx_GetStdout(void) { + PyObject *f = PySys_GetObject("stdout"); + if (!f) { + PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); + } + return f; +} + +static int __Pyx_PrintItem(PyObject *v) { + PyObject *f; + + if (!(f = __Pyx_GetStdout())) + return -1; + if (PyFile_SoftSpace(f, 1)) { + if (PyFile_WriteString(" ", f) < 0) + return -1; + } + if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) + return -1; + if (PyString_Check(v)) { + char *s = PyString_AsString(v); + int len = PyString_Size(v); + if (len > 0 && + isspace(Py_CHARMASK(s[len-1])) && + s[len-1] != ' ') + PyFile_SoftSpace(f, 0); + } + return 0; +} + +static int __Pyx_PrintNewline(void) { + PyObject *f; + + if (!(f = __Pyx_GetStdout())) + return -1; + if (PyFile_WriteString("\n", f) < 0) + return -1; + PyFile_SoftSpace(f, 0); + return 0; +} + +static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) { + while (t->p) { + *t->p = PyString_InternFromString(t->s); + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static int __Pyx_SetVtable(PyObject *dict, void *vtable) { + PyObject *pycobj = 0; + int result; + + pycobj = PyCObject_FromVoidPtr(vtable, 0); + if (!pycobj) + goto bad; + if (PyDict_SetItemString(dict, "__pyx_vtable__", pycobj) < 0) + goto bad; + result = 0; + goto done; + +bad: + result = -1; +done: + Py_XDECREF(pycobj); + return result; +} + +static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, + long size) +{ + PyObject *py_module_name = 0; + PyObject *py_class_name = 0; + PyObject *py_name_list = 0; + PyObject *py_module = 0; + PyObject *result = 0; + + py_module_name = PyString_FromString(module_name); + if (!py_module_name) + goto bad; + py_class_name = PyString_FromString(class_name); + if (!py_class_name) + goto bad; + py_name_list = PyList_New(1); + if (!py_name_list) + goto bad; + Py_INCREF(py_class_name); + if (PyList_SetItem(py_name_list, 0, py_class_name) < 0) + goto bad; + py_module = __Pyx_Import(py_module_name, py_name_list); + if (!py_module) + goto bad; + result = PyObject_GetAttr(py_module, py_class_name); + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%s.%s is not a type object", + module_name, class_name); + goto bad; + } + if (((PyTypeObject *)result)->tp_basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%s.%s does not appear to be the correct type object", + module_name, class_name); + goto bad; + } + goto done; +bad: + Py_XDECREF(result); + result = 0; +done: + Py_XDECREF(py_module_name); + Py_XDECREF(py_class_name); + Py_XDECREF(py_name_list); + return (PyTypeObject *)result; +} + +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" + +static void __Pyx_AddTraceback(char *funcname) { + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + PyObject *py_globals = 0; + PyObject *empty_tuple = 0; + PyObject *empty_string = 0; + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + + py_srcfile = PyString_FromString(__pyx_filename); + if (!py_srcfile) goto bad; + py_funcname = PyString_FromString(funcname); + if (!py_funcname) goto bad; + py_globals = PyModule_GetDict(__pyx_m); + if (!py_globals) goto bad; + empty_tuple = PyTuple_New(0); + if (!empty_tuple) goto bad; + empty_string = PyString_FromString(""); + if (!empty_string) goto bad; + py_code = PyCode_New( + 0, /*int argcount,*/ + 0, /*int nlocals,*/ + 0, /*int stacksize,*/ + 0, /*int flags,*/ + empty_string, /*PyObject *code,*/ + empty_tuple, /*PyObject *consts,*/ + empty_tuple, /*PyObject *names,*/ + empty_tuple, /*PyObject *varnames,*/ + empty_tuple, /*PyObject *freevars,*/ + empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + __pyx_lineno, /*int firstlineno,*/ + empty_string /*PyObject *lnotab*/ + ); + if (!py_code) goto bad; + py_frame = PyFrame_New( + PyThreadState_Get(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + py_globals, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = __pyx_lineno; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + Py_XDECREF(empty_tuple); + Py_XDECREF(empty_string); + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} Added: trunk/Lib/sandbox/pyloess/src/_loess.pyx =================================================================== --- trunk/Lib/sandbox/pyloess/src/_loess.pyx 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/_loess.pyx 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,919 @@ +# -*- Mode: Python -*- +cimport c_python +cimport c_numpy +from c_numpy cimport ndarray, npy_intp, \ + PyArray_SIZE, PyArray_EMPTY, PyArray_FROMANY, \ + NPY_INT, NPY_DOUBLE, NPY_OWNDATA, NPY_ALIGNED, NPY_FORTRAN, \ + PyArray_SimpleNewFromData +import numpy +narray = numpy.array + +# NumPy must be initialized +c_numpy.import_array() + +cimport c_loess + +cdef floatarray_from_data(int rows, int cols, double *data): + cdef ndarray a_ndr + cdef npy_intp size + size = rows*cols + a_ndr = PyArray_SimpleNewFromData(1, &size, NPY_DOUBLE, data) + if cols > 1: + a_ndr.shape = (rows, cols) + return a_ndr + +cdef boolarray_from_data(int rows, int cols, int *data): + cdef ndarray a_ndr + cdef npy_intp size + size = rows*cols + a_ndr = PyArray_SimpleNewFromData(1, &size, NPY_DOUBLE, data) + if cols > 1: + a_ndr.shape = (rows, cols) + return a_ndr.astype(numpy.bool) + +##cimport modelflags +##import modelflags +# +#cdef list_to_clist(object p_list): +# cdef int i, imax +# p_list = list(p_list) +# imax = min(8, len(p_list)) +# for i from 0 <= i < imax: +# c_list[i] = p_list[i] +# return c_list[0] +#cdef object clist_to_list(int c_list[8]): +# cdef int i, imax +# p_list = [False] * 8 +# imax = min(8, len(p_list)) +# for i from 0 <= i < imax: +# p_list[i] = c_list[i] +# return p_list +# +# +#class modelflags: +# def __init__(self): +# self.str_list = [False] * 8 +# self.c_list = list_to_clist(self.str_list) +# def __getitem__(self, idx): +# return self.str_list[idx] +# def __setitem__(self, idx, val): +# cdef int tmpval +# tmpval = val +# self.c_list[idx] = tmpval +# self.str_list[idx] = bool(val) +# def __str__(self): +# return str(self.str_list) +# +##class modelflags(c_modelflags): +## def __init__(self): +## c_modelflags.__init__(self) +## + + +""" +:Keywords: + x : ndarray + A (n,p) ndarray of independent variables, with n the number of observations + and p the number of variables. + y : ndarray + A (n,) ndarray of observations + weights : ndarray + A (n,) ndarray of weights to be given to individual observations in the + sum of squared residuals that forms the local fitting criterion. If not + None, the weights should be non negative. If the different observations + have non-equal variances, the weights should be inversely proportional + to the variances. + By default, an unweighted fit is carried out (all the weights are one). + surface : string ["interpolate"] + Determines whether the fitted surface is computed directly at all points + ("direct") or whether an interpolation method is used ("interpolate"). + The default ("interpolate") is what most users should use unless special + circumstances warrant. + statistics : string ["approximate"] + Determines whether the statistical quantities are computed exactly + ("exact") or approximately ("approximate"). "exact" should only be used + for testing the approximation in statistical development and is not meant + for routine usage because computation time can be horrendous. + trace_hat : string ["wait.to.decide"] + Determines how the trace of the hat matrix should be computed. The hat + matrix is used in the computation of the statistical quantities. + If "exact", an exact computation is done; this could be slow when the + number of observations n becomes large. If "wait.to.decide" is selected, + then a default is "exact" for n < 500 and "approximate" otherwise. + This option is only useful when the fitted surface is interpolated. If + surface is "exact", an exact computation is always done for the trace. + Setting trace_hat to "approximate" for large dataset will substantially + reduce the computation time. + iterations : integer + Number of iterations of the robust fitting method. If the family is + "gaussian", the number of iterations is set to 0. + cell : integer + Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span), + where n is the number of observations, and span the smoothing parameter. + Then, a cell is further divided if the number of observations within it + is greater than or equal to k. This option is only used if the surface + is interpolated. + span : float [0.75] + Smoothing factor, as a fraction of the number of points to take into + account. + degree : integer [2] + Overall degree of locally-fitted polynomial. 1 is locally-linear + fitting and 2 is locally-quadratic fitting. Degree should be 2 at most. + normalize : boolean [True] + Determines whether the independent variables should be normalized. + If True, the normalization is performed by setting the 10% trimmed + standard deviation to one. If False, no normalization is carried out. + This option is only useful for more than one variable. For spatial + coordinates predictors or variables with a common scale, it should be + set to False. + family : string ["gaussian"] + Determines the assumed distribution of the errors. The values are + "gaussian" or "symmetric". If "gaussian" is selected, the fit is + performed with least-squares. If "symmetric" is selected, the fit + is performed robustly by redescending M-estimators. + parametric_flags : sequence [ [False]*p ] + Indicates which independent variables should be conditionally-parametric + (if there are two or more independent variables). The argument should + be a sequence of booleans, with the same size as the number of independent + variables, specified in the order of the predictor group ordered in x. + drop_square : sequence [ [False]* p] + When there are two or more independent variables and when a 2nd order + polynomial is used, "drop_square_flags" specifies those numeric predictors + whose squares should be dropped from the set of fitting variables. + The method of specification is the same as for parametric. + +:Outputs: + fitted_values : ndarray + The (n,) ndarray of fitted values. + fitted_residuals : ndarray + The (n,) ndarray of fitted residuals (observations - fitted values). + enp : float + Equivalent number of parameters. + s : float + Estimate of the scale of residuals. + one_delta: float + Statistical parameter used in the computation of standard errors. + two_delta : float + Statistical parameter used in the computation of standard errors. + pseudovalues : ndarray + The (n,) ndarray of adjusted values of the response when robust estimation + is used. + trace_hat : float + Trace of the operator hat matrix. + diagonal : + Diagonal of the operator hat matrix. + robust : ndarray + The (n,) ndarray of robustness weights for robust fitting. + divisor : ndarray + The (p,) array of normalization divisors for numeric predictors. + + + newdata : ndarray + The (m,p) array of independent variables where the surface must be estimated. + values : ndarray + The (m,) ndarray of loess values evaluated at newdata + stderr : ndarray + The (m,) ndarray of the estimates of the standard error on the estimated + values. + residual_scale : float + Estimate of the scale of the residuals + df : integer + Degrees of freedom of the t-distribution used to compute pointwise + confidence intervals for the evaluated surface. + nest : integer + Number of new observations. + + +""" + + +#####--------------------------------------------------------------------------- +#---- ---- loess model --- +#####--------------------------------------------------------------------------- +cdef class loess_inputs: + cdef c_loess.c_loess_inputs *_base + #......... + property x: + def __get__(self): + return floatarray_from_data(self._base.n, self._base.p, self._base.x) + #......... + property y: + def __get__(self): + return floatarray_from_data(self._base.n, 1, self._base.y) + #......... + property weights: + """A (n,) ndarray of weights to be given to individual observations in the + sum of squared residuals that forms the local fitting criterion. If not + None, the weights should be non negative. If the different observations + have non-equal variances, the weights should be inversely proportional + to the variances. + By default, an unweighted fit is carried out (all the weights are one). + """ + def __get__(self): + return floatarray_from_data(self._base.n, 1, self._base.weights) + + def __set__(self, w): + cdef npy_intp *dims + cdef ndarray w_ndr + w_ndr = PyArray_FROMANY(w, NPY_DOUBLE, 1, 1, NPY_OWNDATA) + if w_ndr.ndim > 1 or w_ndr.size != self._base.n: + raise ValueError, "Invalid size of the 'weights' vector!" + self._base.weights = w_ndr.data + #......... + property nobs: + "Number of observations." + def __get__(self): + return self._base.n + #......... + property npar: + "Number of independent variables." + def __get__(self): + return self._base.p +# +######--------------------------------------------------------------------------- +##---- ---- loess control --- +######--------------------------------------------------------------------------- +cdef class loess_control: + cdef c_loess.c_loess_control *_base + #......... + property surface: + """ + surface : string ["interpolate"] + Determines whether the fitted surface is computed directly at all points + ("direct") or whether an interpolation method is used ("interpolate"). + The default ("interpolate") is what most users should use unless special + circumstances warrant. + """ + def __get__(self): + return self._base.surface + def __set__(self, surface): + if surface.lower() not in ('interpolate', 'direct'): + raise ValueError("Invalid value for the 'surface' argument: "+ + "should be in ('interpolate', 'direct').") + tmpx = surface.lower() + self._base.surface = tmpx + #......... + property statistics: + """ + statistics : string ["approximate"] + Determines whether the statistical quantities are computed exactly + ("exact") or approximately ("approximate"). "exact" should only be used + for testing the approximation in statistical development and is not meant + for routine usage because computation time can be horrendous. + """ + def __get__(self): + return self._base.statistics + def __set__(self, statistics): + if statistics.lower() not in ('approximate', 'exact'): + raise ValueError("Invalid value for the 'statistics' argument: "\ + "should be in ('approximate', 'exact').") + tmpx = statistics.lower() + self._base.statistics = tmpx + #......... + property trace_hat: + """ + trace_hat : string ["wait.to.decide"] + Determines how the trace of the hat matrix should be computed. The hat + matrix is used in the computation of the statistical quantities. + If "exact", an exact computation is done; this could be slow when the + number of observations n becomes large. If "wait.to.decide" is selected, + then a default is "exact" for n < 500 and "approximate" otherwise. + This option is only useful when the fitted surface is interpolated. If + surface is "exact", an exact computation is always done for the trace. + Setting trace_hat to "approximate" for large dataset will substantially + reduce the computation time. + """ + def __get__(self): + return self._base.trace_hat + def __set__(self, trace_hat): + if trace_hat.lower() not in ('approximate', 'exact'): + raise ValueError("Invalid value for the 'trace_hat' argument: "\ + "should be in ('approximate', 'exact').") + tmpx = trace_hat.lower() + self._base.trace_hat = tmpx + #......... + property iterations: + """ + iterations : integer + Number of iterations of the robust fitting method. If the family is + "gaussian", the number of iterations is set to 0. + """ + def __get__(self): + return self._base.iterations + def __set__(self, iterations): + if iterations < 0: + raise ValueError("Invalid number of iterations: should be positive") + self._base.iterations = iterations + #......... + property cell: + """ + cell : integer + Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span), + where n is the number of observations, and span the smoothing parameter. + Then, a cell is further divided if the number of observations within it + is greater than or equal to k. This option is only used if the surface + is interpolated. + """ + def __get__(self): + return self._base.cell + def __set__(self, cell): + if cell <= 0: + raise ValueError("Invalid value for the cell argument: should be positive") + self._base.cell = cell + #......... + def update(self, **cellargs): + """Updates several parameters at once.""" + surface = cellargs.get('surface', None) + if surface is not None: + self.surface = surface + # + statistics = cellargs.get('statistics', None) + if statistics is not None: + self.statistics = statistics + # + trace_hat = cellargs.get('trace_hat', None) + if trace_hat is not None: + self.trace_hat = trace_hat + # + iterations = cellargs.get('iterations', None) + if iterations is not None: + self.iterations = iterations + # + cell = cellargs.get('cell', None) + if cell is not None: + self.parametric_flags = cell + # + #......... + def __str__(self): + strg = ["Control :", + "Surface type : %s" % self.surface, + "Statistics : %s" % self.statistics, + "Trace estimation : %s" % self.trace_hat, + "Cell size : %s" % self.cell, + "Nb iterations : %s" % self.iterations,] + return '\n'.join(strg) + +# +######--------------------------------------------------------------------------- +##---- ---- loess kd_tree --- +######--------------------------------------------------------------------------- +cdef class loess_kd_tree: + cdef c_loess.c_loess_kd_tree *_base + +######--------------------------------------------------------------------------- +##---- ---- loess model --- +######--------------------------------------------------------------------------- +cdef class loess_model: + cdef c_loess.c_loess_model *_base + cdef long npar +# cdef public double span +# cdef public int degree +# cdef public char *family +# cdef public parametric_mflags, drop_square_mflags + #......... + cdef setup(self, c_loess.c_loess_model *base, long npar): + self._base = base + self.npar = npar +# self.parametric_flags = modelflags() +# self.parametric_flags.c_list[0] = base.parametric[0] +# self.drop_square_flags = modelflags() +# self.drop_square_flags.c_list[0] = base.drop_square[0] +# self.span = self._base.span +# self.degree = self._base.degree +# self.family = self._base.family +# self.parametric_flags = boolarray_from_data(self.npar, 1, self._base.parametric) +# self.drop_square_flags = boolarray_from_data(self.npar, 1, self._base.drop_square) + return self + #......... + property normalize: + """ + normalize : boolean [True] + Determines whether the independent variables should be normalized. + If True, the normalization is performed by setting the 10% trimmed + standard deviation to one. If False, no normalization is carried out. + This option is only useful for more than one variable. For spatial + coordinates predictors or variables with a common scale, it should be + set to False. + """ + def __get__(self): + return bool(self._base.normalize) + def __set__(self, normalize): + self._base.normalize = normalize + #......... + property span: + """Smoothing factor, as a fraction of the number of points to take into + account. By default, span=0.75.""" + def __get__(self): + return self._base.span + def __set__(self, span): + if span <= 0. or span > 1.: + raise ValueError("Span should be between 0 and 1!") + self._base.span = span + #......... + property degree: + """ + degree : integer [2] + Overall degree of locally-fitted polynomial. 1 is locally-linear + fitting and 2 is locally-quadratic fitting. Degree should be 2 at most. + """ + def __get__(self): + return self._base.degree + def __set__(self, degree): + if degree < 0 or degree > 2: + raise ValueError("Degree should be between 0 and 2!") + #......... + property family: + """ + family : string ["gaussian"] + Determines the assumed distribution of the errors. The values are + "gaussian" or "symmetric". If "gaussian" is selected, the fit is + performed with least-squares. If "symmetric" is selected, the fit + is performed robustly by redescending M-estimators. + """ + def __get__(self): + return self._base.family + def __set__(self, family): + if family.lower() not in ('symmetric', 'gaussian'): + raise ValueError("Invalid value for the 'family' argument: "\ + "should be in ('symmetric', 'gaussian').") + self._base.family = family + #......... + property parametric_flags: + """ + parametric_flags : sequence [ [False]*p ] + Indicates which independent variables should be conditionally-parametric + (if there are two or more independent variables). The argument should + be a sequence of booleans, with the same size as the number of independent + variables, specified in the order of the predictor group ordered in x. + """ + def __get__(self): + return boolarray_from_data(self.npar, 1, self._base.parametric) + def __set__(self, paramf): + cdef ndarray p_ndr + cdef int i + p_ndr = numpy.atleast_1d(narray(paramf, copy=False, subok=True, + dtype=numpy.bool)) + for i from 0 <= i < min(self.npar, p_ndr.size): + self._base.parametric[i] = p_ndr[i] + #......... + property drop_square_flags: + """ + drop_square : sequence [ [False]* p] + When there are two or more independent variables and when a 2nd order + polynomial is used, "drop_square_flags" specifies those numeric predictors + whose squares should be dropped from the set of fitting variables. + The method of specification is the same as for parametric. + """ + def __get__(self): + return boolarray_from_data(self.npar, 1, self._base.drop_square) + def __set__(self, drop_sq): + cdef ndarray d_ndr + cdef int i + d_ndr = numpy.atleast_1d(narray(drop_sq, copy=False, subok=True, + dtype=numpy.bool)) + for i from 0 <= i < min(self.npar, d_ndr.size): + self._base.drop_square[i] = d_ndr[i] + #........ + def update(self, **modelargs): + family = modelargs.get('family', None) + if family is not None: + self.family = family + # + span = modelargs.get('span', None) + if span is not None: + self.span = span + # + degree = modelargs.get('degree', None) + if degree is not None: + self.degree = degree + # + normalize = modelargs.get('normalize', None) + if normalize is not None: + self.normalize = normalize + # + parametric = modelargs.get('parametric', None) + if parametric is not None: + self.parametric_flags = parametric + # + drop_square = modelargs.get('drop_square', None) + if drop_square is not None: + self.drop_square_flags = drop_square + #......... + def __repr__(self): + return "loess model parameters @%s" % id(self) + #......... + def __str__(self): + strg = ["Model parameters.....", + "family : %s" % self.family, + "span : %s" % self.span, + "degree : %s" % self.degree, + "normalized : %s" % self.normalize, + "parametric : %s" % self.parametric_flags[:self.npar], + "drop_square : %s" % self.drop_square_flags[:self.npar] + ] + return '\n'.join(strg) + +#####--------------------------------------------------------------------------- +#---- ---- loess outputs --- +#####--------------------------------------------------------------------------- +cdef class loess_outputs: + cdef c_loess.c_loess_outputs *_base + cdef long nobs, npar + cdef readonly int activated + #........ + property fitted_values: + """ + fitted_values : ndarray + The (n,) ndarray of fitted values. + """ + def __get__(self): + return floatarray_from_data(self.nobs, 1, self._base.fitted_values) + #......... + property fitted_residuals: + """ + fitted_residuals : ndarray + The (n,) ndarray of fitted residuals (observations - fitted values). + """ + def __get__(self): + return floatarray_from_data(self.nobs, 1, self._base.fitted_residuals) + #......... + property pseudovalues: + """ + pseudovalues : ndarray + The (n,) ndarray of adjusted values of the response when robust estimation + is used. + """ + def __get__(self): + return floatarray_from_data(self.nobs, 1, self._base.pseudovalues) + #......... + property diagonal: + """ + diagonal : + Diagonal of the operator hat matrix. + """ + def __get__(self): + return floatarray_from_data(self.nobs, 1, self._base.diagonal) + #......... + property robust: + """ + robust : ndarray + The (n,) ndarray of robustness weights for robust fitting. + """ + def __get__(self): + return floatarray_from_data(self.nobs, 1, self._base.robust) + #......... + property divisor: + "Equivalent number of parameters." + def __get__(self): + return floatarray_from_data(self.npar, 1, self._base.divisor) + #......... + property enp: + """ + enp : float + Equivalent number of parameters. + """ + def __get__(self): + return self._base.enp + #......... + property s: + """ + s : float + Estimate of the scale of residuals. + """ + def __get__(self): + return self._base.s + #......... + property one_delta: + """ + one_delta: float + Statistical parameter used in the computation of standard errors. + """ + def __get__(self): + return self._base.one_delta + #......... + property two_delta: + """ + two_delta : float + Statistical parameter used in the computation of standard errors. + """ + def __get__(self): + return self._base.two_delta + #......... + property trace_hat: + """ + trace_hat : float + Trace of the operator hat matrix. + """ + def __get__(self): + return self._base.trace_hat + #......... + def __str__(self): + strg = ["Outputs................", + "Fitted values : %s\n" % self.fitted_values, + "Fitted residuals : %s\n" % self.fitted_residuals, + "Eqv. nb of parameters : %s" % self.enp, + "Residual error : %s" % self.s, + "Deltas : %s - %s" % (self.one_delta, self.two_delta), + "Normalization factors : %s" % self.divisor,] + return '\n'.join(strg) + + + +#####--------------------------------------------------------------------------- +#---- ---- loess confidence --- +#####--------------------------------------------------------------------------- +cdef class conf_intervals: + cdef c_loess.c_conf_inv _base + cdef readonly ndarray lower, fit, upper + #......... +# def __dealloc__(self): +# c_loess.pw_free_mem(self._base) + #......... + cdef setup(self, c_loess.c_conf_inv base, long nest): + self._base = base + self.fit = floatarray_from_data(nest, 1, base.fit) + self.upper = floatarray_from_data(nest, 1, base.upper) + self.lower = floatarray_from_data(nest, 1, base.lower) + #......... + def __str__(self): + cdef ndarray tmp_ndr + tmp_ndr = numpy.r_[[self.lower,self.fit,self.upper]].T + return "Confidence intervals....\nLower b./ fit / upper b.\n%s" % \ + tmp_ndr + +#####--------------------------------------------------------------------------- +#---- ---- loess predictions --- +#####--------------------------------------------------------------------------- +cdef class loess_predicted: + cdef c_loess.c_prediction _base + cdef readonly long nest + cdef readonly conf_intervals confidence_intervals +# cdef readonly ndarray values, stderr +# cdef readonly double residual_scale, df + #......... + def __dealloc__(self): + c_loess.pred_free_mem(&self._base) + #......... + cdef setup(self, c_loess.c_prediction base, long nest): + self._base = base + self.nest = nest +# cdef setup(self, c_loess.c_loess loess_base, object newdata, stderror): +# cdef ndarray p_ndr +# cdef double *p_dat +# cdef c_loess.c_prediction _prediction +# cdef int i, m +# # +# # Note : we need a copy as we may have to normalize +# p_ndr = narray(newdata, copy=True, subok=True, order='C').ravel() +# p_dat = p_ndr.data +# # Test the compatibility of sizes ....... +# if p_ndr.size == 0: +# raise ValueError("Can't predict without input data !") +# (m, notOK) = divmod(len(p_ndr), loess_base.inputs.p) +# if notOK: +# raise ValueError( +# "Incompatible data size: there should be as many rows as parameters") +# #..... +# c_loess.c_predict(p_dat, m, &loess_base, &_prediction, stderror) +# if loess_base.status.err_status: +# raise ValueError(loess_base.status.err_msg) +# self._base = _prediction +# self.nest = m +## self.values = floatarray_from_data(m, 1, _prediction.fit) +## self.stderr = floatarray_from_data(m, 1, _prediction.se_fit) +## self.residual_scale = _prediction.residual_scale +## self.df = _prediction.df + #......... + property values: + """ + values : ndarray + The (m,) ndarray of loess values evaluated at newdata + """ + def __get__(self): + return floatarray_from_data(self.nest, 1, self._base.fit) + #......... + property stderr: + """ + stderr : ndarray + The (m,) ndarray of the estimates of the standard error on the estimated + values. + """ + def __get__(self): + return floatarray_from_data(self.nest, 1, self._base.se_fit) + #......... + property residual_scale: + """ + residual_scale : float + Estimate of the scale of the residuals + """ + def __get__(self): + return self._base.residual_scale + #......... + property df: + """ + df : integer + Degrees of freedom of the t-distribution used to compute pointwise + confidence intervals for the evaluated surface. + """ + def __get__(self): + return self._base.df + #......... + def confidence(self, coverage=0.95): + """Returns the pointwise confidence intervals for each predicted values, +at the given confidence interval coverage. + +:Parameters: + coverage : float + Confidence level of the confidence intervals limits, as a fraction. + """ + cdef c_loess.c_conf_inv _confintv + if coverage < 0.5: + coverage = 1. - coverage + if coverage > 1. : + raise ValueError("The coverage precentage should be between 0 and 1!") + c_loess.c_pointwise(&self._base, self.nest, coverage, &_confintv) + self.confidence_intervals = conf_intervals() + self.confidence_intervals.setup(_confintv, self.nest) + return self.confidence_intervals + #......... + def __str__(self): + strg = ["Outputs................", + "Predicted values : %s\n" % self.values, + "Predicted std error : %s\n" % self.stderr, + "Residual scale : %s" % self.residual_scale, + "Degrees of freedom : %s" % self.df, +# "Confidence intervals : %s" % self.confidence, + ] + return '\n'.join(strg) + + +#####--------------------------------------------------------------------------- +#---- ---- loess base class --- +#####--------------------------------------------------------------------------- +cdef class loess: + cdef c_loess.c_loess _base + cdef readonly loess_inputs inputs + cdef readonly loess_model model + cdef readonly loess_control control + cdef readonly loess_kd_tree kd_tree + cdef readonly loess_outputs outputs + cdef readonly loess_predicted predicted + cdef public long nobs, npar + + def __init__(self, object x, object y, object weights=None, **options): + # + cdef ndarray x_ndr, y_ndr + cdef double *x_dat, *y_dat + cdef int i + # Get the predictor array + x_ndr = narray(x, copy=True, subok=True, order='C') + x_dat = x_ndr.data + n = len(x_ndr) + p = x_ndr.size / n + self.npar = p + self.nobs = n + # Ravel the predictor array ... + if p > 1: + x_ndr.shape = (n*p,) + # Get the response array ...... + y_ndr = narray(y, copy=False, subok=True, order='C') + y_dat = y_ndr.data + if y_ndr.size != n: + raise ValueError("Incompatible size between the response array (%i)"\ + " and the predictor array (%i)" % (y_ndr,n)) + # Initialization .............. + c_loess.loess_setup(x_dat, y_dat, n, p, &self._base) + # + self.inputs = loess_inputs() + self.inputs._base = &self._base.inputs + # + self.model = loess_model() + self.model.setup(&self._base.model, p) +# self.model._base = &self._base.model +# self.model.npar = p + # + self.control = loess_control() + self.control._base = &self._base.control + # + self.kd_tree = loess_kd_tree() + self.kd_tree._base = &self._base.kd_tree + # + self.outputs = loess_outputs() + self.outputs._base = &self._base.outputs + self.outputs.activated = False + self.outputs.nobs = n + self.outputs.npar = p + # Process options ............. + modelopt = {} + controlopt = {} + for (k,v) in options.iteritems(): + if k in ('family', 'span', 'degree', 'normalize', + 'parametric', 'drop_square',): + modelopt[k] = v + elif k in ('surface', 'statistics', 'trace_hat', + 'iterations', 'cell'): + controlopt[k] = v + self.control.update(**controlopt) + self.model.update(**modelopt) + #...................................................... + def fit(self): + c_loess.loess_fit(&self._base) + self.outputs.activated = True + if self._base.status.err_status: + raise ValueError(self._base.status.err_msg) + return + #...................................................... + def summary(self): + print "Number of Observations : %d" % self.inputs.nobs + print "Equivalent Number of Parameters: %.1f" % self.outputs.enp + if self.model.family == "gaussian": + print "Residual Standard Error : %.4f" % self.outputs.s + else: + print "Residual Scale Estimate : %.4f" % self.outputs.s + #...................................................... + def predict(self, newdata, stderror=False): + """ + newdata: ndarray + A (m,p) ndarray specifying the values of the predictors at which the + evaluation is to be carried out. + stderr: Boolean + Logical flag for computing standard errors at newdata. + """ + cdef ndarray p_ndr + cdef double *p_dat + cdef c_loess.c_prediction _prediction + cdef int i, m + # Make sure there's been a fit earlier ... + if self.outputs.activated == 0: + c_loess.loess_fit(&self._base) + self.outputs.activated = True + if self._base.status.err_status: + raise ValueError(self._base.status.err_msg) + # Note : we need a copy as we may have to normalize + p_ndr = narray(newdata, copy=True, subok=True, order='C').ravel() + p_dat = p_ndr.data + # Test the compatibility of sizes ....... + if p_ndr.size == 0: + raise ValueError("Can't predict without input data !") + (m, notOK) = divmod(len(p_ndr), self.npar) + if notOK: + raise ValueError( + "Incompatible data size: there should be as many rows as parameters") + #..... + c_loess.c_predict(p_dat, m, &self._base, &_prediction, stderror) + if self._base.status.err_status: + raise ValueError(self._base.status.err_msg) + self.predicted = loess_predicted() + self.predicted._base = _prediction + self.predicted.nest = m +# self.predicted.setup(_prediction, m) + return self.predicted + #......... + def __dealloc__(self): + c_loess.loess_free_mem(&self._base) + #...................................................... + + +#####--------------------------------------------------------------------------- +#---- ---- loess anova --- +#####--------------------------------------------------------------------------- +cdef class anova: + cdef readonly double dfn, dfd, F_value, Pr_F + # + def __init__(self, loess_one, loess_two): + cdef double one_d1, one_d2, one_s, two_d1, two_d2, two_s, rssdiff,\ + d1diff, tmp, df1, df2 + # + if not isinstance(loess_one, loess) or not isinstance(loess_two, loess): + raise ValueError("Arguments should be valid loess objects!"\ + "got '%s' instead" % type(loess_one)) + # + out_one = loess_one.outputs + out_two = loess_two.outputs + # + one_d1 = out_one.one_delta + one_d2 = out_one.two_delta + one_s = out_one.s + # + two_d1 = out_two.one_delta + two_d2 = out_two.two_delta + two_s = out_two.s + # + rssdiff = abs(one_s * one_s * one_d1 - two_s * two_s * two_d1) + d1diff = abs(one_d1 - two_d1) + self.dfn = d1diff * d1diff / abs(one_d2 - two_d2) + df1 = self.dfn + # + if out_one.enp > out_two.enp: + self.dfd = one_d1 * one_d1 / one_d2 + tmp = one_s + else: + self.dfd = two_d1 * two_d1 / two_d2 + tmp = two_s + df2 = self.dfd + F_value = (rssdiff / d1diff) / (tmp * tmp) + + self.Pr_F = 1. - c_loess.ibeta(F_value*df1/(df2+F_value*df1), df1/2, df2/2) + self.F_value = F_value + + \ No newline at end of file Added: trunk/Lib/sandbox/pyloess/src/c_loess.pxd =================================================================== --- trunk/Lib/sandbox/pyloess/src/c_loess.pxd 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/c_loess.pxd 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,75 @@ +# -*- Mode: Python -*- + +cdef extern from "loess.h": + ctypedef struct c_loess_errstatus "loess_errstatus": + int err_status + char *err_msg + ctypedef struct c_loess_inputs "loess_inputs": + long n + long p + double *y + double *x + double *weights + ctypedef struct c_loess_model "loess_model": + double span + int degree + int normalize + int parametric[8] + int drop_square[8] + char *family + ctypedef struct c_loess_control "loess_control": + char *surface + char *statistics + double cell + char *trace_hat + int iterations + ctypedef struct c_loess_kd_tree "loess_kd_tree": + pass + ctypedef struct c_loess_outputs "loess_outputs": + double *fitted_values + double *fitted_residuals + double enp + double s + double one_delta + double two_delta + double *pseudovalues + double trace_hat + double *diagonal + double *robust + double *divisor + ctypedef struct c_loess "loess": + c_loess_inputs inputs + c_loess_model model + c_loess_control control + c_loess_kd_tree kd_tree + c_loess_outputs outputs + c_loess_errstatus status + ctypedef struct c_prediction "prediction": + double *fit + double *se_fit + double residual_scale + double df +# ctypedef struct c_anova "anova_struct": +# double dfn +# double dfd +# double F_value +# double Pr_F + ctypedef struct c_conf_inv "conf_inv": + double *fit + double *upper + double *lower + +cdef extern from "cloess.h": + void loess_setup(double *x, double *y, long n, long p, c_loess *lo) + void loess_fit(c_loess *lo) + void loess_free_mem(c_loess *lo) + void loess_summary(c_loess *lo) + # + void c_predict "predict" (double *eval, int m, c_loess *lo, c_prediction *pre, int se) + void pred_free_mem(c_prediction *pre) + # + void c_pointwise "pointwise" (c_prediction *pre, int m, double coverage, c_conf_inv *ci) + double pf (double q, double df1, double df2) + double ibeta (double x, double a, double b) + void pw_free_mem (c_conf_inv *ci) + Added: trunk/Lib/sandbox/pyloess/src/c_numpy.pxd =================================================================== --- trunk/Lib/sandbox/pyloess/src/c_numpy.pxd 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/c_numpy.pxd 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,129 @@ +# :Author: Travis Oliphant + +cdef extern from "numpy/arrayobject.h": + + cdef enum NPY_TYPES: + NPY_BOOL + NPY_BYTE + NPY_UBYTE + NPY_SHORT + NPY_USHORT + NPY_INT + NPY_UINT + NPY_LONG + NPY_ULONG + NPY_LONGLONG + NPY_ULONGLONG + NPY_FLOAT + NPY_DOUBLE + NPY_LONGDOUBLE + NPY_CFLOAT + NPY_CDOUBLE + NPY_CLONGDOUBLE + NPY_OBJECT + NPY_STRING + NPY_UNICODE + NPY_VOID + NPY_NTYPES + NPY_NOTYPE + + cdef enum requirements: + NPY_CONTIGUOUS + NPY_FORTRAN + NPY_OWNDATA + NPY_FORCECAST + NPY_ENSURECOPY + NPY_ENSUREARRAY + NPY_ELEMENTSTRIDES + NPY_ALIGNED + NPY_NOTSWAPPED + NPY_WRITEABLE + NPY_UPDATEIFCOPY + NPY_ARR_HAS_DESCR + + NPY_BEHAVED + NPY_BEHAVED_NS + NPY_CARRAY + NPY_CARRAY_RO + NPY_FARRAY + NPY_FARRAY_RO + NPY_DEFAULT + + NPY_IN_ARRAY + NPY_OUT_ARRAY + NPY_INOUT_ARRAY + NPY_IN_FARRAY + NPY_OUT_FARRAY + NPY_INOUT_FARRAY + + NPY_UPDATE_ALL + + cdef enum defines: + # Note: as of Pyrex 0.9.5, enums are type-checked more strictly, so this + # can't be used as an integer. + NPY_MAXDIMS + + ctypedef struct npy_cdouble: + double real + double imag + + ctypedef struct npy_cfloat: + double real + double imag + + ctypedef int npy_intp + + ctypedef extern class numpy.dtype [object PyArray_Descr]: + cdef int type_num, elsize, alignment + cdef char type, kind, byteorder, hasobject + cdef object fields, typeobj + + ctypedef extern class numpy.ndarray [object PyArrayObject]: + cdef char *data + cdef int nd + cdef npy_intp *dimensions + cdef npy_intp *strides + cdef object base + cdef dtype descr + cdef int flags + + ctypedef extern class numpy.flatiter [object PyArrayIterObject]: + cdef int nd_m1 + cdef npy_intp index, size + cdef ndarray ao + cdef char *dataptr + + ctypedef extern class numpy.broadcast [object PyArrayMultiIterObject]: + cdef int numiter + cdef npy_intp size, index + cdef int nd + # These next two should be arrays of [NPY_MAXITER], but that is + # difficult to cleanly specify in Pyrex. Fortunately, it doesn't matter. + cdef npy_intp *dimensions + cdef void **iters + + object PyArray_ZEROS(int ndims, npy_intp* dims, NPY_TYPES type_num, int fortran) + object PyArray_EMPTY(int ndims, npy_intp* dims, NPY_TYPES type_num, int fortran) + dtype PyArray_DescrFromTypeNum(NPY_TYPES type_num) + object PyArray_SimpleNew(int ndims, npy_intp* dims, NPY_TYPES type_num) + int PyArray_Check(object obj) + object PyArray_ContiguousFromAny(object obj, NPY_TYPES type, + int mindim, int maxdim) + npy_intp PyArray_SIZE(ndarray arr) + npy_intp PyArray_NBYTES(ndarray arr) + void *PyArray_DATA(ndarray arr) + object PyArray_FromAny(object obj, dtype newtype, int mindim, int maxdim, + int requirements, object context) + object PyArray_FROMANY(object obj, NPY_TYPES type_num, int min, + int max, int requirements) + object PyArray_NewFromDescr(object subtype, dtype newtype, int nd, + npy_intp* dims, npy_intp* strides, void* data, + int flags, object parent) + + object PyArray_IterNew(object arr) + void PyArray_ITER_NEXT(flatiter it) + + + object PyArray_SimpleNewFromData(int ndims, npy_intp* dims, NPY_TYPES type_num, void* data) + + void import_array() Added: trunk/Lib/sandbox/pyloess/src/c_python.pxd =================================================================== --- trunk/Lib/sandbox/pyloess/src/c_python.pxd 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/c_python.pxd 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,22 @@ +# -*- Mode: Python -*- Not really, but close enough + +# Expose as much of the Python C API as we need here + +cdef extern from "stdlib.h": + ctypedef int size_t + +cdef extern from "Python.h": + ctypedef int Py_intptr_t + void* PyMem_Malloc(size_t) + void* PyMem_Realloc(void *p, size_t n) + void PyMem_Free(void *p) + char* PyString_AsString(object string) + object PyString_FromString(char *v) + object PyString_InternFromString(char *v) + int PyErr_CheckSignals() + object PyFloat_FromDouble(double v) + void Py_XINCREF(object o) + void Py_XDECREF(object o) + void Py_CLEAR(object o) # use instead of decref + + object PyList_New(int size) Added: trunk/Lib/sandbox/pyloess/src/cloess.h =================================================================== --- trunk/Lib/sandbox/pyloess/src/cloess.h 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/cloess.h 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,21 @@ +#include +#include + + +// from loess.c +void loess_setup(double *x, double *y, int n, int p, loess *lo); +char loess_fit(loess *lo); +void loess_free_mem(loess *lo); +void loess_summary(loess *lo); + +// from misc.c +void pointwise(prediction *pre, int m, double coverage, conf_inv *ci); +void pw_free_mem(conf_inv *ci); +double pf(double q, double df1, double df2); +double ibeta(double x, double a, double b); +//// +// from predict.c +void predict(double *eval, int m, loess *lo, prediction *pre, int se); +void pred_free_mem(prediction *pre); +// + Added: trunk/Lib/sandbox/pyloess/src/linpack_lite.f =================================================================== --- trunk/Lib/sandbox/pyloess/src/linpack_lite.f 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/linpack_lite.f 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,757 @@ + subroutine dqrsl(x,ldx,n,k,qraux,y,qy,qty,b,rsd,xb,job,info) + integer ldx,n,k,job,info + double precision x(ldx,1),qraux(1),y(1),qy(1),qty(1),b(1),rsd(1), + * xb(1) +c +c dqrsl applies the output of dqrdc to compute coordinate +c transformations, projections, and least squares solutions. +c for k .le. min(n,p), let xk be the matrix +c +c xk = (x(jpvt(1)),x(jpvt(2)), ... ,x(jpvt(k))) +c +c formed from columnns jpvt(1), ... ,jpvt(k) of the original +c n x p matrix x that was input to dqrdc (if no pivoting was +c done, xk consists of the first k columns of x in their +c original order). dqrdc produces a factored orthogonal matrix q +c and an upper triangular matrix r such that +c +c xk = q * (r) +c (0) +c +c this information is contained in coded form in the arrays +c x and qraux. +c +c on entry +c +c x double precision(ldx,p). +c x contains the output of dqrdc. +c +c ldx integer. +c ldx is the leading dimension of the array x. +c +c n integer. +c n is the number of rows of the matrix xk. it must +c have the same value as n in dqrdc. +c +c k integer. +c k is the number of columns of the matrix xk. k +c must nnot be greater than min(n,p), where p is the +c same as in the calling sequence to dqrdc. +c +c qraux double precision(p). +c qraux contains the auxiliary output from dqrdc. +c +c y double precision(n) +c y contains an n-vector that is to be manipulated +c by dqrsl. +c +c job integer. +c job specifies what is to be computed. job has +c the decimal expansion abcde, with the following +c meaning. +c +c if a.ne.0, compute qy. +c if b,c,d, or e .ne. 0, compute qty. +c if c.ne.0, compute b. +c if d.ne.0, compute rsd. +c if e.ne.0, compute xb. +c +c note that a request to compute b, rsd, or xb +c automatically triggers the computation of qty, for +c which an array must be provided in the calling +c sequence. +c +c on return +c +c qy double precision(n). +c qy conntains q*y, if its computation has been +c requested. +c +c qty double precision(n). +c qty contains trans(q)*y, if its computation has +c been requested. here trans(q) is the +c transpose of the matrix q. +c +c b double precision(k) +c b contains the solution of the least squares problem +c +c minimize norm2(y - xk*b), +c +c if its computation has been requested. (note that +c if pivoting was requested in dqrdc, the j-th +c component of b will be associated with column jpvt(j) +c of the original matrix x that was input into dqrdc.) +c +c rsd double precision(n). +c rsd contains the least squares residual y - xk*b, +c if its computation has been requested. rsd is +c also the orthogonal projection of y onto the +c orthogonal complement of the column space of xk. +c +c xb double precision(n). +c xb contains the least squares approximation xk*b, +c if its computation has been requested. xb is also +c the orthogonal projection of y onto the column space +c of x. +c +c info integer. +c info is zero unless the computation of b has +c been requested and r is exactly singular. in +c this case, info is the index of the first zero +c diagonal element of r and b is left unaltered. +c +c the parameters qy, qty, b, rsd, and xb are not referenced +c if their computation is not requested and in this case +c can be replaced by dummy variables in the calling program. +c to save storage, the user may in some cases use the same +c array for different parameters in the calling sequence. a +c frequently occuring example is when one wishes to compute +c any of b, rsd, or xb and does not need y or qty. in this +c case one may identify y, qty, and one of b, rsd, or xb, while +c providing separate arrays for anything else that is to be +c computed. thus the calling sequence +c +c call dqrsl(x,ldx,n,k,qraux,y,dum,y,b,y,dum,110,info) +c +c will result in the computation of b and rsd, with rsd +c overwriting y. more generally, each item in the following +c list contains groups of permissible identifications for +c a single callinng sequence. +c +c 1. (y,qty,b) (rsd) (xb) (qy) +c +c 2. (y,qty,rsd) (b) (xb) (qy) +c +c 3. (y,qty,xb) (b) (rsd) (qy) +c +c 4. (y,qy) (qty,b) (rsd) (xb) +c +c 5. (y,qy) (qty,rsd) (b) (xb) +c +c 6. (y,qy) (qty,xb) (b) (rsd) +c +c in any group the value returned in the array allocated to +c the group corresponds to the last member of the group. +c +c linpack. this version dated 08/14/78 . +c g.w. stewart, university of maryland, argonne national lab. +c +c dqrsl uses the following functions and subprograms. +c +c blas daxpy,dcopy,ddot +c fortran dabs,min0,mod +c +c internal variables +c + integer i,j,jj,ju,kp1 + double precision ddot,t,temp + logical cb,cqy,cqty,cr,cxb +c +c +c set info flag. +c + info = 0 +c +c determine what is to be computed. +c + cqy = job/10000 .ne. 0 + cqty = mod(job,10000) .ne. 0 + cb = mod(job,1000)/100 .ne. 0 + cr = mod(job,100)/10 .ne. 0 + cxb = mod(job,10) .ne. 0 + ju = min0(k,n-1) +c +c special action when n=1. +c + if (ju .ne. 0) go to 40 + if (cqy) qy(1) = y(1) + if (cqty) qty(1) = y(1) + if (cxb) xb(1) = y(1) + if (.not.cb) go to 30 + if (x(1,1) .ne. 0.0d0) go to 10 + info = 1 + go to 20 + 10 continue + b(1) = y(1)/x(1,1) + 20 continue + 30 continue + if (cr) rsd(1) = 0.0d0 + go to 250 + 40 continue +c +c set up to compute qy or qty. +c + if (cqy) call dcopy(n,y,1,qy,1) + if (cqty) call dcopy(n,y,1,qty,1) + if (.not.cqy) go to 70 +c +c compute qy. +c + do 60 jj = 1, ju + j = ju - jj + 1 + if (qraux(j) .eq. 0.0d0) go to 50 + temp = x(j,j) + x(j,j) = qraux(j) + t = -ddot(n-j+1,x(j,j),1,qy(j),1)/x(j,j) + call daxpy(n-j+1,t,x(j,j),1,qy(j),1) + x(j,j) = temp + 50 continue + 60 continue + 70 continue + if (.not.cqty) go to 100 +c +c compute trans(q)*y. +c + do 90 j = 1, ju + if (qraux(j) .eq. 0.0d0) go to 80 + temp = x(j,j) + x(j,j) = qraux(j) + t = -ddot(n-j+1,x(j,j),1,qty(j),1)/x(j,j) + call daxpy(n-j+1,t,x(j,j),1,qty(j),1) + x(j,j) = temp + 80 continue + 90 continue + 100 continue +c +c set up to compute b, rsd, or xb. +c + if (cb) call dcopy(k,qty,1,b,1) + kp1 = k + 1 + if (cxb) call dcopy(k,qty,1,xb,1) + if (cr .and. k .lt. n) call dcopy(n-k,qty(kp1),1,rsd(kp1),1) + if (.not.cxb .or. kp1 .gt. n) go to 120 + do 110 i = kp1, n + xb(i) = 0.0d0 + 110 continue + 120 continue + if (.not.cr) go to 140 + do 130 i = 1, k + rsd(i) = 0.0d0 + 130 continue + 140 continue + if (.not.cb) go to 190 +c +c compute b. +c + do 170 jj = 1, k + j = k - jj + 1 + if (x(j,j) .ne. 0.0d0) go to 150 + info = j +c ......exit + go to 180 + 150 continue + b(j) = b(j)/x(j,j) + if (j .eq. 1) go to 160 + t = -b(j) + call daxpy(j-1,t,x(1,j),1,b,1) + 160 continue + 170 continue + 180 continue + 190 continue + if (.not.cr .and. .not.cxb) go to 240 +c +c compute rsd or xb as required. +c + do 230 jj = 1, ju + j = ju - jj + 1 + if (qraux(j) .eq. 0.0d0) go to 220 + temp = x(j,j) + x(j,j) = qraux(j) + if (.not.cr) go to 200 + t = -ddot(n-j+1,x(j,j),1,rsd(j),1)/x(j,j) + call daxpy(n-j+1,t,x(j,j),1,rsd(j),1) + 200 continue + if (.not.cxb) go to 210 + t = -ddot(n-j+1,x(j,j),1,xb(j),1)/x(j,j) + call daxpy(n-j+1,t,x(j,j),1,xb(j),1) + 210 continue + x(j,j) = temp + 220 continue + 230 continue + 240 continue + 250 continue + return + end +c...................................................................... + subroutine dsvdc(x,ldx,n,p,s,e,u,ldu,v,ldv,work,job,info) + integer ldx,n,p,ldu,ldv,job,info + double precision x(ldx,1),s(1),e(1),u(ldu,1),v(ldv,1),work(1) +c +c +c dsvdc is a subroutine to reduce a double precision nxp matrix x +c by orthogonal transformations u and v to diagonal form. the +c diagonal elements s(i) are the singular values of x. the +c columns of u are the corresponding left singular vectors, +c and the columns of v the right singular vectors. +c +c on entry +c +c x double precision(ldx,p), where ldx.ge.n. +c x contains the matrix whose singular value +c decomposition is to be computed. x is +c destroyed by dsvdc. +c +c ldx integer. +c ldx is the leading dimension of the array x. +c +c n integer. +c n is the number of rows of the matrix x. +c +c p integer. +c p is the number of columns of the matrix x. +c +c ldu integer. +c ldu is the leading dimension of the array u. +c (see below). +c +c ldv integer. +c ldv is the leading dimension of the array v. +c (see below). +c +c work double precision(n). +c work is a scratch array. +c +c job integer. +c job controls the computation of the singular +c vectors. it has the decimal expansion ab +c with the following meaning +c +c a.eq.0 do not compute the left singular +c vectors. +c a.eq.1 return the n left singular vectors +c in u. +c a.ge.2 return the first min(n,p) singular +c vectors in u. +c b.eq.0 do not compute the right singular +c vectors. +c b.eq.1 return the right singular vectors +c in v. +c +c on return +c +c s double precision(mm), where mm=min(n+1,p). +c the first min(n,p) entries of s contain the +c singular values of x arranged in descending +c order of magnitude. +c +c e double precision(p), +c e ordinarily contains zeros. however see the +c discussion of info for exceptions. +c +c u double precision(ldu,k), where ldu.ge.n. if +c joba.eq.1 then k.eq.n, if joba.ge.2 +c then k.eq.min(n,p). +c u contains the matrix of left singular vectors. +c u is not referenced if joba.eq.0. if n.le.p +c or if joba.eq.2, then u may be identified with x +c in the subroutine call. +c +c v double precision(ldv,p), where ldv.ge.p. +c v contains the matrix of right singular vectors. +c v is not referenced if job.eq.0. if p.le.n, +c then v may be identified with x in the +c subroutine call. +c +c info integer. +c the singular values (and their corresponding +c singular vectors) s(info+1),s(info+2),...,s(m) +c are correct (here m=min(n,p)). thus if +c info.eq.0, all the singular values and their +c vectors are correct. in any event, the matrix +c b = trans(u)*x*v is the bidiagonal matrix +c with the elements of s on its diagonal and the +c elements of e on its super-diagonal (trans(u) +c is the transpose of u). thus the singular +c values of x and b are the same. +c +c linpack. this version dated 08/14/78 . +c correction made to shift 2/84. +c g.w. stewart, university of maryland, argonne national lab. +c +c dsvdc uses the following functions and subprograms. +c +c external drot +c blas daxpy,ddot,dscal,dswap,dnrm2,drotg +c fortran dabs,dmax1,max0,min0,mod,dsqrt +c +c internal variables +c + integer i,iter,j,jobu,k,kase,kk,l,ll,lls,lm1,lp1,ls,lu,m,maxit, + * mm,mm1,mp1,nct,nctp1,ncu,nrt,nrtp1 + double precision ddot,t,r + double precision b,c,cs,el,emm1,f,g,dnrm2,scale,shift,sl,sm,sn, + * smm1,t1,test,ztest + logical wantu,wantv +c +c +c set the maximum number of iterations. +c + maxit = 30 +c +c determine what is to be computed. +c + wantu = .false. + wantv = .false. + jobu = mod(job,100)/10 + ncu = n + if (jobu .gt. 1) ncu = min0(n,p) + if (jobu .ne. 0) wantu = .true. + if (mod(job,10) .ne. 0) wantv = .true. +c +c reduce x to bidiagonal form, storing the diagonal elements +c in s and the super-diagonal elements in e. +c + info = 0 + nct = min0(n-1,p) + nrt = max0(0,min0(p-2,n)) + lu = max0(nct,nrt) + if (lu .lt. 1) go to 170 + do 160 l = 1, lu + lp1 = l + 1 + if (l .gt. nct) go to 20 +c +c compute the transformation for the l-th column and +c place the l-th diagonal in s(l). +c + s(l) = dnrm2(n-l+1,x(l,l),1) + if (s(l) .eq. 0.0d0) go to 10 + if (x(l,l) .ne. 0.0d0) s(l) = dsign(s(l),x(l,l)) + call dscal(n-l+1,1.0d0/s(l),x(l,l),1) + x(l,l) = 1.0d0 + x(l,l) + 10 continue + s(l) = -s(l) + 20 continue + if (p .lt. lp1) go to 50 + do 40 j = lp1, p + if (l .gt. nct) go to 30 + if (s(l) .eq. 0.0d0) go to 30 +c +c apply the transformation. +c + t = -ddot(n-l+1,x(l,l),1,x(l,j),1)/x(l,l) + call daxpy(n-l+1,t,x(l,l),1,x(l,j),1) + 30 continue +c +c place the l-th row of x into e for the +c subsequent calculation of the row transformation. +c + e(j) = x(l,j) + 40 continue + 50 continue + if (.not.wantu .or. l .gt. nct) go to 70 +c +c place the transformation in u for subsequent back +c multiplication. +c + do 60 i = l, n + u(i,l) = x(i,l) + 60 continue + 70 continue + if (l .gt. nrt) go to 150 +c +c compute the l-th row transformation and place the +c l-th super-diagonal in e(l). +c + e(l) = dnrm2(p-l,e(lp1),1) + if (e(l) .eq. 0.0d0) go to 80 + if (e(lp1) .ne. 0.0d0) e(l) = dsign(e(l),e(lp1)) + call dscal(p-l,1.0d0/e(l),e(lp1),1) + e(lp1) = 1.0d0 + e(lp1) + 80 continue + e(l) = -e(l) + if (lp1 .gt. n .or. e(l) .eq. 0.0d0) go to 120 +c +c apply the transformation. +c + do 90 i = lp1, n + work(i) = 0.0d0 + 90 continue + do 100 j = lp1, p + call daxpy(n-l,e(j),x(lp1,j),1,work(lp1),1) + 100 continue + do 110 j = lp1, p + call daxpy(n-l,-e(j)/e(lp1),work(lp1),1,x(lp1,j),1) + 110 continue + 120 continue + if (.not.wantv) go to 140 +c +c place the transformation in v for subsequent +c back multiplication. +c + do 130 i = lp1, p + v(i,l) = e(i) + 130 continue + 140 continue + 150 continue + 160 continue + 170 continue +c +c set up the final bidiagonal matrix or order m. +c + m = min0(p,n+1) + nctp1 = nct + 1 + nrtp1 = nrt + 1 + if (nct .lt. p) s(nctp1) = x(nctp1,nctp1) + if (n .lt. m) s(m) = 0.0d0 + if (nrtp1 .lt. m) e(nrtp1) = x(nrtp1,m) + e(m) = 0.0d0 +c +c if required, generate u. +c + if (.not.wantu) go to 300 + if (ncu .lt. nctp1) go to 200 + do 190 j = nctp1, ncu + do 180 i = 1, n + u(i,j) = 0.0d0 + 180 continue + u(j,j) = 1.0d0 + 190 continue + 200 continue + if (nct .lt. 1) go to 290 + do 280 ll = 1, nct + l = nct - ll + 1 + if (s(l) .eq. 0.0d0) go to 250 + lp1 = l + 1 + if (ncu .lt. lp1) go to 220 + do 210 j = lp1, ncu + t = -ddot(n-l+1,u(l,l),1,u(l,j),1)/u(l,l) + call daxpy(n-l+1,t,u(l,l),1,u(l,j),1) + 210 continue + 220 continue + call dscal(n-l+1,-1.0d0,u(l,l),1) + u(l,l) = 1.0d0 + u(l,l) + lm1 = l - 1 + if (lm1 .lt. 1) go to 240 + do 230 i = 1, lm1 + u(i,l) = 0.0d0 + 230 continue + 240 continue + go to 270 + 250 continue + do 260 i = 1, n + u(i,l) = 0.0d0 + 260 continue + u(l,l) = 1.0d0 + 270 continue + 280 continue + 290 continue + 300 continue +c +c if it is required, generate v. +c + if (.not.wantv) go to 350 + do 340 ll = 1, p + l = p - ll + 1 + lp1 = l + 1 + if (l .gt. nrt) go to 320 + if (e(l) .eq. 0.0d0) go to 320 + do 310 j = lp1, p + t = -ddot(p-l,v(lp1,l),1,v(lp1,j),1)/v(lp1,l) + call daxpy(p-l,t,v(lp1,l),1,v(lp1,j),1) + 310 continue + 320 continue + do 330 i = 1, p + v(i,l) = 0.0d0 + 330 continue + v(l,l) = 1.0d0 + 340 continue + 350 continue +c +c main iteration loop for the singular values. +c + mm = m + iter = 0 + 360 continue +c +c quit if all the singular values have been found. +c +c ...exit + if (m .eq. 0) go to 620 +c +c if too many iterations have been performed, set +c flag and return. +c + if (iter .lt. maxit) go to 370 + info = m +c ......exit + go to 620 + 370 continue +c +c this section of the program inspects for +c negligible elements in the s and e arrays. on +c completion the variables kase and l are set as follows. +c +c kase = 1 if s(m) and e(l-1) are negligible and l.lt.m +c kase = 2 if s(l) is negligible and l.lt.m +c kase = 3 if e(l-1) is negligible, l.lt.m, and +c s(l), ..., s(m) are not negligible (qr step). +c kase = 4 if e(m-1) is negligible (convergence). +c + do 390 ll = 1, m + l = m - ll +c ...exit + if (l .eq. 0) go to 400 + test = dabs(s(l)) + dabs(s(l+1)) + ztest = test + dabs(e(l)) + if (ztest .ne. test) go to 380 + e(l) = 0.0d0 +c ......exit + go to 400 + 380 continue + 390 continue + 400 continue + if (l .ne. m - 1) go to 410 + kase = 4 + go to 480 + 410 continue + lp1 = l + 1 + mp1 = m + 1 + do 430 lls = lp1, mp1 + ls = m - lls + lp1 +c ...exit + if (ls .eq. l) go to 440 + test = 0.0d0 + if (ls .ne. m) test = test + dabs(e(ls)) + if (ls .ne. l + 1) test = test + dabs(e(ls-1)) + ztest = test + dabs(s(ls)) + if (ztest .ne. test) go to 420 + s(ls) = 0.0d0 +c ......exit + go to 440 + 420 continue + 430 continue + 440 continue + if (ls .ne. l) go to 450 + kase = 3 + go to 470 + 450 continue + if (ls .ne. m) go to 460 + kase = 1 + go to 470 + 460 continue + kase = 2 + l = ls + 470 continue + 480 continue + l = l + 1 +c +c perform the task indicated by kase. +c + go to (490,520,540,570), kase +c +c deflate negligible s(m). +c + 490 continue + mm1 = m - 1 + f = e(m-1) + e(m-1) = 0.0d0 + do 510 kk = l, mm1 + k = mm1 - kk + l + t1 = s(k) + call drotg(t1,f,cs,sn) + s(k) = t1 + if (k .eq. l) go to 500 + f = -sn*e(k-1) + e(k-1) = cs*e(k-1) + 500 continue + if (wantv) call drot(p,v(1,k),1,v(1,m),1,cs,sn) + 510 continue + go to 610 +c +c split at negligible s(l). +c + 520 continue + f = e(l-1) + e(l-1) = 0.0d0 + do 530 k = l, m + t1 = s(k) + call drotg(t1,f,cs,sn) + s(k) = t1 + f = -sn*e(k) + e(k) = cs*e(k) + if (wantu) call drot(n,u(1,k),1,u(1,l-1),1,cs,sn) + 530 continue + go to 610 +c +c perform one qr step. +c + 540 continue +c +c calculate the shift. +c + scale = dmax1(dabs(s(m)),dabs(s(m-1)),dabs(e(m-1)), + * dabs(s(l)),dabs(e(l))) + sm = s(m)/scale + smm1 = s(m-1)/scale + emm1 = e(m-1)/scale + sl = s(l)/scale + el = e(l)/scale + b = ((smm1 + sm)*(smm1 - sm) + emm1**2)/2.0d0 + c = (sm*emm1)**2 + shift = 0.0d0 + if (b .eq. 0.0d0 .and. c .eq. 0.0d0) go to 550 + shift = dsqrt(b**2+c) + if (b .lt. 0.0d0) shift = -shift + shift = c/(b + shift) + 550 continue + f = (sl + sm)*(sl - sm) + shift + g = sl*el +c +c chase zeros. +c + mm1 = m - 1 + do 560 k = l, mm1 + call drotg(f,g,cs,sn) + if (k .ne. l) e(k-1) = f + f = cs*s(k) + sn*e(k) + e(k) = cs*e(k) - sn*s(k) + g = sn*s(k+1) + s(k+1) = cs*s(k+1) + if (wantv) call drot(p,v(1,k),1,v(1,k+1),1,cs,sn) + call drotg(f,g,cs,sn) + s(k) = f + f = cs*e(k) + sn*s(k+1) + s(k+1) = -sn*e(k) + cs*s(k+1) + g = sn*e(k+1) + e(k+1) = cs*e(k+1) + if (wantu .and. k .lt. n) + * call drot(n,u(1,k),1,u(1,k+1),1,cs,sn) + 560 continue + e(m-1) = f + iter = iter + 1 + go to 610 +c +c convergence. +c + 570 continue +c +c make the singular value positive. +c + if (s(l) .ge. 0.0d0) go to 580 + s(l) = -s(l) + if (wantv) call dscal(p,-1.0d0,v(1,l),1) + 580 continue +c +c order the singular value. +c + 590 if (l .eq. mm) go to 600 +c ...exit + if (s(l) .ge. s(l+1)) go to 600 + t = s(l) + s(l) = s(l+1) + s(l+1) = t + if (wantv .and. l .lt. p) + * call dswap(p,v(1,l),1,v(1,l+1),1) + if (wantu .and. l .lt. n) + * call dswap(n,u(1,l),1,u(1,l+1),1) + l = l + 1 + go to 590 + 600 continue + iter = 0 + m = m - 1 + 610 continue + go to 360 + 620 continue + return + end + Added: trunk/Lib/sandbox/pyloess/src/loess.c =================================================================== --- trunk/Lib/sandbox/pyloess/src/loess.c 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/loess.c 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,350 @@ +#include "S.h" +#include "loess.h" +#include +#include +#include + + +static char *surf_stat; + +int error_status = 0; +char *error_message = NULL; + +void +loess_setup(double *x, double *y, long n, long p, loess *lo) +{ + int i, max_kd; + + max_kd = n > 200 ? n : 200; + + lo->inputs.y = (double *) malloc(n * sizeof(double)); + lo->inputs.x = (double *) malloc(n * p * sizeof(double)); + lo->inputs.weights = (double *) malloc(n * sizeof(double)); + for(i = 0; i < (n * p); i++) + lo->inputs.x[i] = x[i]; + for(i = 0; i < n; i++) { + lo->inputs.y[i] = y[i]; + lo->inputs.weights[i] = 1; + } + lo->inputs.n = n; + lo->inputs.p = p; + lo->model.span = 0.75; + lo->model.degree = 2; + lo->model.normalize = TRUE; + for(i = 0; i < 8; i++) + lo->model.parametric[i] = lo->model.drop_square[i] = FALSE; + lo->model.family = "gaussian"; + + lo->control.surface = "interpolate"; + lo->control.statistics = "approximate"; + lo->control.cell = 0.2; + lo->control.trace_hat = "wait.to.decide"; + lo->control.iterations = 4; + + lo->outputs.fitted_values = (double *) malloc(n * sizeof(double)); + lo->outputs.fitted_residuals = (double *) malloc(n * sizeof(double)); + lo->outputs.pseudovalues = (double *) malloc(n * sizeof(double)); + lo->outputs.diagonal = (double *) malloc(n * sizeof(double)); + lo->outputs.robust = (double *) malloc(n * sizeof(double)); + lo->outputs.divisor = (double *) malloc(p * sizeof(double)); + + lo->kd_tree.parameter = (long *) malloc(7 * sizeof(long)); + lo->kd_tree.a = (long *) malloc(max_kd * sizeof(long)); + lo->kd_tree.xi = (double *) malloc(max_kd * sizeof(double)); + lo->kd_tree.vert = (double *) malloc(p * 2 * sizeof(double)); + lo->kd_tree.vval = (double *) malloc((p + 1) * max_kd * sizeof(double)); +} + +void +loess_fit(loess *lo) +{ + int size_info[2], iterations; + void loess_(); + + size_info[0] = lo->inputs.p; + size_info[1] = lo->inputs.n; + + //Reset the default error status... + error_status = 0; + lo->status.err_status = 0; + lo->status.err_msg = NULL; + + iterations = (!strcmp(lo->model.family, "gaussian")) ? 0 : + lo->control.iterations; + if(!strcmp(lo->control.trace_hat, "wait.to.decide")) { + if(!strcmp(lo->control.surface, "interpolate")) + lo->control.trace_hat = (lo->inputs.n < 500) ? "exact" : "approximate"; + else + lo->control.trace_hat = "exact"; + } + loess_(lo->inputs.y, lo->inputs.x, size_info, lo->inputs.weights, + &lo->model.span, + &lo->model.degree, + lo->model.parametric, + lo->model.drop_square, + &lo->model.normalize, + &lo->control.statistics, + &lo->control.surface, + &lo->control.cell, + &lo->control.trace_hat, + &iterations, + lo->outputs.fitted_values, + lo->outputs.fitted_residuals, + &lo->outputs.enp, + &lo->outputs.s, + &lo->outputs.one_delta, + &lo->outputs.two_delta, + lo->outputs.pseudovalues, + &lo->outputs.trace_hat, + lo->outputs.diagonal, + lo->outputs.robust, + lo->outputs.divisor, + lo->kd_tree.parameter, + lo->kd_tree.a, + lo->kd_tree.xi, + lo->kd_tree.vert, + lo->kd_tree.vval); + + if(error_status){ + lo->status.err_status = error_status; + lo->status.err_msg = error_message; + } +} + +void +loess_(double *y, double *x_, int *size_info, double *weights, double *span, + int *degree, int *parametric, int *drop_square, int *normalize, + char **statistics, char **surface, double *cell, char **trace_hat_in, + int *iterations, double *fitted_values, double *fitted_residuals, + double *enp, double *s, double *one_delta, double *two_delta, + double *pseudovalues, double *trace_hat_out, double *diagonal, + double *robust, double *divisor, int *parameter, int *a, double *xi, + double *vert, double *vval) +{ + double *x, *x_tmp, new_cell, trL, delta1, delta2, sum_squares = 0, + *pseudo_resid, *temp, *xi_tmp, *vert_tmp, *vval_tmp, + *diag_tmp, trL_tmp = 0, d1_tmp = 0, d2_tmp = 0, sum, mean; + int i, j, k, p, N, D, sum_drop_sqr = 0, sum_parametric = 0, + setLf, nonparametric = 0, *order_parametric, + *order_drop_sqr, zero = 0, max_kd, *a_tmp, *param_tmp; + int cut, comp(); + char *new_stat, *mess; + void condition(); + + D = size_info[0]; + N = size_info[1]; + max_kd = (N > 200 ? N : 200); + *one_delta = *two_delta = *trace_hat_out = 0; + + x = (double *) malloc(D * N * sizeof(double)); + x_tmp = (double *) malloc(D * N * sizeof(double)); + temp = (double *) malloc(N * sizeof(double)); + a_tmp = (int *) malloc(max_kd * sizeof(int)); + xi_tmp = (double *) malloc(max_kd * sizeof(double)); + vert_tmp = (double *) malloc(D * 2 * sizeof(double)); + vval_tmp = (double *) malloc((D + 1) * max_kd * sizeof(double)); + diag_tmp = (double *) malloc(N * sizeof(double)); + param_tmp = (int *) malloc(N * sizeof(int)); + order_parametric = (int *) malloc(D * sizeof(int)); + order_drop_sqr = (int *) malloc(D * sizeof(int)); + if((*iterations) > 0) + pseudo_resid = (double *) malloc(N * sizeof(double)); + + new_cell = (*span) * (*cell); + for(i = 0; i < N; i++) + robust[i] = 1; + for(i = 0; i < (N * D); i++) + x_tmp[i] = x_[i]; + if((*normalize) && (D > 1)) { + cut = ceil(0.100000000000000000001 * N); + for(i = 0; i < D; i++) { + k = i * N; + for(j = 0; j < N; j++) + temp[j] = x_[k + j]; + qsort(temp, N, sizeof(double), comp); + sum = 0; + for(j = cut; j <= (N - cut - 1); j++) + sum = sum + temp[j]; + mean = sum / (N - 2 * cut); + sum = 0; + for(j = cut; j <= (N - cut - 1); j++) { + temp[j] = temp[j] - mean; + sum = sum + temp[j] * temp[j]; + } + divisor[i] = sqrt(sum / (N - 2 * cut - 1)); + for(j = 0; j < N; j++) { + p = k + j; + x_tmp[p] = x_[p] / divisor[i]; + } + } + } + else + for(i = 0; i < D; i++) divisor[i] = 1; + + j = D - 1; + for(i = 0; i < D; i++) { + sum_drop_sqr = sum_drop_sqr + drop_square[i]; + sum_parametric = sum_parametric + parametric[i]; + if(parametric[i]) + order_parametric[j--] = i; + else + order_parametric[nonparametric++] = i; + } + //Reorder the predictors w/ the non-parametric first + for(i = 0; i < D; i++) { + order_drop_sqr[i] = 2 - drop_square[order_parametric[i]]; + k = i * N; + p = order_parametric[i] * N; + for(j = 0; j < N; j++) + x[k + j] = x_tmp[p + j]; + } + + // Misc. checks ............................. + if((*degree) == 1 && sum_drop_sqr) { + error_status = 1; + error_message = "Specified the square of a factor predictor to be "\ + "dropped when degree = 1"; + return; + } + + if(D == 1 && sum_drop_sqr) { + error_status = 1; + error_message = "Specified the square of a predictor to be dropped "\ + "with only one numeric predictor"; + return; + } + + if(sum_parametric == D) { + error_status = 1; + error_message = "Specified parametric for all predictors"; + return; + } + + // Start the iterations ..................... + for(j = 0; j <= (*iterations); j++) { + new_stat = j ? "none" : *statistics; + for(i = 0; i < N; i++) + robust[i] = weights[i] * robust[i]; + condition(surface, new_stat, trace_hat_in); + setLf = !strcmp(surf_stat, "interpolate/exact"); + loess_raw(y, x, weights, robust, &D, &N, span, degree, + &nonparametric, order_drop_sqr, &sum_drop_sqr, + &new_cell, &surf_stat, fitted_values, parameter, a, + xi, vert, vval, diagonal, &trL, &delta1, &delta2, + &setLf); + if(j == 0) { + *trace_hat_out = trL; + *one_delta = delta1; + *two_delta = delta2; + } + for(i = 0; i < N; i++){ + fitted_residuals[i] = y[i] - fitted_values[i]; + }; + if(j < (*iterations)) + F77_SUB(lowesw)(fitted_residuals, &N, robust, temp); + } + if((*iterations) > 0) { + F77_SUB(lowesp)(&N, y, fitted_values, weights, robust, temp, + pseudovalues); + loess_raw(pseudovalues, x, weights, weights, &D, &N, span, + degree, &nonparametric, order_drop_sqr, &sum_drop_sqr, + &new_cell, &surf_stat, temp, param_tmp, a_tmp, xi_tmp, + vert_tmp, vval_tmp, diag_tmp, &trL_tmp, &d1_tmp, &d2_tmp, + &zero); + for(i = 0; i < N; i++) + pseudo_resid[i] = pseudovalues[i] - temp[i]; + } + if((*iterations) == 0) + for(i = 0; i < N; i++) + sum_squares = sum_squares + weights[i] * + fitted_residuals[i] * fitted_residuals[i]; + else + for(i = 0; i < N; i++) + sum_squares = sum_squares + weights[i] * + pseudo_resid[i] * pseudo_resid[i]; + *enp = (*one_delta) + 2 * (*trace_hat_out) - N; + *s = sqrt(sum_squares / (*one_delta)); + + //Clean the mess and leave .................. + free(x); + free(x_tmp); + free(temp); + free(xi_tmp); + free(vert_tmp); + free(vval_tmp); + free(diag_tmp); + free(a_tmp); + free(param_tmp); + free(order_parametric); + free(order_drop_sqr); + if((*iterations) > 0) + free(pseudo_resid); +} + +void +loess_free_mem(loess *lo) +{ + free(lo->inputs.x); + free(lo->inputs.y); + free(lo->inputs.weights); + free(lo->outputs.fitted_values); + free(lo->outputs.fitted_residuals); + free(lo->outputs.pseudovalues); + free(lo->outputs.diagonal); + free(lo->outputs.robust); + free(lo->outputs.divisor); + free(lo->kd_tree.parameter); + free(lo->kd_tree.a); + free(lo->kd_tree.xi); + free(lo->kd_tree.vert); + free(lo->kd_tree.vval); +} + +void +loess_summary(loess *lo) +{ + printf("Number of Observations : %d\n", lo->inputs.n); + printf("Equivalent Number of Parameters: %.1f\n", lo->outputs.enp); + if(!strcmp(lo->model.family, "gaussian")) + printf("Residual Standard Error : "); + else + printf("Residual Scale Estimate: "); + printf("%.4f\n", lo->outputs.s); +} + +void +condition(char **surface, char *new_stat, char **trace_hat_in) +{ + if(!strcmp(*surface, "interpolate")) { + if(!strcmp(new_stat, "none")) + surf_stat = "interpolate/none"; + else if(!strcmp(new_stat, "exact")) + surf_stat = "interpolate/exact"; + else if(!strcmp(new_stat, "approximate")) + { + if(!strcmp(*trace_hat_in, "approximate")) + surf_stat = "interpolate/2.approx"; + else if(!strcmp(*trace_hat_in, "exact")) + surf_stat = "interpolate/1.approx"; + } + } + else if(!strcmp(*surface, "direct")) { + if(!strcmp(new_stat, "none")) + surf_stat = "direct/none"; + else if(!strcmp(new_stat, "exact")) + surf_stat = "direct/exact"; + else if(!strcmp(new_stat, "approximate")) + surf_stat = "direct/approximate"; + } +} + +int +comp(double *d1, double *d2) +{ + if(*d1 < *d2) + return(-1); + else if(*d1 == *d2) + return(0); + else + return(1); +} Added: trunk/Lib/sandbox/pyloess/src/loess.h =================================================================== --- trunk/Lib/sandbox/pyloess/src/loess.h 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/loess.h 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,87 @@ +/* for the meaning of these fields, see struct.m */ +/* longs are used here so that the codes can be called from S */ + +#define TRUE 1 +#define FALSE 0 + +typedef struct { + int err_status; + char *err_msg; + } loess_errstatus; + +typedef struct { + long n; + long p; + double *y; + double *x; + double *weights; + } loess_inputs; + +typedef struct { + double span; + int degree; + int normalize; + int parametric[8]; + int drop_square[8]; + char *family; + } loess_model; + +typedef struct { + char *surface; + char *statistics; + double cell; + char *trace_hat; + int iterations; + } loess_control; + +typedef struct { + long *parameter; + long *a; + double *xi; + double *vert; + double *vval; + } loess_kd_tree; + +typedef struct { + double *fitted_values; + double *fitted_residuals; + double enp; + double s; + double one_delta; + double two_delta; + double *pseudovalues; + double trace_hat; + double *diagonal; + double *robust; + double *divisor; + } loess_outputs; + +typedef struct { + loess_inputs inputs; + loess_model model; + loess_control control; + loess_kd_tree kd_tree; + loess_outputs outputs; + loess_errstatus status; +} loess; + +typedef struct { + double *fit; + double *se_fit; + double residual_scale; + double df; + } prediction; + +typedef struct { + double dfn; + double dfd; + double F_value; + double Pr_F; + } anova_struct; + +typedef struct { + double *fit; + double *upper; + double *lower; + } conf_inv; + Added: trunk/Lib/sandbox/pyloess/src/loessc.c =================================================================== --- trunk/Lib/sandbox/pyloess/src/loessc.c 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/loessc.c 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,414 @@ +#include "S.h" +#include +#include +#include + +#define min(x,y) ((x) < (y) ? (x) : (y)) +#define max(x,y) ((x) > (y) ? (x) : (y)) +#define GAUSSIAN 1 +#define SYMMETRIC 0 + +static int *iv, liv, lv, tau; +static double *v; + +extern char *error_message; +extern int error_status; + +loess_raw(double *y, double *x, double *weights, double *robust, int *d, + int*n, double *span, int *degree, int *nonparametric, + int *drop_square, int *sum_drop_sqr, double *cell, char **surf_stat, + double *surface, long *parameter, long *a, double *xi, double *vert, + double *vval, double *diagonal, double *trL, double *one_delta, + double *two_delta, int *setLf) +{ + int zero = 0, one = 1, two = 2, nsing, i, k; + double *hat_matrix, *LL; + + *trL = 0; + loess_workspace(d, n, span, degree, nonparametric, drop_square, + sum_drop_sqr, setLf); + v[1] = *cell; + if(!strcmp(*surf_stat, "interpolate/none")) { + F77_SUB(lowesb)(x, y, robust, &zero, &zero, iv, &liv, &lv, v); + F77_SUB(lowese)(iv, &liv, &lv, v, n, x, surface); + loess_prune(parameter, a, xi, vert, vval); + } + else if (!strcmp(*surf_stat, "direct/none")) { + F77_SUB(lowesf)(x, y, robust, iv, &liv, &lv, v, n, x, + &zero, &zero, surface); + } + else if (!strcmp(*surf_stat, "interpolate/1.approx")) { + F77_SUB(lowesb)(x, y, weights, diagonal, &one, iv, &liv, &lv, v); + F77_SUB(lowese)(iv, &liv, &lv, v, n, x, surface); + nsing = iv[29]; + for(i = 0; i < (*n); i++) *trL = *trL + diagonal[i]; + F77_SUB(lowesa)(trL, n, d, &tau, &nsing, one_delta, two_delta); + loess_prune(parameter, a, xi, vert, vval); + } + else if (!strcmp(*surf_stat, "interpolate/2.approx")) { + F77_SUB(lowesb)(x, y, robust, &zero, &zero, iv, &liv, &lv, v); + F77_SUB(lowese)(iv, &liv, &lv, v, n, x, surface); + nsing = iv[29]; + F77_SUB(ehg196)(&tau, d, span, trL); + F77_SUB(lowesa)(trL, n, d, &tau, &nsing, one_delta, two_delta); + loess_prune(parameter, a, xi, vert, vval); + } + else if (!strcmp(*surf_stat, "direct/approximate")) { + F77_SUB(lowesf)(x, y, weights, iv, &liv, &lv, v, n, x, + diagonal, &one, surface); + nsing = iv[29]; + for(i = 0; i < (*n); i++) *trL = *trL + diagonal[i]; + F77_SUB(lowesa)(trL, n, d, &tau, &nsing, one_delta, two_delta); + } + else if (!strcmp(*surf_stat, "interpolate/exact")) { + hat_matrix = Calloc((*n)*(*n), double); + LL = Calloc((*n)*(*n), double); + F77_SUB(lowesb)(x, y, weights, diagonal, &one, iv, &liv, &lv, v); + F77_SUB(lowesl)(iv, &liv, &lv, v, n, x, hat_matrix); + F77_SUB(lowesc)(n, hat_matrix, LL, trL, one_delta, two_delta); + F77_SUB(lowese)(iv, &liv, &lv, v, n, x, surface); + loess_prune(parameter, a, xi, vert, vval); + Free(hat_matrix); + Free(LL); + } + else if (!strcmp(*surf_stat, "direct/exact")) { + hat_matrix = Calloc((*n)*(*n), double); + LL = Calloc((*n)*(*n), double); + F77_SUB(lowesf)(x, y, weights, iv, liv, lv, v, n, x, + hat_matrix, &two, surface); + F77_SUB(lowesc)(n, hat_matrix, LL, trL, one_delta, two_delta); + k = (*n) + 1; + for(i = 0; i < (*n); i++) + diagonal[i] = hat_matrix[i * k]; + Free(hat_matrix); + Free(LL); + } + loess_free(); +} + +loess_dfit(double *y, double *x, double *x_evaluate, double *weights, + double *span, int *degree, int *nonparametric, + int *drop_square, int *sum_drop_sqr, int *d, int *n, int *m, + double *fit) +{ + int zero = 0, one = 1; + loess_workspace(d, n, span, degree, nonparametric, drop_square, + sum_drop_sqr, &zero); + F77_SUB(lowesf)(x, y, weights, iv, &liv, &lv, v, m, x_evaluate, + &zero, &zero, fit); + loess_free(); +} + +loess_dfitse(double *y, double *x, double *x_evaluate, double *weights, + double *robust, int *family, double *span, int *degree, + int *nonparametric, int *drop_square, int *sum_drop_sqr, + int *d, int *n, int *m, double *fit, double *L) +{ + int zero = 0, one = 1, two = 2; + loess_workspace(d, n, span, degree, nonparametric, drop_square, + sum_drop_sqr, &zero); + if(*family == GAUSSIAN) + F77_SUB(lowesf)(x, y, weights, iv, &liv, &lv, v, m, + x_evaluate, L, &two, fit); + else if(*family == SYMMETRIC) + { + F77_SUB(lowesf)(x, y, weights, iv, &liv, &lv, v, m, + x_evaluate, L, &two, fit); + F77_SUB(lowesf)(x, y, robust, iv, &liv, &lv, v, m, + x_evaluate, &zero, &zero, fit); + } + loess_free(); +} + +loess_ifit(long *parameter, long *a, double *xi, double *vert, double *vval, + int *m, double *x_evaluate, double *fit) +{ + loess_grow(parameter, a, xi, vert, vval); + F77_SUB(lowese)(iv, &liv, &lv, v, m, x_evaluate, fit); + loess_free(); +} + +loess_ise(double *y, double *x, double *x_evaluate, double *weights, + double *span, int *degree, int *nonparametric, int *drop_square, + int *sum_drop_sqr, double *cell, int *d, int *n, int *m, + double *fit, double *L) +{ + int zero = 0, one = 1; + loess_workspace(d, n, span, degree, nonparametric, drop_square, + sum_drop_sqr, &one); + v[1] = *cell; + F77_SUB(lowesb)(x, y, weights, &zero, &zero, iv, &liv, &lv, v); + F77_SUB(lowesl)(iv, &liv, &lv, v, m, x_evaluate, L); + loess_free(); +} + +loess_workspace(int *d, int *n, double *span, int *degree, + int *nonparametric, int *drop_square, int *sum_drop_sqr, + int *setLf) +{ + int D, N, tau0, nvmax, nf, version = 106, i; + D = *d; + N = *n; + nvmax = max(200, N); + nf = min(N, floor(N * (*span))); + tau0 = ((*degree) > 1) ? ((D + 2) * (D + 1) * 0.5) : (D + 1); + tau = tau0 - (*sum_drop_sqr); + lv = 50 + (3 * D + 3) * nvmax + N + (tau0 + 2) * nf; + liv = 50 + ((int)pow((double)2, (double)D) + 4) * nvmax + 2 * N; + if(*setLf) { + lv = lv + (D + 1) * nf * nvmax; + liv = liv + nf * nvmax; + } + iv = Calloc(liv, int); + v = Calloc(lv, double); + + F77_SUB(lowesd)(&version, iv, &liv, &lv, v, d, n, span, degree, + &nvmax, setLf); + iv[32] = *nonparametric; + for(i = 0; i < D; i++) + iv[i + 40] = drop_square[i]; +} + +loess_prune(long *parameter, long *a, double *xi, double *vert, double *vval) +{ + int d, vc, a1, v1, xi1, vv1, nc, nv, nvmax, i, j, k; + + d = iv[1]; + vc = iv[3] - 1; + nc = iv[4]; + nv = iv[5]; + a1 = iv[6] - 1; + v1 = iv[10] - 1; + xi1 = iv[11] - 1; + vv1 = iv[12] - 1; + nvmax = iv[13]; + + for(i = 0; i < 5; i++) + parameter[i] = iv[i + 1]; + parameter[5] = iv[21] - 1; + parameter[6] = iv[14] - 1; + + for(i = 0; i < d; i++){ + k = nvmax * i; + vert[i] = v[v1 + k]; + vert[i + d] = v[v1 + vc + k]; + } + for(i = 0; i < nc; i++) { + xi[i] = v[xi1 + i]; + a[i] = iv[a1 + i]; + } + k = (d + 1) * nv; + for(i = 0; i < k; i++) + vval[i] = v[vv1 + i]; +} + +loess_grow(long *parameter, long *a, double *xi, double *vert, double *vval) +{ + int d, vc, nc, nv, a1, v1, xi1, vv1, i, j, k; + + d = parameter[0]; + vc = parameter[2]; + nc = parameter[3]; + nv = parameter[4]; + liv = parameter[5]; + lv = parameter[6]; + iv = Calloc(liv, int); + v = Calloc(lv, double); + + iv[1] = d; + iv[2] = parameter[1]; + iv[3] = vc; + iv[5] = iv[13] = nv; + iv[4] = iv[16] = nc; + iv[6] = 50; + iv[7] = iv[6] + nc; + iv[8] = iv[7] + vc * nc; + iv[9] = iv[8] + nc; + iv[10] = 50; + iv[12] = iv[10] + nv * d; + iv[11] = iv[12] + (d + 1) * nv; + iv[27] = 173; + + v1 = iv[10] - 1; + xi1 = iv[11] - 1; + a1 = iv[6] - 1; + vv1 = iv[12] - 1; + + for(i = 0; i < d; i++) { + k = nv * i; + v[v1 + k] = vert[i]; + v[v1 + vc - 1 + k] = vert[i + d]; + } + for(i = 0; i < nc; i++) { + v[xi1 + i] = xi[i]; + iv[a1 + i] = a[i]; + } + k = (d + 1) * nv; + for(i = 0; i < k; i++) + v[vv1 + i] = vval[i]; + + F77_SUB(ehg169)(&d, &vc, &nc, &nc, &nv, &nv, v+v1, iv+a1, + v+xi1, iv+iv[7]-1, iv+iv[8]-1, iv+iv[9]-1); +} + +loess_free() +{ + Free(v); + Free(iv); +} + +/* begin ehg's FORTRAN-callable C-codes */ + +void* +F77_SUB(ehg182)(int *i) +{ +char *mess, mess2[50]; +switch(*i){ +case 100: + mess="Wrong version number in lowesd. Probably typo in caller."; + break; +case 101: + mess="d>dMAX in ehg131. Need to recompile with increased dimensions."; + break; +case 102: + mess="liv too small. (Discovered by lowesd)"; + break; +case 103: + mess="lv too small. (Discovered by lowesd)"; + break; +case 104: + mess="Span too small. Fewer data values than degrees of freedom."; + break; +case 105: + mess="k>d2MAX in ehg136. Need to recompile with increased dimensions."; + break; +case 106: + mess="lwork too small"; + break; +case 107: + mess="Invalid value for kernel"; + break; +case 108: + mess="Invalid value for ideg"; + break; +case 109: + mess="lowstt only applies when kernel=1."; + break; +case 110: + mess="Not enough extra workspace for robustness calculation"; + break; +case 120: + mess="Zero-width neighborhood. Make span bigger"; + break; +case 121: + mess="All data on boundary of neighborhood. make span bigger"; + break; +case 122: + mess="Extrapolation not allowed with blending"; + break; +case 123: + mess="ihat=1 (diag L) in l2fit only makes sense if z=x (eval=data)."; + break; +case 171: + mess="lowesd must be called first."; + break; +case 172: + mess="lowesf must not come between lowesb and lowese, lowesr, or lowesl."; + break; +case 173: + mess="lowesb must come before lowese, lowesr, or lowesl."; + break; +case 174: + mess="lowesb need not be called twice."; + break; +case 175: + mess="Need setLf=.true. for lowesl."; + break; +case 180: + mess="nv>nvmax in cpvert."; + break; +case 181: + mess="nt>20 in eval."; + break; +case 182: + mess="svddc failed in l2fit."; + break; +case 183: + mess="Did not find edge in vleaf."; + break; +case 184: + mess="Zero-width cell found in vleaf."; + break; +case 185: + mess="Trouble descending to leaf in vleaf."; + break; +case 186: + mess="Insufficient workspace for lowesf."; + break; +case 187: + mess="Insufficient stack space."; + break; +case 188: + mess="lv too small for computing explicit L."; + break; +case 191: + mess="Computed trace L was negative; something is wrong!"; + break; +case 192: + mess="Computed delta was negative; something is wrong!"; + break; +case 193: + mess="Workspace in loread appears to be corrupted."; + break; +case 194: + mess="Trouble in l2fit/l2tr"; + break; +case 195: + mess="Only constant, linear, or quadratic local models allowed"; + break; +case 196: + mess="degree must be at least 1 for vertex influence matrix"; + break; +case 999: + mess="not yet implemented"; + break; +default: + sprintf(mess=mess2,"Assert failed; error code %d\n",*i); + break; + } +// printf(mess); + error_status = 1; + error_message = mess; +} + +void +F77_SUB(ehg183)(char *s,int *i, int *n, int *inc) +{ + char mess[4000], num[20]; + int j; + strcpy(mess,s); + for (j=0; j<*n; j++) { + sprintf(num," %d",i[j * *inc]); + strcat(mess,num); + } + strcat(mess,"\n"); +// printf(mess); + error_status = 1; + error_message = mess; +} + +void +F77_SUB(ehg184)(char *s, double *x, int *n, int *inc) +{ + char mess[4000], num[30]; + int j; + strcpy(mess,s); + for (j=0; j<*n; j++) { + sprintf(num," %.5g",x[j * *inc]); + strcat(mess,num); + } + strcat(mess,"\n"); +// printf(mess); + error_status = 1; + error_message = mess; +} Added: trunk/Lib/sandbox/pyloess/src/loessf.f =================================================================== --- trunk/Lib/sandbox/pyloess/src/loessf.f 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/loessf.f 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,2288 @@ + subroutine ehg126(d,n,vc,x,v,nvmax) + integer d,execnt,i,j,k,n,nv,nvmax,vc + DOUBLE PRECISION machin,alpha,beta,mu,t + DOUBLE PRECISION v(nvmax,d),x(n,d) + DOUBLE PRECISION D1MACH + external D1MACH + save machin,execnt + data execnt /0/ +c MachInf -> machin + execnt=execnt+1 + if(execnt.eq.1)then + machin=D1MACH(2) + end if +c fill in vertices for bounding box of $x$ +c lower left, upper right + do 3 k=1,d + alpha=machin + beta=-machin + do 4 i=1,n + t=x(i,k) + alpha=min(alpha,t) + beta=max(beta,t) + 4 continue +c expand the box a little + mu=0.005D0*max(beta-alpha,1.d-10*max(DABS(alpha),DABS(beta))+1. + +d-30) + alpha=alpha-mu + beta=beta+mu + v(1,k)=alpha + v(vc,k)=beta + 3 continue +c remaining vertices + do 5 i=2,vc-1 + j=i-1 + do 6 k=1,d + v(i,k)=v(1+mod(j,2)*(vc-1),k) + j=DFLOAT(j)/2.D0 + 6 continue + 5 continue + return + end +C----------------------------------------------------------------------C +C cpvert + subroutine ehg125(p,nv,v,vhit,nvmax,d,k,t,r,s,f,l,u) + logical i1,i2,match + integer d,execnt,h,i,i3,j,k,m,mm,nv,nvmax,p,r,s + integer f(r,0:1,s),l(r,0:1,s),u(r,0:1,s),vhit(nvmax) + DOUBLE PRECISION t + DOUBLE PRECISION v(nvmax,d) + external ehg182 + save execnt + data execnt /0/ + execnt=execnt+1 + h=nv + do 3 i=1,r + do 4 j=1,s + h=h+1 + do 5 i3=1,d + v(h,i3)=v(f(i,0,j),i3) + 5 continue + v(h,k)=t +c check for redundant vertex + match=.false. + m=1 +c top of while loop + 6 if(.not.match)then + i1=(m.le.nv) + else + i1=.false. + end if + if(.not.(i1))goto 7 + match=(v(m,1).eq.v(h,1)) + mm=2 +c top of while loop + 8 if(match)then + i2=(mm.le.d) + else + i2=.false. + end if + if(.not.(i2))goto 9 + match=(v(m,mm).eq.v(h,mm)) + mm=mm+1 + goto 8 +c bottom of while loop + 9 m=m+1 + goto 6 +c bottom of while loop + 7 m=m-1 + if(match)then + h=h-1 + else + m=h + if(vhit(1).ge.0)then + vhit(m)=p + end if + end if + l(i,0,j)=f(i,0,j) + l(i,1,j)=m + u(i,0,j)=m + u(i,1,j)=f(i,1,j) + 4 continue + 3 continue + nv=h + if(.not.(nv.le.nvmax))then + call ehg182(180) + end if + return + end +C----------------------------------------------------------------------- +C descend + integer function ehg138(i,z,a,xi,lo,hi,ncmax) + logical i1 + integer d,execnt,i,j,nc,ncmax + integer a(ncmax),hi(ncmax),lo(ncmax) + DOUBLE PRECISION xi(ncmax),z(8) + save execnt + data execnt /0/ + execnt=execnt+1 +c descend tree until leaf or ambiguous + j=i +c top of while loop + 3 if(a(j).ne.0)then + i1=(z(a(j)).ne.xi(j)) + else + i1=.false. + end if + if(.not.(i1))goto 4 + if(z(a(j)).le.xi(j))then + j=lo(j) + else + j=hi(j) + end if + goto 3 +c bottom of while loop + 4 ehg138=j + return + end + +C----------------------------------------------------------------------C +C select q-th smallest by partial sorting + subroutine ehg106(il,ir,k,nk,p,pi,n) + integer execnt,i,ii,il,ir,j,k,l,n,nk,r + integer pi(n) + DOUBLE PRECISION t + DOUBLE PRECISION p(nk,n) + save execnt + data execnt /0/ + execnt=execnt+1 +c find the $k$-th smallest of $n$ elements +c Floyd+Rivest, CACM Mar '75, Algorithm 489 + l=il + r=ir +c top of while loop + 3 if(.not.(l.lt.r))goto 4 +c to avoid recursion, sophisticated partition deleted +c partition $x sub {l..r}$ about $t$ + t=p(1,pi(k)) + i=l + j=r + ii=pi(l) + pi(l)=pi(k) + pi(k)=ii + if(t.lt.p(1,pi(r)))then + ii=pi(l) + pi(l)=pi(r) + pi(r)=ii + end if +c top of while loop + 5 if(.not.(i.lt.j))goto 6 + ii=pi(i) + pi(i)=pi(j) + pi(j)=ii + i=i+1 + j=j-1 +c top of while loop + 7 if(.not.(p(1,pi(i)).lt.t))goto 8 + i=i+1 + goto 7 +c bottom of while loop + 8 continue +c top of while loop + 9 if(.not.(t.lt.p(1,pi(j))))goto 10 + j=j-1 + goto 9 +c bottom of while loop + 10 goto 5 +c bottom of while loop + 6 if(p(1,pi(l)).eq.t)then + ii=pi(l) + pi(l)=pi(j) + pi(j)=ii + else + j=j+1 + ii=pi(r) + pi(r)=pi(j) + pi(j)=ii + end if + if(j.le.k)then + l=j+1 + end if + if(k.le.j)then + r=j-1 + end if + goto 3 +c bottom of while loop + 4 return + end + +C----------------------------------------------------------------------C +C l2fit,l2tr computational kernel + subroutine ehg127(q,n,d,nf,f,x,psi,y,rw,kernel,k,dist,eta,b,od,w,r + +cond,sing,sigma,u,e,dgamma,qraux,work,tol,dd,tdeg,cdeg,s) + integer column,d,dd,execnt,i,i3,i9,info,inorm2,j,jj,jpvt,k,kernel, + +n,nf,od,sing,tdeg + integer cdeg(8),psi(n) + double precision machep,f,i1,i10,i2,i4,i5,i6,i7,i8,rcond,rho,scal, + +tol + double precision g(15),sigma(15),u(15,15),e(15,15),b(nf,k),colnor( + +15),dist(n),eta(nf),dgamma(15),q(d),qraux(15),rw(n),s(0:od),w(nf), + +work(15),x(n,d),y(n) + external ehg106,ehg182,ehg184,dqrdc,dqrsl,dsvdc + integer idamax + external idamax + double precision d1mach + external d1mach + double precision ddot + external ddot + save machep,execnt + data execnt /0/ +c colnorm -> colnor +c E -> g +c MachEps -> machep +c V -> e +c X -> b + execnt=execnt+1 + if(execnt.eq.1)then + machep=d1mach(4) + end if +c sort by distance + do 3 i3=1,n + dist(i3)=0 + 3 continue + do 4 j=1,dd + i4=q(j) + do 5 i3=1,n + dist(i3)=dist(i3)+(x(i3,j)-i4)**2 + 5 continue + 4 continue + call ehg106(1,n,nf,1,dist,psi,n) + rho=dist(psi(nf))*max(1.d0,f) + if(.not.(0.lt.rho))then + call ehg182(120) + end if +c compute neighborhood weights + if(kernel.eq.2)then + do 6 i=1,nf + if(dist(psi(i)).lt.rho)then + i1=dsqrt(rw(psi(i))) + else + i1=0 + end if + w(i)=i1 + 6 continue + else + do 7 i3=1,nf + w(i3)=dsqrt(dist(psi(i3))/rho) + 7 continue + do 8 i3=1,nf + w(i3)=dsqrt(rw(psi(i3))*(1-w(i3)**3)**3) + 8 continue + end if + if(dabs(w(idamax(nf,w,1))).eq.0)then + call ehg184('at ',q,dd,1) + call ehg184('radius ',rho,1,1) + if(.not..false.)then + call ehg182(121) + end if + end if +c fill design matrix + column=1 + do 9 i3=1,nf + b(i3,column)=w(i3) + 9 continue + if(tdeg.ge.1)then + do 10 j=1,d + if(cdeg(j).ge.1)then + column=column+1 + i5=q(j) + do 11 i3=1,nf + b(i3,column)=w(i3)*(x(psi(i3),j)-i5) + 11 continue + end if + 10 continue + end if + if(tdeg.ge.2)then + do 12 j=1,d + if(cdeg(j).ge.1)then + if(cdeg(j).ge.2)then + column=column+1 + i6=q(j) + do 13 i3=1,nf + b(i3,column)=w(i3)*(x(psi(i3),j)-i6)**2 + 13 continue + end if + do 14 jj=j+1,d + if(cdeg(jj).ge.1)then + column=column+1 + i7=q(j) + i8=q(jj) + do 15 i3=1,nf + b(i3,column)=w(i3)*(x(psi(i3),j)-i7)*(x(psi(i3), + +jj)-i8) + 15 continue + end if + 14 continue + end if + 12 continue + k=column + end if + do 16 i3=1,nf + eta(i3)=w(i3)*y(psi(i3)) + 16 continue +c equilibrate columns + do 17 j=1,k + scal=0 + do 18 inorm2=1,nf + scal=scal+b(inorm2,j)**2 + 18 continue + scal=dsqrt(scal) + if(0.lt.scal)then + do 19 i3=1,nf + b(i3,j)=b(i3,j)/scal + 19 continue + colnor(j)=scal + else + colnor(j)=1 + end if + 17 continue +c singular value decomposition + call dqrdc(b,nf,nf,k,qraux,jpvt,work,0) + call dqrsl(b,nf,nf,k,qraux,eta,work,eta,eta,work,work,1000,info) + do 20 i9=1,k + do 21 i3=1,k + u(i3,i9)=0 + 21 continue + 20 continue + do 22 i=1,k + do 23 j=i,k + u(i,j)=b(i,j) + 23 continue + 22 continue + call dsvdc(u,15,k,k,sigma,g,u,15,e,15,work,21,info) + if(.not.(info.eq.0))then + call ehg182(182) + end if + tol=sigma(1)*(100*machep) + rcond=min(rcond,sigma(k)/sigma(1)) + if(sigma(k).le.tol)then + sing=sing+1 + if(sing.eq.1)then + call ehg184('Warning. pseudoinverse used at',q,d,1) + call ehg184('neighborhood radius',dsqrt(rho),1,1) + call ehg184('reciprocal condition number ',rcond,1,1) + else + if(sing.eq.2)then + call ehg184('There are other near singularities as well.' + +,rho,1,1) + end if + end if + end if +c compensate for equilibration + do 24 j=1,k + i10=colnor(j) + do 25 i3=1,k + e(j,i3)=e(j,i3)/i10 + 25 continue + 24 continue +c solve least squares problem + do 26 j=1,k + if(tol.lt.sigma(j))then + i2=ddot(k,u(1,j),1,eta,1)/sigma(j) + else + i2=0.d0 + end if + dgamma(j)=i2 + 26 continue + do 27 j=0,od +c bug fix 2006-07-04 for k=1, od>1. (thanks btyner at gmail.com) + if(j.lt.k)then + s(j)=ddot(k,e(j+1,1),15,dgamma,1) + else + s(j)=0.d0 + end if + 27 continue + return + end + +C----------------------------------------------------------------------C +C lowesb after workspace expansion + subroutine ehg131(x,y,rw,trl,diagl,kernel,k,n,d,nc,ncmax,vc,nv,nvm + +ax,nf,f,a,c,hi,lo,pi,psi,v,vhit,vval,xi,dist,eta,b,ntol,fd,w,vval2 + +,rcond,sing,dd,tdeg,cdeg,lq,lf,setlf) + logical setlf + integer identi,d,dd,execnt,i1,i2,j,k,kernel,n,nc,ncmax,nf,ntol,nv, + +nvmax,sing,tdeg,vc + integer lq(nvmax,nf),a(ncmax),c(vc,ncmax),cdeg(8),hi(ncmax),lo(ncm + +ax),pi(n),psi(n),vhit(nvmax) + double precision f,fd,rcond,trl + double precision lf(0:d,nvmax,nf),b(*),delta(8),diagl(n),dist(n),e + +ta(nf),rw(n),v(nvmax,d),vval(0:d,nvmax),vval2(0:d,nvmax),w(nf),x(n + +,d),xi(ncmax),y(n) + external ehg126,ehg182,ehg139,ehg124 + double precision dnrm2 + external dnrm2 + save execnt + data execnt /0/ +c Identity -> identi +c X -> b + execnt=execnt+1 + if(.not.(d.le.8))then + call ehg182(101) + end if +c build $k$-d tree + call ehg126(d,n,vc,x,v,nvmax) + nv=vc + nc=1 + do 3 j=1,vc + c(j,nc)=j + vhit(j)=0 + 3 continue + do 4 i1=1,d + delta(i1)=v(vc,i1)-v(1,i1) + 4 continue + fd=fd*dnrm2(d,delta,1) + do 5 identi=1,n + pi(identi)=identi + 5 continue + call ehg124(1,n,d,n,nv,nc,ncmax,vc,x,pi,a,xi,lo,hi,c,v,vhit,nvmax, + +ntol,fd,dd) +c smooth + if(trl.ne.0)then + do 6 i2=1,nv + do 7 i1=0,d + vval2(i1,i2)=0 + 7 continue + 6 continue + end if + call ehg139(v,nvmax,nv,n,d,nf,f,x,pi,psi,y,rw,trl,kernel,k,dist,di + +st,eta,b,d,w,diagl,vval2,nc,vc,a,xi,lo,hi,c,vhit,rcond,sing,dd,tde + +g,cdeg,lq,lf,setlf,vval) + return + end + +C----------------------------------------------------------------------C +C lowese after workspace expansion + subroutine ehg133(n,d,vc,nvmax,nc,ncmax,a,c,hi,lo,v,vval,xi,m,z,s) + integer d,execnt,i,i1,m,nc,ncmax,nv,nvmax,vc + integer a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax) + double precision delta(8),s(m),v(nvmax,d),vval(0:d,nvmax),xi(ncmax + +),z(m,d) + double precision ehg128 + external ehg128 + save execnt + data execnt /0/ + execnt=execnt+1 + do 3 i=1,m + do 4 i1=1,d + delta(i1)=z(i,i1) + 4 continue + s(i)=ehg128(delta,d,ncmax,vc,a,xi,lo,hi,c,v,nvmax,vval) + 3 continue + return + end + subroutine ehg140(iw,i,j) + integer execnt,i,j + integer iw(i) + save execnt + data execnt /0/ + execnt=execnt+1 + iw(i)=j + return + end + +C----------------------------------------------------------------------C +C delta1,2 from trL + subroutine ehg141(trl,n,deg,k,d,nsing,dk,delta1,delta2) + integer d,deg,dk,k,n,nsing + external ehg176 + double precision ehg176 + double precision corx,delta1,delta2,trl,z + double precision c(48), c1, c2, c3, c4 +c coef, d, deg, del + data c / .2971620d0,.3802660d0,.5886043d0,.4263766d0,.3346498d0,.6 + +271053d0,.5241198d0,.3484836d0,.6687687d0,.6338795d0,.4076457d0,.7 + +207693d0,.1611761d0,.3091323d0,.4401023d0,.2939609d0,.3580278d0,.5 + +555741d0,.3972390d0,.4171278d0,.6293196d0,.4675173d0,.4699070d0,.6 + +674802d0,.2848308d0,.2254512d0,.2914126d0,.5393624d0,.2517230d0,.3 + +898970d0,.7603231d0,.2969113d0,.4740130d0,.9664956d0,.3629838d0,.5 + +348889d0,.2075670d0,.2822574d0,.2369957d0,.3911566d0,.2981154d0,.3 + +623232d0,.5508869d0,.3501989d0,.4371032d0,.7002667d0,.4291632d0,.4 + +930370d0 / + if(deg.eq.0) dk=1 + if(deg.eq.1) dk=d+1 + if(deg.eq.2) dk=dfloat((d+2)*(d+1))/2.d0 + corx=dsqrt(k/dfloat(n)) + z=(dsqrt(k/trl)-corx)/(1-corx) + if(nsing .eq. 0 .and. 1 .lt. z) call ehg184('Chernobyl! trLn',trl,1,1) + z=min(1.0d0,max(0.0d0,z)) + c4=dexp(ehg176(z)) + i=1+3*(min(d,4)-1+4*(deg-1)) + if(d.le.4)then + c1=c(i) + c2=c(i+1) + c3=c(i+2) + else + c1=c(i)+(d-4)*(c(i)-c(i-3)) + c2=c(i+1)+(d-4)*(c(i+1)-c(i-2)) + c3=c(i+2)+(d-4)*(c(i+2)-c(i-1)) + endif + delta1=n-trl*dexp(c1*z**c2*(1-z)**c3*c4) + i=i+24 + if(d.le.4)then + c1=c(i) + c2=c(i+1) + c3=c(i+2) + else + c1=c(i)+(d-4)*(c(i)-c(i-3)) + c2=c(i+1)+(d-4)*(c(i+1)-c(i-2)) + c3=c(i+2)+(d-4)*(c(i+2)-c(i-1)) + endif + delta2=n-trl*dexp(c1*z**c2*(1-z)**c3*c4) + return + end + +C----------------------------------------------------------------------C +C exact delta + subroutine lowesc(n,l,ll,trl,delta1,delta2) + integer execnt,i,j,n + double precision delta1,delta2,trl + double precision l(n,n),ll(n,n) + double precision ddot + external ddot + save execnt + data execnt /0/ + execnt=execnt+1 +c compute $LL~=~(I-L)(I-L)'$ + do 3 i=1,n + l(i,i)=l(i,i)-1 + 3 continue + do 4 i=1,n + do 5 j=1,i + ll(i,j)=ddot(n,l(i,1),n,l(j,1),n) + 5 continue + 4 continue + do 6 i=1,n + do 7 j=i+1,n + ll(i,j)=ll(j,i) + 7 continue + 6 continue + do 8 i=1,n + l(i,i)=l(i,i)+1 + 8 continue +c accumulate first two traces + trl=0 + delta1=0 + do 9 i=1,n + trl=trl+l(i,i) + delta1=delta1+ll(i,i) + 9 continue +c $delta sub 2 = "tr" LL sup 2$ + delta2=0 + do 10 i=1,n + delta2=delta2+ddot(n,ll(i,1),n,ll(1,i),1) + 10 continue + return + end + +C----------------------------------------------------------------------C +C compute derived k-d tree information + subroutine ehg169(d,vc,nc,ncmax,nv,nvmax,v,a,xi,c,hi,lo) + integer d,execnt,i,j,k,mc,mv,nc,ncmax,nv,nvmax,p,vc + integer a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax),novhit(1) + DOUBLE PRECISION v(nvmax,d),xi(ncmax) + external ehg125,ehg182 + integer ifloor + external ifloor + save execnt + data execnt /0/ + execnt=execnt+1 +c as in bbox +c remaining vertices + do 3 i=2,vc-1 + j=i-1 + do 4 k=1,d + v(i,k)=v(1+mod(j,2)*(vc-1),k) + j=ifloor(DFLOAT(j)/2.D0) + 4 continue + 3 continue +c as in ehg131 + mc=1 + mv=vc + novhit(1)=-1 + do 5 j=1,vc + c(j,mc)=j + 5 continue +c as in rbuild + p=1 +c top of while loop + 6 if(.not.(p.le.nc))goto 7 + if(a(p).ne.0)then + k=a(p) +c left son + mc=mc+1 + lo(p)=mc +c right son + mc=mc+1 + hi(p)=mc + call ehg125(p,mv,v,novhit,nvmax,d,k,xi(p),2**(k-1),2**(d-k), + +c(1,p),c(1,lo(p)),c(1,hi(p))) + end if + p=p+1 + goto 6 +c bottom of while loop + 7 if(.not.(mc.eq.nc))then + call ehg182(193) + end if + if(.not.(mv.eq.nv))then + call ehg182(193) + end if + return + end + +C----------------------------------------------------------------------C +C loeval for delta + DOUBLE PRECISION function ehg176(z) + DOUBLE PRECISION z(*) + integer d,vc,nv,nc + integer a(17), c(2,17) + integer hi(17), lo(17) + DOUBLE PRECISION v(10,1) + DOUBLE PRECISION vval(0:1,10) + DOUBLE PRECISION xi(17) + DOUBLE PRECISION ehg128 + data d,vc,nv,nc /1,2,10,17/ + data a(1) /1/ + data hi(1),lo(1),xi(1) /3,2,0.3705D0/ + data c(1,1) /1/ + data c(2,1) /2/ + data a(2) /1/ + data hi(2),lo(2),xi(2) /5,4,0.2017D0/ + data c(1,2) /1/ + data c(2,2) /3/ + data a(3) /1/ + data hi(3),lo(3),xi(3) /7,6,0.5591D0/ + data c(1,3) /3/ + data c(2,3) /2/ + data a(4) /1/ + data hi(4),lo(4),xi(4) /9,8,0.1204D0/ + data c(1,4) /1/ + data c(2,4) /4/ + data a(5) /1/ + data hi(5),lo(5),xi(5) /11,10,0.2815D0/ + data c(1,5) /4/ + data c(2,5) /3/ + data a(6) /1/ + data hi(6),lo(6),xi(6) /13,12,0.4536D0/ + data c(1,6) /3/ + data c(2,6) /5/ + data a(7) /1/ + data hi(7),lo(7),xi(7) /15,14,0.7132D0/ + data c(1,7) /5/ + data c(2,7) /2/ + data a(8) /0/ + data c(1,8) /1/ + data c(2,8) /6/ + data a(9) /0/ + data c(1,9) /6/ + data c(2,9) /4/ + data a(10) /0/ + data c(1,10) /4/ + data c(2,10) /7/ + data a(11) /0/ + data c(1,11) /7/ + data c(2,11) /3/ + data a(12) /0/ + data c(1,12) /3/ + data c(2,12) /8/ + data a(13) /0/ + data c(1,13) /8/ + data c(2,13) /5/ + data a(14) /0/ + data c(1,14) /5/ + data c(2,14) /9/ + data a(15) /1/ + data hi(15),lo(15),xi(15) /17,16,0.8751D0/ + data c(1,15) /9/ + data c(2,15) /2/ + data a(16) /0/ + data c(1,16) /9/ + data c(2,16) /10/ + data a(17) /0/ + data c(1,17) /10/ + data c(2,17) /2/ + data vval(0,1) /-9.0572D-2/ + data v(1,1) /-5.D-3/ + data vval(1,1) /4.4844D0/ + data vval(0,2) /-1.0856D-2/ + data v(2,1) /1.005D0/ + data vval(1,2) /-0.7736D0/ + data vval(0,3) /-5.3718D-2/ + data v(3,1) /0.3705D0/ + data vval(1,3) /-0.3495D0/ + data vval(0,4) /2.6152D-2/ + data v(4,1) /0.2017D0/ + data vval(1,4) /-0.7286D0/ + data vval(0,5) /-5.8387D-2/ + data v(5,1) /0.5591D0/ + data vval(1,5) /0.1611D0/ + data vval(0,6) /9.5807D-2/ + data v(6,1) /0.1204D0/ + data vval(1,6) /-0.7978D0/ + data vval(0,7) /-3.1926D-2/ + data v(7,1) /0.2815D0/ + data vval(1,7) /-0.4457D0/ + data vval(0,8) /-6.4170D-2/ + data v(8,1) /0.4536D0/ + data vval(1,8) /3.2813D-2/ + data vval(0,9) /-2.0636D-2/ + data v(9,1) /0.7132D0/ + data vval(1,9) /0.3350D0/ + data vval(0,10) /4.0172D-2/ + data v(10,1) /0.8751D0/ + data vval(1,10) /-4.1032D-2/ + ehg176=ehg128(z,d,nc,vc,a,xi,lo,hi,c,v,nv,vval) + end + +C----------------------------------------------------------------------C +C approximate delta + subroutine lowesa(trl,n,d,tau,nsing,delta1,delta2) + integer d,dka,dkb,execnt,n,nsing,tau + double precision alpha,d1a,d1b,d2a,d2b,delta1,delta2,trl + external ehg141 + save execnt + data execnt /0/ + execnt=execnt+1 + call ehg141(trl,n,1,tau,d,nsing,dka,d1a,d2a) + call ehg141(trl,n,2,tau,d,nsing,dkb,d1b,d2b) + alpha=dfloat(tau-dka)/dfloat(dkb-dka) + delta1=(1-alpha)*d1a+alpha*d1b + delta2=(1-alpha)*d2a+alpha*d2b + return + end + +C----------------------------------------------------------------------C +C lowesl after workspace expansion + subroutine ehg191(m,z,l,d,n,nf,nv,ncmax,vc,a,xi,lo,hi,c,v,nvmax,vv + +al2,lf,lq) + integer lq1,d,execnt,i,i1,i2,j,m,n,nc,ncmax,nf,nv,nvmax,p,vc + integer lq(nvmax,nf),a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax) + double precision l(m,n),lf(0:d,nvmax,nf),v(nvmax,d),vval2(0:d,nvma + +x),xi(ncmax),z(m,d),zi(8) + double precision ehg128 + external ehg128 + save execnt + data execnt /0/ + execnt=execnt+1 + do 3 j=1,n + do 4 i2=1,nv + do 5 i1=0,d + vval2(i1,i2)=0 + 5 continue + 4 continue + do 6 i=1,nv +c linear search for i in Lq + lq1=lq(i,1) + lq(i,1)=j + p=nf +c top of while loop + 7 if(.not.(lq(i,p).ne.j))goto 8 + p=p-1 + goto 7 +c bottom of while loop + 8 lq(i,1)=lq1 + if(lq(i,p).eq.j)then + do 9 i1=0,d + vval2(i1,i)=lf(i1,i,p) + 9 continue + end if + 6 continue + do 10 i=1,m + do 11 i1=1,d + zi(i1)=z(i,i1) + 11 continue + l(i,j)=ehg128(zi,d,ncmax,vc,a,xi,lo,hi,c,v,nvmax,vval2) + 10 continue + 3 continue + return + end + +C----------------------------------------------------------------------C +C trL approximation + subroutine ehg196(tau,d,f,trl) + integer d,dka,dkb,execnt,tau + double precision alpha,f,trl,trla,trlb + external ehg197 + save execnt + data execnt /0/ + execnt=execnt+1 + call ehg197(1,tau,d,f,dka,trla) + call ehg197(2,tau,d,f,dkb,trlb) + alpha=dfloat(tau-dka)/dfloat(dkb-dka) + trl=(1-alpha)*trla+alpha*trlb + return + end + +C----------------------------------------------------------------------C +C for deg 1,2 + subroutine ehg197(deg,tau,d,f,dk,trl) + integer d,deg,dk,tau + double precision trl, f + dk = 0 + if(deg.eq.1) dk=d+1 + if(deg.eq.2) dk=dfloat((d+2)*(d+1))/2.d0 + g1 = (-0.08125d0*d+0.13d0)*d+1.05d0 + trl = dk*(1+max(0.d0,(g1-f)/f)) + return + end + +C----------------------------------------------------------------------C +C lowesr after workspace expansion + subroutine ehg192(y,d,n,nf,nv,nvmax,vval,lf,lq) + integer d,execnt,i,i1,i2,j,n,nf,nv,nvmax + integer lq(nvmax,nf) + DOUBLE PRECISION i3 + DOUBLE PRECISION lf(0:d,nvmax,nf),vval(0:d,nvmax),y(n) + save execnt + data execnt /0/ + execnt=execnt+1 + do 3 i2=1,nv + do 4 i1=0,d + vval(i1,i2)=0 + 4 continue + 3 continue + do 5 i=1,nv + do 6 j=1,nf + i3=y(lq(i,j)) + do 7 i1=0,d + vval(i1,i)=vval(i1,i)+i3*lf(i1,i,j) + 7 continue + 6 continue + 5 continue + return + end + + +C----------------------------------------------------------------------C +C eval + DOUBLE PRECISION function ehg128(z,d,ncmax,vc,a,xi,lo,hi,c,v,nvmax + +,vval) + logical i10,i2,i3,i4,i5,i6,i7,i8,i9 + integer d,execnt,i,i1,i11,i12,ig,ii,j,lg,ll,m,nc,ncmax,nt,nv,nvmax + +,ur,vc + integer a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax),t(20) + DOUBLE PRECISION ge,gn,gs,gw,gpe,gpn,gps,gpw,h,phi0,phi1,psi0,psi1 + +,s,sew,sns,v0,v1,xibar + DOUBLE PRECISION g(0:8,256),g0(0:8),g1(0:8),v(nvmax,d),vval(0:d,nv + +max),xi(ncmax),z(d) + external ehg182,ehg184 + save execnt + data execnt /0/ + execnt=execnt+1 +c locate enclosing cell + nt=1 + t(nt)=1 + j=1 +c top of while loop + 3 if(.not.(a(j).ne.0))goto 4 + nt=nt+1 +c bug fix 2006-07-18 (thanks, btyner at gmail.com) + if(z(a(j)).le.xi(j))then + i1=lo(j) + else + i1=hi(j) + end if + t(nt)=i1 + if(.not.(nt.lt.20))then + call ehg182(181) + end if + j=t(nt) + goto 3 +c bottom of while loop + 4 continue +c tensor + do 5 i12=1,vc + do 6 i11=0,d + g(i11,i12)=vval(i11,c(i12,j)) + 6 continue + 5 continue + lg=vc + ll=c(1,j) + ur=c(vc,j) + do 7 i=d,1,-1 + h=(z(i)-v(ll,i))/(v(ur,i)-v(ll,i)) + if(h.lt.-.001D0)then + call ehg184('eval ',z,d,1) + call ehg184('lowerlimit ',v(ll,1),d,nvmax) + else + if(1.001D0.lt.h)then + call ehg184('eval ',z,d,1) + call ehg184('upperlimit ',v(ur,1),d,nvmax) + end if + end if + if(-.001D0.le.h)then + i2=(h.le.1.001D0) + else + i2=.false. + end if + if(.not.i2)then + call ehg182(122) + end if + lg=DFLOAT(lg)/2.D0 + do 8 ig=1,lg +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + g(0,ig)=phi0*g(0,ig)+phi1*g(0,ig+lg)+(psi0*g(i,ig)+psi1*g(i, + +ig+lg))*(v(ur,i)-v(ll,i)) + do 9 ii=1,i-1 + g(ii,ig)=phi0*g(ii,ig)+phi1*g(ii,ig+lg) + 9 continue + 8 continue + 7 continue + s=g(0,1) +c blending + if(d.eq.2)then +c ----- North ----- + v0=v(ll,1) + v1=v(ur,1) + do 10 i11=0,d + g0(i11)=vval(i11,c(3,j)) + 10 continue + do 11 i11=0,d + g1(i11)=vval(i11,c(4,j)) + 11 continue + xibar=v(ur,2) + m=nt-1 +c top of while loop + 12 if(m.eq.0)then + i4=.true. + else + if(a(t(m)).eq.2)then + i3=(xi(t(m)).eq.xibar) + else + i3=.false. + end if + i4=i3 + end if + if(.not.(.not.i4))goto 13 + m=m-1 +c voidp junk + goto 12 +c bottom of while loop + 13 if(m.ge.1)then + m=hi(t(m)) +c top of while loop + 14 if(.not.(a(m).ne.0))goto 15 + if(z(a(m)).le.xi(m))then + m=lo(m) + else + m=hi(m) + end if + goto 14 +c bottom of while loop + 15 if(v0.lt.v(c(1,m),1))then + v0=v(c(1,m),1) + do 16 i11=0,d + g0(i11)=vval(i11,c(1,m)) + 16 continue + end if + if(v(c(2,m),1).lt.v1)then + v1=v(c(2,m),1) + do 17 i11=0,d + g1(i11)=vval(i11,c(2,m)) + 17 continue + end if + end if + h=(z(1)-v0)/(v1-v0) +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + gn=phi0*g0(0)+phi1*g1(0)+(psi0*g0(1)+psi1*g1(1))*(v1-v0) + gpn=phi0*g0(2)+phi1*g1(2) +c ----- South ----- + v0=v(ll,1) + v1=v(ur,1) + do 18 i11=0,d + g0(i11)=vval(i11,c(1,j)) + 18 continue + do 19 i11=0,d + g1(i11)=vval(i11,c(2,j)) + 19 continue + xibar=v(ll,2) + m=nt-1 +c top of while loop + 20 if(m.eq.0)then + i6=.true. + else + if(a(t(m)).eq.2)then + i5=(xi(t(m)).eq.xibar) + else + i5=.false. + end if + i6=i5 + end if + if(.not.(.not.i6))goto 21 + m=m-1 +c voidp junk + goto 20 +c bottom of while loop + 21 if(m.ge.1)then + m=lo(t(m)) +c top of while loop + 22 if(.not.(a(m).ne.0))goto 23 + if(z(a(m)).le.xi(m))then + m=lo(m) + else + m=hi(m) + end if + goto 22 +c bottom of while loop + 23 if(v0.lt.v(c(3,m),1))then + v0=v(c(3,m),1) + do 24 i11=0,d + g0(i11)=vval(i11,c(3,m)) + 24 continue + end if + if(v(c(4,m),1).lt.v1)then + v1=v(c(4,m),1) + do 25 i11=0,d + g1(i11)=vval(i11,c(4,m)) + 25 continue + end if + end if + h=(z(1)-v0)/(v1-v0) +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + gs=phi0*g0(0)+phi1*g1(0)+(psi0*g0(1)+psi1*g1(1))*(v1-v0) + gps=phi0*g0(2)+phi1*g1(2) +c ----- East ----- + v0=v(ll,2) + v1=v(ur,2) + do 26 i11=0,d + g0(i11)=vval(i11,c(2,j)) + 26 continue + do 27 i11=0,d + g1(i11)=vval(i11,c(4,j)) + 27 continue + xibar=v(ur,1) + m=nt-1 +c top of while loop + 28 if(m.eq.0)then + i8=.true. + else + if(a(t(m)).eq.1)then + i7=(xi(t(m)).eq.xibar) + else + i7=.false. + end if + i8=i7 + end if + if(.not.(.not.i8))goto 29 + m=m-1 +c voidp junk + goto 28 +c bottom of while loop + 29 if(m.ge.1)then + m=hi(t(m)) +c top of while loop + 30 if(.not.(a(m).ne.0))goto 31 + if(z(a(m)).le.xi(m))then + m=lo(m) + else + m=hi(m) + end if + goto 30 +c bottom of while loop + 31 if(v0.lt.v(c(1,m),2))then + v0=v(c(1,m),2) + do 32 i11=0,d + g0(i11)=vval(i11,c(1,m)) + 32 continue + end if + if(v(c(3,m),2).lt.v1)then + v1=v(c(3,m),2) + do 33 i11=0,d + g1(i11)=vval(i11,c(3,m)) + 33 continue + end if + end if + h=(z(2)-v0)/(v1-v0) +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + ge=phi0*g0(0)+phi1*g1(0)+(psi0*g0(2)+psi1*g1(2))*(v1-v0) + gpe=phi0*g0(1)+phi1*g1(1) +c ----- West ----- + v0=v(ll,2) + v1=v(ur,2) + do 34 i11=0,d + g0(i11)=vval(i11,c(1,j)) + 34 continue + do 35 i11=0,d + g1(i11)=vval(i11,c(3,j)) + 35 continue + xibar=v(ll,1) + m=nt-1 +c top of while loop + 36 if(m.eq.0)then + i10=.true. + else + if(a(t(m)).eq.1)then + i9=(xi(t(m)).eq.xibar) + else + i9=.false. + end if + i10=i9 + end if + if(.not.(.not.i10))goto 37 + m=m-1 +c voidp junk + goto 36 +c bottom of while loop + 37 if(m.ge.1)then + m=lo(t(m)) +c top of while loop + 38 if(.not.(a(m).ne.0))goto 39 + if(z(a(m)).le.xi(m))then + m=lo(m) + else + m=hi(m) + end if + goto 38 +c bottom of while loop + 39 if(v0.lt.v(c(2,m),2))then + v0=v(c(2,m),2) + do 40 i11=0,d + g0(i11)=vval(i11,c(2,m)) + 40 continue + end if + if(v(c(4,m),2).lt.v1)then + v1=v(c(4,m),2) + do 41 i11=0,d + g1(i11)=vval(i11,c(4,m)) + 41 continue + end if + end if + h=(z(2)-v0)/(v1-v0) +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + gw=phi0*g0(0)+phi1*g1(0)+(psi0*g0(2)+psi1*g1(2))*(v1-v0) + gpw=phi0*g0(1)+phi1*g1(1) +c NS + h=(z(2)-v(ll,2))/(v(ur,2)-v(ll,2)) +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + sns=phi0*gs+phi1*gn+(psi0*gps+psi1*gpn)*(v(ur,2)-v(ll,2)) +c EW + h=(z(1)-v(ll,1))/(v(ur,1)-v(ll,1)) +c Hermite basis + phi0=(1-h)**2*(1+2*h) + phi1=h**2*(3-2*h) + psi0=h*(1-h)**2 + psi1=h**2*(h-1) + sew=phi0*gw+phi1*ge+(psi0*gpw+psi1*gpe)*(v(ur,1)-v(ll,1)) + s=(sns+sew)-s + end if + ehg128=s + return + end + + +C----------------------------------------------------------------------C +C + integer function ifloor(x) + DOUBLE PRECISION x + ifloor=x + if(ifloor.gt.x) ifloor=ifloor-1 + end + DOUBLE PRECISION functionDSIGN(a1,a2) + DOUBLE PRECISION a1, a2 + DSIGN=DABS(a1) + if(a2.ge.0)DSIGN=-DSIGN + end + subroutine ehg136(u,lm,m,n,d,nf,f,x,psi,y,rw,kernel,k,dist,eta,b,o + +d,o,ihat,w,rcond,sing,dd,tdeg,cdeg,s) + integer identi,d,dd,execnt,i,i1,ihat,info,j,k,kernel,l,lm,m,n,nf,o + +d,sing,tdeg + integer cdeg(8),psi(n) + double precision f,i2,rcond,scale,tol + double precision o(m,n),sigma(15),e(15,15),g(15,15),b(nf,k),dist(n + +),eta(nf),dgamma(15),q(8),qraux(15),rw(n),s(0:od,m),u(lm,d),w(nf), + +work(15),x(n,d),y(n) + external ehg127,ehg182,dqrsl + double precision ddot + external ddot + save execnt + data execnt /0/ +c V -> g +c U -> e +c Identity -> identi +c L -> o +c X -> b + execnt=execnt+1 + if(.not.(k.le.nf-1))then + call ehg182(104) + end if + if(.not.(k.le.15))then + call ehg182(105) + end if + do 3 identi=1,n + psi(identi)=identi + 3 continue + do 4 l=1,m + do 5 i1=1,d + q(i1)=u(l,i1) + 5 continue + call ehg127(q,n,d,nf,f,x,psi,y,rw,kernel,k,dist,eta,b,od,w,rcon + +d,sing,sigma,e,g,dgamma,qraux,work,tol,dd,tdeg,cdeg,s(0,l)) + if(ihat.eq.1)then +c $L sub {l,l} = +c V sub {1,:} SIGMA sup {+} U sup T +c (Q sup T W e sub i )$ + if(.not.(m.eq.n))then + call ehg182(123) + end if +c find $i$ such that $l = psi sub i$ + i=1 +c top of while loop + 6 if(.not.(l.ne.psi(i)))goto 7 + i=i+1 + if(.not.(i.lt.nf))then + call ehg182(123) + end if + goto 6 +c bottom of while loop + 7 do 8 i1=1,nf + eta(i1)=0 + 8 continue + eta(i)=w(i) +c $eta = Q sup T W e sub i$ + call dqrsl(b,nf,nf,k,qraux,eta,eta,eta,eta,eta,eta,1000,info + +) +c $gamma = U sup T eta sub {1:k}$ + do 9 i1=1,k + dgamma(i1)=0 + 9 continue + do 10 j=1,k + i2=eta(j) + do 11 i1=1,k + dgamma(i1)=dgamma(i1)+i2*e(j,i1) + 11 continue + 10 continue +c $gamma = SIGMA sup {+} gamma$ + do 12 j=1,k + if(tol.lt.sigma(j))then + dgamma(j)=dgamma(j)/sigma(j) + else + dgamma(j)=0.d0 + end if + 12 continue +c voidp junk +c voidp junk + o(l,1)=ddot(k,g(1,1),15,dgamma,1) + else + if(ihat.eq.2)then +c $L sub {l,:} = +c V sub {1,:} SIGMA sup {+} +c ( U sup T Q sup T ) W $ + do 13 i1=1,n + o(l,i1)=0 + 13 continue + do 14 j=1,k + do 15 i1=1,nf + eta(i1)=0 + 15 continue + do 16 i1=1,k + eta(i1)=e(i1,j) + 16 continue + call dqrsl(b,nf,nf,k,qraux,eta,eta,work,work,work,work + +,10000,info) + if(tol.lt.sigma(j))then + scale=1.d0/sigma(j) + else + scale=0.d0 + end if + do 17 i1=1,nf + eta(i1)=eta(i1)*(scale*w(i1)) + 17 continue + do 18 i=1,nf + o(l,psi(i))=o(l,psi(i))+g(1,j)*eta(i) + 18 continue + 14 continue + end if + end if + 4 continue + return + end + +C----------------------------------------------------------------------C +C l2tr + subroutine ehg139(v,nvmax,nv,n,d,nf,f,x,pi,psi,y,rw,trl,kernel,k,d + +ist,phi,eta,b,od,w,diagl,vval2,ncmax,vc,a,xi,lo,hi,c,vhit,rcond,si + +ng,dd,tdeg,cdeg,lq,lf,setlf,s) + logical setlf + integer identi,d,dd,execnt,i,i2,i3,i5,i6,ii,ileaf,info,j,k,kernel, + +l,n,nc,ncmax,nf,nleaf,nv,nvmax,od,sing,tdeg,vc + integer lq(nvmax,nf),a(ncmax),c(vc,ncmax),cdeg(8),hi(ncmax),leaf(2 + +56),lo(ncmax),phi(n),pi(n),psi(n),vhit(nvmax) + DOUBLE PRECISION f,i1,i4,i7,rcond,scale,term,tol,trl + DOUBLE PRECISION lf(0:d,nvmax,nf),sigma(15),u(15,15),e(15,15),b(nf + +,k),diagl(n),dist(n),eta(nf),DGAMMA(15),q(8),qraux(15),rw(n),s(0:o + +d,nv),v(nvmax,d),vval2(0:d,nv),w(nf),work(15),x(n,d),xi(ncmax),y(n + +),z(8) + external ehg127,ehg182,DQRSL,ehg137 + DOUBLE PRECISION ehg128 + external ehg128 + DOUBLE PRECISION DDOT + external DDOT + save execnt + data execnt /0/ +c V -> e +c Identity -> identi +c X -> b + execnt=execnt+1 +c l2fit with trace(L) + if(.not.(k.le.nf-1))then + call ehg182(104) + end if + if(.not.(k.le.15))then + call ehg182(105) + end if + if(trl.ne.0)then + do 3 i5=1,n + diagl(i5)=0 + 3 continue + do 4 i6=1,nv + do 5 i5=0,d + vval2(i5,i6)=0 + 5 continue + 4 continue + end if + do 6 identi=1,n + psi(identi)=identi + 6 continue + do 7 l=1,nv + do 8 i5=1,d + q(i5)=v(l,i5) + 8 continue + call ehg127(q,n,d,nf,f,x,psi,y,rw,kernel,k,dist,eta,b,od,w,rcon + +d,sing,sigma,u,e,DGAMMA,qraux,work,tol,dd,tdeg,cdeg,s(0,l)) + if(trl.ne.0)then +c invert $psi$ + do 9 i5=1,n + phi(i5)=0 + 9 continue + do 10 i=1,nf + phi(psi(i))=i + 10 continue + do 11 i5=1,d + z(i5)=v(l,i5) + 11 continue + call ehg137(z,vhit(l),leaf,nleaf,d,nv,nvmax,ncmax,vc,a,xi,lo + +,hi,c,v) + do 12 ileaf=1,nleaf + do 13 ii=lo(leaf(ileaf)),hi(leaf(ileaf)) + i=phi(pi(ii)) + if(i.ne.0)then + if(.not.(psi(i).eq.pi(ii)))then + call ehg182(194) + end if + do 14 i5=1,nf + eta(i5)=0 + 14 continue + eta(i)=w(i) +c $eta = Q sup T W e sub i$ + call DQRSL(b,nf,nf,k,qraux,eta,work,eta,eta,work,wo + +rk,1000,info) + do 15 j=1,k + if(tol.lt.sigma(j))then + i4=DDOT(k,u(1,j),1,eta,1)/sigma(j) + else + i4=0.D0 + end if + DGAMMA(j)=i4 + 15 continue + do 16 j=1,d+1 +c bug fix 2006-07-15 for k=1, od>1. (thanks btyner at gmail.com) + if(j.le.k)then + vval2(j-1,l)=DDOT(k,e(j,1),15,DGAMMA,1) + else + vval2(j-1,l)=0 + end if + 16 continue + do 17 i5=1,d + z(i5)=x(pi(ii),i5) + 17 continue + term=ehg128(z,d,ncmax,vc,a,xi,lo,hi,c,v,nvmax,vval2 + +) + diagl(pi(ii))=diagl(pi(ii))+term + do 18 i5=0,d + vval2(i5,l)=0 + 18 continue + end if + 13 continue + 12 continue + end if + if(setlf)then +c $Lf sub {:,l,:} = V SIGMA sup {+} U sup T Q sup T W$ + if(.not.(k.ge.d+1))then + call ehg182(196) + end if + do 19 i5=1,nf + lq(l,i5)=psi(i5) + 19 continue + do 20 i6=1,nf + do 21 i5=0,d + lf(i5,l,i6)=0 + 21 continue + 20 continue + do 22 j=1,k + do 23 i5=1,nf + eta(i5)=0 + 23 continue + do 24 i5=1,k + eta(i5)=u(i5,j) + 24 continue + call DQRSL(b,nf,nf,k,qraux,eta,eta,work,work,work,work,10 + +000,info) + if(tol.lt.sigma(j))then + scale=1.D0/sigma(j) + else + scale=0.D0 + end if + do 25 i5=1,nf + eta(i5)=eta(i5)*(scale*w(i5)) + 25 continue + do 26 i=1,nf + i7=eta(i) + do 27 i5=0,d + if(i5.lt.k)then + lf(i5,l,i)=lf(i5,l,i)+e(1+i5,j)*i7 + else + lf(i5,l,i)=0 + end if + 27 continue + 26 continue + 22 continue + end if + 7 continue + if(trl.ne.0)then + if(n.le.0)then + trl=0.D0 + else + i3=n + i1=diagl(i3) + do 28 i2=i3-1,1,-1 + i1=diagl(i2)+i1 + 28 continue + trl=i1 + end if + end if + return + end + + +C----------------------------------------------------------------------C + subroutine dqrdc(x,ldx,n,p,qraux,jpvt,work,job) + integer ldx,n,p,job + integer jpvt(1) + double precision x(ldx,1),qraux(1),work(1) +c +c dqrdc uses householder transformations to compute the qr +c factorization of an n by p matrix x. column pivoting +c based on the 2-norms of the reduced columns may be +c performed at the users option. +c +c on entry +c +c x double precision(ldx,p), where ldx .ge. n. +c x contains the matrix whose decomposition is to be +c computed. +c +c ldx integer. +c ldx is the leading dimension of the array x. +c +c n integer. +c n is the number of rows of the matrix x. +c +c p integer. +c p is the number of columns of the matrix x. +c +c jpvt integer(p). +c jpvt contains integers that control the selection +c of the pivot columns. the k-th column x(k) of x +c is placed in one of three classes according to the +c value of jpvt(k). +c +c if jpvt(k) .gt. 0, then x(k) is an initial +c column. +c +c if jpvt(k) .eq. 0, then x(k) is a free column. +c +c if jpvt(k) .lt. 0, then x(k) is a final column. +c +c before the decomposition is computed, initial columns +c are moved to the beginning of the array x and final +c columns to the end. both initial and final columns +c are frozen in place during the computation and only +c free columns are moved. at the k-th stage of the +c reduction, if x(k) is occupied by a free column +c it is interchanged with the free column of largest +c reduced norm. jpvt is not referenced if +c job .eq. 0. +c +c work double precision(p). +c work is a work array. work is not referenced if +c job .eq. 0. +c +c job integer. +c job is an integer that initiates column pivoting. +c if job .eq. 0, no pivoting is done. +c if job .ne. 0, pivoting is done. +c +c on return +c +c x x contains in its upper triangle the upper +c triangular matrix r of the qr factorization. +c below its diagonal x contains information from +c which the orthogonal part of the decomposition +c can be recovered. note that if pivoting has +c been requested, the decomposition is not that +c of the original matrix x but that of x +c with its columns permuted as described by jpvt. +c +c qraux double precision(p). +c qraux contains further information required to recover +c the orthogonal part of the decomposition. +c +c jpvt jpvt(k) contains the index of the column of the +c original matrix that has been interchanged into +c the k-th column, if pivoting was requested. +c +c linpack. this version dated 08/14/78 . +c g.w. stewart, university of maryland, argonne national lab. +c +c dqrdc uses the following functions and subprograms. +c +c blas daxpy,ddot,dscal,dswap,dnrm2 +c fortran dabs,dmax1,min0,dsqrt +c +c internal variables +c + integer j,jp,l,lp1,lup,maxj,pl,pu + double precision maxnrm,dnrm2,tt + double precision ddot,nrmxl,t + logical negj,swapj +c +c + pl = 1 + pu = 0 + if (job .eq. 0) go to 60 +c +c pivoting has been requested. rearrange the columns +c according to jpvt. +c + do 20 j = 1, p + swapj = jpvt(j) .gt. 0 + negj = jpvt(j) .lt. 0 + jpvt(j) = j + if (negj) jpvt(j) = -j + if (.not.swapj) go to 10 + if (j .ne. pl) call dswap(n,x(1,pl),1,x(1,j),1) + jpvt(j) = jpvt(pl) + jpvt(pl) = j + pl = pl + 1 + 10 continue + 20 continue + pu = p + do 50 jj = 1, p + j = p - jj + 1 + if (jpvt(j) .ge. 0) go to 40 + jpvt(j) = -jpvt(j) + if (j .eq. pu) go to 30 + call dswap(n,x(1,pu),1,x(1,j),1) + jp = jpvt(pu) + jpvt(pu) = jpvt(j) + jpvt(j) = jp + 30 continue + pu = pu - 1 + 40 continue + 50 continue + 60 continue +c +c compute the norms of the free columns. +c + if (pu .lt. pl) go to 80 + do 70 j = pl, pu + qraux(j) = dnrm2(n,x(1,j),1) + work(j) = qraux(j) + 70 continue + 80 continue +c +c perform the householder reduction of x. +c + lup = min0(n,p) + do 200 l = 1, lup + if (l .lt. pl .or. l .ge. pu) go to 120 +c +c locate the column of largest norm and bring it +c into the pivot position. +c + maxnrm = 0.0d0 + maxj = l + do 100 j = l, pu + if (qraux(j) .le. maxnrm) go to 90 + maxnrm = qraux(j) + maxj = j + 90 continue + 100 continue + if (maxj .eq. l) go to 110 + call dswap(n,x(1,l),1,x(1,maxj),1) + qraux(maxj) = qraux(l) + work(maxj) = work(l) + jp = jpvt(maxj) + jpvt(maxj) = jpvt(l) + jpvt(l) = jp + 110 continue + 120 continue + qraux(l) = 0.0d0 + if (l .eq. n) go to 190 +c +c compute the householder transformation for column l. +c + nrmxl = dnrm2(n-l+1,x(l,l),1) + if (nrmxl .eq. 0.0d0) go to 180 + if (x(l,l) .ne. 0.0d0) nrmxl = dsign(nrmxl,x(l,l)) + call dscal(n-l+1,1.0d0/nrmxl,x(l,l),1) + x(l,l) = 1.0d0 + x(l,l) +c +c apply the transformation to the remaining columns, +c updating the norms. +c + lp1 = l + 1 + if (p .lt. lp1) go to 170 + do 160 j = lp1, p + t = -ddot(n-l+1,x(l,l),1,x(l,j),1)/x(l,l) + call daxpy(n-l+1,t,x(l,l),1,x(l,j),1) + if (j .lt. pl .or. j .gt. pu) go to 150 + if (qraux(j) .eq. 0.0d0) go to 150 + tt = 1.0d0 - (dabs(x(l,j))/qraux(j))**2 + tt = dmax1(tt,0.0d0) + t = tt + tt = 1.0d0 + 0.05d0*tt*(qraux(j)/work(j))**2 + if (tt .eq. 1.0d0) go to 130 + qraux(j) = qraux(j)*dsqrt(t) + go to 140 + 130 continue + qraux(j) = dnrm2(n-l,x(l+1,j),1) + work(j) = qraux(j) + 140 continue + 150 continue + 160 continue + 170 continue +c +c save the transformation. +c + qraux(l) = x(l,l) + x(l,l) = -nrmxl + 180 continue + 190 continue + 200 continue + return + end + +C---------------------------------------------------------------------C + integer function idamax(n,dx,incx) +c +c finds the index of element having max. absolute value. +c jack dongarra, linpack, 3/11/78. +c + double precision dx(1),dmax + integer i,incx,ix,n +c + idamax = 0 + if( n .lt. 1 ) return + idamax = 1 + if(n.eq.1)return + if(incx.eq.1)go to 20 +c +c code for increment not equal to 1 +c + ix = 1 + dmax = dabs(dx(1)) + ix = ix + incx + do 10 i = 2,n + if(dabs(dx(ix)).le.dmax) go to 5 + idamax = i + dmax = dabs(dx(ix)) + 5 ix = ix + incx + 10 continue + return +c +c code for increment equal to 1 +c + 20 dmax = dabs(dx(1)) + do 30 i = 2,n + if(dabs(dx(i)).le.dmax) go to 30 + idamax = i + dmax = dabs(dx(i)) + 30 continue + return + end + +C----------------------------------------------------------------------C +C build kd tree + subroutine lowesb(xx,yy,ww,diagl,infl,iv,liv,lv,wv) + logical infl,setlf + integer execnt + integer iv(*) + DOUBLE PRECISION trl + DOUBLE PRECISION diagl(*),wv(*),ww(*),xx(*),yy(*) + external ehg131,ehg182,ehg183 + integer ifloor + external ifloor + save execnt + data execnt /0/ + execnt=execnt+1 + if(.not.(iv(28).ne.173))then + call ehg182(174) + end if + if(iv(28).ne.172)then + if(.not.(iv(28).eq.171))then + call ehg182(171) + end if + end if + iv(28)=173 + if(infl)then + trl=1.D0 + else + trl=0.D0 + end if + setlf=(iv(27).ne.iv(25)) + call ehg131(xx,yy,ww,trl,diagl,iv(20),iv(29),iv(3),iv(2),iv(5),iv( + +17),iv(4),iv(6),iv(14),iv(19),wv(1),iv(iv(7)),iv(iv(8)),iv(iv(9)), + +iv(iv(10)),iv(iv(22)),iv(iv(27)),wv(iv(11)),iv(iv(23)),wv(iv(13)), + +wv(iv(12)),wv(iv(15)),wv(iv(16)),wv(iv(18)),ifloor(iv(3)*wv(2)),wv + +(3),wv(iv(26)),wv(iv(24)),wv(4),iv(30),iv(33),iv(32),iv(41),iv(iv( + +25)),wv(iv(34)),setlf) + if(iv(14).lt.iv(6)+DFLOAT(iv(4))/2.D0)then + call ehg183('Warning. k-d tree limited by memory; nvmax=',iv(14 + +),1,1) + else + if(iv(17).lt.iv(5)+2)then + call ehg183('Warning. k-d tree limited by memory. ncmax=',iv + +(17),1,1) + end if + end if + return + end + +C----------------------------------------------------------------------C +C setup workspace + subroutine lowesd(versio,iv,liv,lv,v,d,n,f,ideg,nvmax,setlf) + logical setlf + integer bound,d,execnt,i,i1,i2,ideg,j,liv,lv,n,ncmax,nf,nvmax,vc,v + +ersio + integer iv(liv) + double precision f + double precision v(lv) + external ehg182 + integer ifloor + external ifloor + save execnt + data execnt /0/ +c version -> versio + execnt=execnt+1 + if(.not.(versio.eq.106))then + call ehg182(100) + end if + iv(28)=171 + iv(2)=d + iv(3)=n + vc=2**d + iv(4)=vc + if(.not.(0.lt.f))then + call ehg182(120) + end if + nf=min(n,ifloor(n*f)) + iv(19)=nf + iv(20)=1 + if(ideg.eq.0)then + i1=1 + else + if(ideg.eq.1)then + i1=d+1 + else + if(ideg.eq.2)then + i1=dfloat((d+2)*(d+1))/2.d0 + end if + end if + end if + iv(29)=i1 + iv(21)=1 + iv(14)=nvmax + ncmax=nvmax + iv(17)=ncmax + iv(30)=0 + iv(32)=ideg + if(.not.(ideg.ge.0))then + call ehg182(195) + end if + if(.not.(ideg.le.2))then + call ehg182(195) + end if + iv(33)=d + do 3 i2=41,49 + iv(i2)=ideg + 3 continue + iv(7)=50 + iv(8)=iv(7)+ncmax + iv(9)=iv(8)+vc*ncmax + iv(10)=iv(9)+ncmax + iv(22)=iv(10)+ncmax +c initialize permutation + j=iv(22)-1 + do 4 i=1,n + iv(j+i)=i + 4 continue + iv(23)=iv(22)+n + iv(25)=iv(23)+nvmax + if(setlf)then + iv(27)=iv(25)+nvmax*nf + else + iv(27)=iv(25) + end if + bound=iv(27)+n + if(.not.(bound-1.le.liv))then + call ehg182(102) + end if + iv(11)=50 + iv(13)=iv(11)+nvmax*d + iv(12)=iv(13)+(d+1)*nvmax + iv(15)=iv(12)+ncmax + iv(16)=iv(15)+n + iv(18)=iv(16)+nf + iv(24)=iv(18)+iv(29)*nf + iv(34)=iv(24)+(d+1)*nvmax + if(setlf)then + iv(26)=iv(34)+(d+1)*nvmax*nf + else + iv(26)=iv(34) + end if + bound=iv(26)+nf + if(.not.(bound-1.le.lv))then + call ehg182(103) + end if + v(1)=f + v(2)=0.05d0 + v(3)=0.d0 + v(4)=1.d0 + return + end + +C----------------------------------------------------------------------C +C evaluate smooth at z + subroutine lowese(iv,liv,lv,wv,m,z,s) + integer execnt,m + integer iv(*) + double precision s(m),wv(*),z(m,1) + external ehg133,ehg182 + save execnt + data execnt /0/ + execnt=execnt+1 + if(.not.(iv(28).ne.172))then + call ehg182(172) + end if + if(.not.(iv(28).eq.173))then + call ehg182(173) + end if + call ehg133(iv(3),iv(2),iv(4),iv(14),iv(5),iv(17),iv(iv(7)),iv(iv( + +8)),iv(iv(9)),iv(iv(10)),wv(iv(11)),wv(iv(13)),wv(iv(12)),m,z,s) + return + end + +C----------------------------------------------------------------------C +C slow smooth at z + subroutine lowesf(xx,yy,ww,iv,liv,lv,wv,m,z,l,ihat,s) + logical i1 + integer execnt,ihat,m,n + integer iv(*) + double precision l(m,*),s(m),wv(*),ww(*),xx(*),yy(*),z(m,1) + external ehg182,ehg136 + save execnt + data execnt /0/ + execnt=execnt+1 + if(171.le.iv(28))then + i1=(iv(28).le.174) + else + i1=.false. + end if + if(.not.i1)then + call ehg182(171) + end if + iv(28)=172 + if(.not.(iv(14).ge.iv(19)))then + call ehg182(186) + end if + call ehg136(z,m,m,iv(3),iv(2),iv(19),wv(1),xx,iv(iv(22)),yy,ww,iv( + +20),iv(29),wv(iv(15)),wv(iv(16)),wv(iv(18)),0,l,ihat,wv(iv(26)),wv + +(4),iv(30),iv(33),iv(32),iv(41),s) + return + end + +C----------------------------------------------------------------------C +C explicit hat matrix mapping y to z + subroutine lowesl(iv,liv,lv,wv,m,z,l) + integer execnt,m,n + integer iv(*) + double precision l(m,*),wv(*),z(m,1) + external ehg182,ehg191 + save execnt + data execnt /0/ + execnt=execnt+1 + if(.not.(iv(28).ne.172))then + call ehg182(172) + end if + if(.not.(iv(28).eq.173))then + call ehg182(173) + end if + if(.not.(iv(26).ne.iv(34)))then + call ehg182(175) + end if + call ehg191(m,z,l,iv(2),iv(3),iv(19),iv(6),iv(17),iv(4),iv(iv(7)), + +wv(iv(12)),iv(iv(10)),iv(iv(9)),iv(iv(8)),wv(iv(11)),iv(14),wv(iv( + +24)),wv(iv(34)),iv(iv(25))) + return + end + +C----------------------------------------------------------------------C +C rebuild with new data values (does not change y) + subroutine lowesr(yy,iv,liv,lv,wv) + integer execnt + integer iv(*) + DOUBLE PRECISION wv(*),yy(*) + external ehg182,ehg192 + save execnt + data execnt /0/ + execnt=execnt+1 + if(.not.(iv(28).ne.172))then + call ehg182(172) + end if + if(.not.(iv(28).eq.173))then + call ehg182(173) + end if + call ehg192(yy,iv(2),iv(3),iv(19),iv(6),iv(14),wv(iv(13)),wv(iv(34 + +)),iv(iv(25))) + return + end + +C----------------------------------------------------------------------C +C robustness weights + subroutine lowesw(res,n,rw,pi) + integer identi,execnt,i,i1,n,nh + integer pi(n) + double precision cmad,rsmall + double precision res(n),rw(n) + external ehg106 + integer ifloor + external ifloor + double precision d1mach + external d1mach + save execnt + data execnt /0/ +c Identity -> identi + execnt=execnt+1 +c tranliterated from Devlin's ratfor +c find median of absolute residuals + do 3 i1=1,n + rw(i1)=dabs(res(i1)) + 3 continue + do 4 identi=1,n + pi(identi)=identi + 4 continue + nh=ifloor(dfloat(n)/2.d0)+1 +c partial sort to find 6*mad + call ehg106(1,n,nh,1,rw,pi,n) + if((n-nh)+1.lt.nh)then + call ehg106(1,nh-1,nh-1,1,rw,pi,n) + cmad=3*(rw(pi(nh))+rw(pi(nh-1))) + else + cmad=6*rw(pi(nh)) + end if + rsmall=d1mach(1) + if(cmad.lt.rsmall)then + do 5 i1=1,n + rw(i1)=1 + 5 continue + else + do 6 i=1,n + if(cmad*0.999d0.lt.rw(i))then + rw(i)=0 + else + if(cmad*0.001d0.lt.rw(i))then + rw(i)=(1-(rw(i)/cmad)**2)**2 + else + rw(i)=1 + end if + end if + 6 continue + end if + return + end + +C----------------------------------------------------------------------C +C pseudovalues + subroutine lowesp(n,y,yhat,pwgts,rwgts,pi,ytilde) + integer identi,execnt,i2,i3,i5,m,n + integer pi(n) + double precision c,i1,i4,mad + double precision pwgts(n),rwgts(n),y(n),yhat(n),ytilde(n) + external ehg106 + integer ifloor + external ifloor + save execnt + data execnt /0/ +c Identity -> identi + execnt=execnt+1 +c median absolute deviation + do 3 i5=1,n + ytilde(i5)=dabs(y(i5)-yhat(i5))*dsqrt(pwgts(i5)) + 3 continue + do 4 identi=1,n + pi(identi)=identi + 4 continue + m=ifloor(dfloat(n)/2.d0)+1 + call ehg106(1,n,m,1,ytilde,pi,n) + if((n-m)+1.lt.m)then + call ehg106(1,m-1,m-1,1,ytilde,pi,n) + mad=(ytilde(pi(m-1))+ytilde(pi(m)))/2 + else + mad=ytilde(pi(m)) + end if +c magic constant + c=(6*mad)**2/5 + do 5 i5=1,n + ytilde(i5)=1-((y(i5)-yhat(i5))**2*pwgts(i5))/c + 5 continue + do 6 i5=1,n + ytilde(i5)=ytilde(i5)*dsqrt(rwgts(i5)) + 6 continue + if(n.le.0)then + i4=0.d0 + else + i3=n + i1=ytilde(i3) + do 7 i2=i3-1,1,-1 + i1=ytilde(i2)+i1 + 7 continue + i4=i1 + end if + c=n/i4 +c pseudovalues + do 8 i5=1,n + ytilde(i5)=yhat(i5)+(c*rwgts(i5))*(y(i5)-yhat(i5)) + 8 continue + return + end + +C----------------------------------------------------------------------C +C rbuild + subroutine ehg124(ll,uu,d,n,nv,nc,ncmax,vc,x,pi,a,xi,lo,hi,c,v,vhi + +t,nvmax,fc,fd,dd) + logical i1,i2,i3,leaf + integer d,dd,execnt,fc,i4,inorm2,k,l,ll,m,n,nc,ncmax,nv,nvmax,p,u, + +uu,vc,lower,upper,check,offset + integer a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax),pi(n),vhit(nvmax) + DOUBLE PRECISION diam,fd + DOUBLE PRECISION diag(8),sigma(8),v(nvmax,d),x(n,d),xi(ncmax) + external ehg125,ehg106,ehg129 + integer IDAMAX + external IDAMAX + save execnt + data execnt /0/ + execnt=execnt+1 + p=1 + l=ll + u=uu + lo(p)=l + hi(p)=u +c top of while loop + 3 if(.not.(p.le.nc))goto 4 + do 5 i4=1,dd + diag(i4)=v(c(vc,p),i4)-v(c(1,p),i4) + 5 continue + diam=0 + do 6 inorm2=1,dd + diam=diam+diag(inorm2)**2 + 6 continue + diam=DSQRT(diam) + if((u-l)+1.le.fc)then + i1=.true. + else + i1=(diam.le.fd) + end if + if(i1)then + leaf=.true. + else + if(ncmax.lt.nc+2)then + i2=.true. + else + i2=(nvmax.lt.nv+DFLOAT(vc)/2.D0) + end if + leaf=i2 + end if + if(.not.leaf)then + call ehg129(l,u,dd,x,pi,n,sigma) + k=IDAMAX(dd,sigma,1) + m=DFLOAT(l+u)/2.D0 + call ehg106(l,u,m,1,x(1,k),pi,n) + +c bug fix from btyner at gmail.com 2006-07-20 + offset = 0 + 7 if(((m+offset).ge.u).or.((m+offset).lt.l))then + goto 8 + else + if(offset.lt.0)then + lower = l + check = m + offset + upper = check + else + lower = m + offset + 1 + check = lower + upper = u + end if + call ehg106(lower,upper,check,1,x(1,k),pi,n) + if(x(pi(m + offset),k).eq.x(pi(m+offset+1),k))then + offset = (-offset) + if(offset.ge.0)then + offset = offset + 1 + end if + goto 7 + else + m = m + offset + goto 8 + end if + end if + + 8 if(v(c(1,p),k).eq.x(pi(m),k))then + leaf=.true. + else + leaf=(v(c(vc,p),k).eq.x(pi(m),k)) + end if + end if + if(leaf)then + a(p)=0 + else + a(p)=k + xi(p)=x(pi(m),k) +c left son + nc=nc+1 + lo(p)=nc + lo(nc)=l + hi(nc)=m +c right son + nc=nc+1 + hi(p)=nc + lo(nc)=m+1 + hi(nc)=u + call ehg125(p,nv,v,vhit,nvmax,d,k,xi(p),2**(k-1),2**(d-k),c( + +1,p),c(1,lo(p)),c(1,hi(p))) + end if + p=p+1 + l=lo(p) + u=hi(p) + goto 3 +c bottom of while loop + 4 return + end + +C----------------------------------------------------------------------C +C spread + subroutine ehg129(l,u,d,x,pi,n,sigma) + integer d,execnt,i,k,l,n,u + integer pi(n) + DOUBLE PRECISION machin,alpha,beta,t + DOUBLE PRECISION sigma(d),x(n,d) + DOUBLE PRECISION D1MACH + external D1MACH + save machin,execnt + data execnt /0/ +c MachInf -> machin + execnt=execnt+1 + if(execnt.eq.1)then + machin=D1MACH(2) + end if + do 3 k=1,d + alpha=machin + beta=-machin + do 4 i=l,u + t=x(pi(i),k) + alpha=min(alpha,x(pi(i),k)) + beta=max(beta,t) + 4 continue + sigma(k)=beta-alpha + 3 continue + return + end + +C----------------------------------------------------------------------C +C vleaf + subroutine ehg137(z,kappa,leaf,nleaf,d,nv,nvmax,ncmax,vc,a,xi,lo,h + +i,c,v) + integer d,execnt,nc,ncmax,nleaf,p,stackt + integer a(ncmax),hi(ncmax),leaf(256),lo(ncmax),pstack(20) + DOUBLE PRECISION xi(ncmax),z(d) + external ehg182 + save execnt + data execnt /0/ +c stacktop -> stackt + execnt=execnt+1 +c find leaf cells affected by $z$ + stackt=0 + p=1 + nleaf=0 +c top of while loop + 3 if(.not.(0.lt.p))goto 4 + if(a(p).eq.0)then +c leaf + nleaf=nleaf+1 + leaf(nleaf)=p +c Pop + if(stackt.ge.1)then + p=pstack(stackt) + else + p=0 + end if + stackt=max(0,stackt-1) + else + if(z(a(p)).eq.xi(p))then +c Push + stackt=stackt+1 + if(.not.(stackt.le.20))then + call ehg182(187) + end if + pstack(stackt)=hi(p) + p=lo(p) + else + if(z(a(p)).le.xi(p))then + p=lo(p) + else + p=hi(p) + end if + end if + end if + goto 3 +c bottom of while loop + 4 if(.not.(nleaf.le.256))then + call ehg182(185) + end if + return + end Added: trunk/Lib/sandbox/pyloess/src/misc.c =================================================================== --- trunk/Lib/sandbox/pyloess/src/misc.c 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/misc.c 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,316 @@ +#include "S.h" +#include "loess.h" +#include +#include + +static double fmin(double a, double b) +{ + return(a < b ? a : b); +} + +static double fmax(double a, double b) +{ + return(a > b ? a : b); +} + + +void anova(loess *one, loess *two, anova_struct *out) +{ + double one_d1, one_d2, one_s, two_d1, two_d2, two_s, + rssdiff, d1diff, tmp, pf(); + int max_enp; + + one_d1 = one->outputs.one_delta; + one_d2 = one->outputs.two_delta; + one_s = one->outputs.s; + two_d1 = two->outputs.one_delta; + two_d2 = two->outputs.two_delta; + two_s = two->outputs.s; + + rssdiff = fabs(one_s * one_s * one_d1 - two_s * two_s * two_d1); + d1diff = fabs(one_d1 - two_d1); + out->dfn = d1diff * d1diff / fabs(one_d2 - two_d2); + max_enp = (one->outputs.enp > two->outputs.enp); + tmp = max_enp ? one_d1 : two_d1; + out->dfd = tmp * tmp / (max_enp ? one_d2 : two_d2); + tmp = max_enp ? one_s : two_s; + out->F_value = (rssdiff / d1diff) / (tmp * tmp); + out->Pr_F = 1 - pf(out->F_value, out->dfn, out->dfd); +} + +void pointwise(prediction *pre, int m, double coverage, conf_inv *ci) +{ + double t_dist, limit, fit, qt(); + int i; + + ci->fit = (double *) malloc(m * sizeof(double)); + ci->upper = (double *) malloc(m * sizeof(double)); + ci->lower = (double *) malloc(m * sizeof(double)); + + t_dist = qt(1 - (1 - coverage)/2, pre->df); + for(i = 0; i < m; i++) { + limit = pre->se_fit[i] * t_dist; + ci->fit[i] = fit = pre->fit[i]; + ci->upper[i] = fit + limit; + ci->lower[i] = fit - limit; + } +} + +void pw_free_mem(conf_inv *ci) +{ + free(ci->fit); + free(ci->upper); + free(ci->lower); +} + +double pf(double q, double df1, double df2) +{ + double ibeta(); + return(ibeta(q*df1/(df2+q*df1), df1/2, df2/2)); +} + +double qt(double p, double df) +{ + double t, invibeta(); + t = invibeta(fabs(2*p-1), 0.5, df/2); + return((p>0.5?1:-1) * sqrt(t*df/(1-t))); +} + +/**********************************************************************/ + /* + * Incomplete beta function. + * Reference: Abramowitz and Stegun, 26.5.8. + * Assumptions: 0 <= x <= 1; a,b > 0. + */ +#define DOUBLE_EPS 2.2204460492503131E-16 +#define IBETA_LARGE 1.0e30 +#define IBETA_SMALL 1.0e-30 + +double ibeta(double x, double a, double b) +{ + int flipped = 0, i, k, count; + double I, temp, pn[6], ak, bk, next, prev, factor, val; + + if (x <= 0) + return(0); + if (x >= 1) + return(1); + + /* use ibeta(x,a,b) = 1-ibeta(1-x,b,a) */ + if ((a+b+1)*x > (a+1)) { + flipped = 1; + temp = a; + a = b; + b = temp; + x = 1 - x; + } + + pn[0] = 0.0; + pn[2] = pn[3] = pn[1] = 1.0; + count = 1; + val = x/(1.0-x); + bk = 1.0; + next = 1.0; + do { + count++; + k = count/2; + prev = next; + if (count%2 == 0) + ak = -((a+k-1.0)*(b-k)*val)/((a+2.0*k-2.0)*(a+2.0*k-1.0)); + else + ak = ((a+b+k-1.0)*k*val)/((a+2.0*k)*(a+2.0*k-1.0)); + pn[4] = bk*pn[2] + ak*pn[0]; + pn[5] = bk*pn[3] + ak*pn[1]; + next = pn[4] / pn[5]; + for (i=0; i<=3; i++) + pn[i] = pn[i+2]; + if (fabs(pn[4]) >= IBETA_LARGE) + for (i=0; i<=3; i++) + pn[i] /= IBETA_LARGE; + if (fabs(pn[4]) <= IBETA_SMALL) + for (i=0; i<=3; i++) + pn[i] /= IBETA_SMALL; + } while (fabs(next-prev) > DOUBLE_EPS*prev); + factor = a*log(x) + (b-1)*log(1-x); + factor -= gamma(a+1) + gamma(b) - gamma(a+b); + I = exp(factor) * next; + return(flipped ? 1-I : I); +} + +/* + * Rational approximation to inverse Gaussian distribution. + * Absolute error is bounded by 4.5e-4. + * Reference: Abramowitz and Stegun, page 933. + * Assumption: 0 < p < 1. + */ + +static double num[] = { + 2.515517, + 0.802853, + 0.010328 +}; + +static double den[] = { + 1.000000, + 1.432788, + 0.189269, + 0.001308 +}; + +double invigauss_quick(double p) +{ + int lower; + double t, n, d, q; + + if(p == 0.5) + return(0); + lower = p < 0.5; + p = lower ? p : 1 - p; + t = sqrt(-2 * log(p)); + n = (num[2]*t + num[1])*t + num[0]; + d = ((den[3]*t + den[2])*t + den[1])*t + den[0]; + q = lower ? n/d - t : t - n/d; + return(q); +} + +/* + * Inverse incomplete beta function. + * Assumption: 0 <= p <= 1, a,b > 0. + */ + +double invibeta(double p, double a, double b) +{ + int i; + double ql, qr, qm, qdiff; + double pl, pr, pm, pdiff; + double invibeta_quick(), ibeta(); + +/* MEANINGFUL(qm);*/ + qm = 0; + if(p == 0 || p == 1) + return(p); + + /* initialize [ql,qr] containing the root */ + ql = qr = invibeta_quick(p, a, b); + pl = pr = ibeta(ql, a, b); + if(pl == p) + return(ql); + if(pl < p) + while(1) { + qr += 0.05; + if(qr >= 1) { + pr = qr = 1; + break; + } + pr = ibeta(qr, a, b); + if(pr == p) + return(pr); + if(pr > p) + break; + } + else + while(1) { + ql -= 0.05; + if(ql <= 0) { + pl = ql = 0; + break; + } + pl = ibeta(ql, a, b); + if(pl == p) + return(pl); + if(pl < p) + break; + } + + /* a few steps of bisection */ + for(i = 0; i < 5; i++) { + qm = (ql + qr) / 2; + pm = ibeta(qm, a, b); + qdiff = qr - ql; + pdiff = pm - p; + if(fabs(qdiff) < DOUBLE_EPS*qm || fabs(pdiff) < DOUBLE_EPS) + return(qm); + if(pdiff < 0) { + ql = qm; + pl = pm; + } else { + qr = qm; + pr = pm; + } + } + + /* a few steps of secant */ + for(i = 0; i < 40; i++) { + qm = ql + (p-pl)*(qr-ql)/(pr-pl); + pm = ibeta(qm, a, b); + qdiff = qr - ql; + pdiff = pm - p; + if(fabs(qdiff) < 2*DOUBLE_EPS*qm || fabs(pdiff) < 2*DOUBLE_EPS) + return(qm); + if(pdiff < 0) { + ql = qm; + pl = pm; + } else { + qr = qm; + pr = pm; + } + } + + /* no convergence */ + return(qm); +} + +/* + * Quick approximation to inverse incomplete beta function, + * by matching first two moments with the Gaussian distribution. + * Assumption: 0 < p < 1, a,b > 0. + */ + +double invibeta_quick(double p, double a, double b) +{ + double x, m, s, fmax(), fmin(), invigauss_quick(); + + x = a + b; + m = a / x; + s = sqrt((a*b) / (x*x*(x+1))); + return(fmax(0.0, fmin(1.0, invigauss_quick(p)*s + m))); +} + +int max(int a, int b) +{ + return(a > b ? a : b); +} + +typedef double doublereal; +typedef int integer; + +void Recover(char *a, int *b) +{ + printf(a); + exit(1); +} + +void Warning(char *a, int *b) +{ + printf(a); +} + +/* d1mach may be replaced by Fortran code: + mail netlib at netlib.bell-labs.com + send d1mach from core. +*/ + +#include + +doublereal F77_SUB(d1mach) (integer *i) +{ +switch(*i){ + case 1: return DBL_MIN; + case 2: return DBL_MAX; + case 3: return DBL_EPSILON/FLT_RADIX; + case 4: return DBL_EPSILON; + case 5: return log10(FLT_RADIX); + default: Recover("Invalid argument to d1mach()", 0L); + } +} + Added: trunk/Lib/sandbox/pyloess/src/predict.c =================================================================== --- trunk/Lib/sandbox/pyloess/src/predict.c 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/src/predict.c 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,187 @@ +#include "S.h" +#include "loess.h" +#include +#include + + +extern char *error_message; +extern int error_status; + +void +predict(double *eval, int m, loess *lo, prediction *pre, int se) +{ + int size_info[3]; + void pred_(); + + pre->fit = (double *) malloc(m * sizeof(double)); + pre->se_fit = (double *) malloc(m * sizeof(double)); + pre->residual_scale = lo->outputs.s; + pre->df = (lo->outputs.one_delta * lo->outputs.one_delta) / + lo->outputs.two_delta; + + size_info[0] = lo->inputs.p; + size_info[1] = lo->inputs.n; + size_info[2] = m; + + error_status = 0; + lo->status.err_status = 0; + lo->status.err_msg = NULL; + + pred_(lo->inputs.y, + lo->inputs.x, eval, + size_info, + &lo->outputs.s, + lo->inputs.weights, + lo->outputs.robust, + &lo->model.span, + &lo->model.degree, + &lo->model.normalize, + lo->model.parametric, + lo->model.drop_square, + &lo->control.surface, + &lo->control.cell, + &lo->model.family, + lo->kd_tree.parameter, + lo->kd_tree.a, + lo->kd_tree.xi, + lo->kd_tree.vert, + lo->kd_tree.vval, + lo->outputs.divisor, + &se, + pre->fit, + pre->se_fit); + + if(error_status){ + lo->status.err_status = error_status; + lo->status.err_msg = error_message; + } +} + +void +pred_(double *y, double *x_, double *new_x, int *size_info, double *s, + double *weights, double *robust, double *span, int *degree, + int *normalize, int *parametric, int *drop_square, char **surface, + double *cell, char **family, int *parameter, int *a, double *xi, + double *vert, double *vval, double *divisor, int *se, double *fit, + double *se_fit) +{ + double *x, *x_tmp, *x_evaluate, *L, new_cell, z, tmp, *fit_tmp, + *temp, sum, mean; + int N, D, M, sum_drop_sqr = 0, sum_parametric = 0, + nonparametric = 0, *order_parametric, *order_drop_sqr; + int i, j, k, p, cut, comp(); + + D = size_info[0]; + N = size_info[1]; + M = size_info[2]; + + x = (double *) malloc(N * D * sizeof(double)); + x_tmp = (double *) malloc(N * D * sizeof(double)); + x_evaluate = (double *) malloc(M * D * sizeof(double)); + L = (double *) malloc(N * M * sizeof(double)); + order_parametric = (int *) malloc(D * sizeof(int)); + order_drop_sqr = (int *) malloc(D * sizeof(int)); + temp = (double *) malloc(N * D * sizeof(double)); + + for(i = 0; i < (N * D); i++) + x_tmp[i] = x_[i]; + for(i = 0; i < D; i++) { + k = i * M; + for(j = 0; j < M; j++) { + p = k + j; + new_x[p] = new_x[p] / divisor[i]; + } + } + if(!strcmp(*surface, "direct") || se) { + for(i = 0; i < D; i++) { + k = i * N; + for(j = 0; j < N; j++) { + p = k + j; + x_tmp[p] = x_[p] / divisor[i]; + } + } + } + j = D - 1; + for(i = 0; i < D; i++) { + sum_drop_sqr = sum_drop_sqr + drop_square[i]; + sum_parametric = sum_parametric + parametric[i]; + if(parametric[i]) + order_parametric[j--] = i; + else + order_parametric[nonparametric++] = i; + } + for(i = 0; i < D; i++) { + order_drop_sqr[i] = 2 - drop_square[order_parametric[i]]; + k = i * M; + p = order_parametric[i] * M; + for(j = 0; j < M; j++) + x_evaluate[k + j] = new_x[p + j]; + k = i * N; + p = order_parametric[i] * N; + for(j = 0; j < N; j++) + x[k + j] = x_tmp[p + j]; + } + for(i = 0; i < N; i++) + robust[i] = weights[i] * robust[i]; + + if(!strcmp(*surface, "direct")) { + if(*se) { + loess_dfitse(y, x, x_evaluate, weights, robust, + !strcmp(*family, "gaussian"), span, degree, + &nonparametric, order_drop_sqr, &sum_drop_sqr, + &D, &N, &M, fit, L); + } + else { + loess_dfit(y, x, x_evaluate, robust, span, degree, + &nonparametric, order_drop_sqr, &sum_drop_sqr, + &D, &N, &M, fit); + } + } + else { + loess_ifit(parameter, a, xi, vert, vval, &M, x_evaluate, fit); + if(*se) { + new_cell = (*span) * (*cell); + fit_tmp = (double *) malloc(M * sizeof(double)); + loess_ise(y, x, x_evaluate, weights, span, degree, + &nonparametric, order_drop_sqr, &sum_drop_sqr, + &new_cell, &D, &N, &M, fit_tmp, L); + free(fit_tmp); + } + } + if(*se) { + for(i = 0; i < N; i++) { + k = i * M; + for(j = 0; j < M; j++) { + p = k + j; + L[p] = L[p] / weights[i]; + L[p] = L[p] * L[p]; + } + } + for(i = 0; i < M; i++) { + tmp = 0; + for(j = 0; j < N; j++) + tmp = tmp + L[i + j * M]; + se_fit[i] = (*s) * sqrt(tmp); + } + } + free(x); + free(x_tmp); + free(x_evaluate); + free(L); + free(order_parametric); + free(order_drop_sqr); + free(temp); +} + +void +pred_free_mem(prediction *pre) +{ + free(pre->fit); + free(pre->se_fit); +} + + + + + + Added: trunk/Lib/sandbox/pyloess/tests/gas_data =================================================================== --- trunk/Lib/sandbox/pyloess/tests/gas_data 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/tests/gas_data 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,3 @@ +E (observations) +0.831000 1.045000 1.021000 0.970000 0.825000 0.891000 0.710000 0.801000 1.074000 1.148000 1.000000 0.928000 0.767000 0.701000 0.807000 0.902000 0.997000 1.224000 1.089000 0.973000 0.980000 0.665000 NOx (response) +4.818000 2.849000 3.275000 4.691000 4.255000 5.064000 2.118000 4.602000 2.286000 0.970000 3.965000 5.344000 3.834000 1.990000 5.199000 5.283000 3.752000 0.537000 1.640000 5.055000 4.937000 1.561000 \ No newline at end of file Added: trunk/Lib/sandbox/pyloess/tests/gas_result =================================================================== --- trunk/Lib/sandbox/pyloess/tests/gas_result 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/tests/gas_result 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,10 @@ +loess(&gas): +4.883437 2.927639 3.572746 4.710510 4.815363 5.196193 2.512832 4.474939 2.149797 0.990044 4.089353 5.303627 3.864174 2.267121 4.575636 5.240293 4.154036 0.523682 1.853026 4.659184 4.521148 1.196414 +loess(&gas_null): +4.892690 3.362733 3.728575 4.489023 4.831715 5.177112 2.535887 4.530370 2.873000 1.453502 4.059136 5.052650 3.943568 2.265232 4.614320 5.163913 4.107184 -0.276342 2.604373 4.445040 4.351615 1.051719 +predict(gas_fit_E, m, &gas, &gas_pred, 0): +1.196414 5.068747 0.523682 +pointwise(&gas_pred, m, coverage, &gas_ci): +0.407208 1.196414 1.985621 3.249187 3.679498 4.109808 4.631187 5.055708 5.480229 4.704010 5.135260 5.566510 2.759703 3.143656 3.527609 0.683247 1.196932 1.710617 -0.424684 0.523682 1.472049 +anova(&gas_null, &gas, &gas_anova): +2.5531 15.663 10.1397 0.000860102 Added: trunk/Lib/sandbox/pyloess/tests/madeup_data =================================================================== --- trunk/Lib/sandbox/pyloess/tests/madeup_data 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/tests/madeup_data 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,4 @@ +one_two (observations) +-0.957581 -2.809549 -0.696511 3.451000 0.509260 0.557854 0.052582 -2.050644 -1.115675 -1.183665 0.511959 0.334364 -2.057062 -0.121897 0.544238 0.600502 0.531074 0.495400 -1.608602 0.277371 0.290464 0.579894 -0.290441 1.306226 -0.482898 -0.716423 0.742413 -0.911613 1.279436 -0.189153 0.592293 0.952416 0.491436 -0.305681 -0.363871 -0.285424 -0.037209 -0.923529 1.138054 -1.331223 0.551234 -0.852726 1.196875 0.498782 0.320180 0.212447 1.009358 -0.900989 1.132164 0.018867 0.424170 -0.198621 0.955170 0.948321 0.473848 -0.699121 -0.612853 0.580431 1.277996 0.806797 -1.038559 1.008663 -0.578257 -0.323245 -0.756302 1.386352 0.722419 -1.216078 -0.498280 0.726247 -0.260119 -0.741135 -0.184111 0.307762 0.464568 -0.252531 -0.486504 0.426634 -1.303969 0.067149 1.771176 0.907249 0.432350 1.419897 -0.413389 2.442025 0.041138 0.509505 -0.282744 0.179882 -1.188083 0.982653 -1.042886 1.181365 -0.398340 -1.335565 -0.502790 0.484762 -0.806446 1.412077 -0.878874 -0.935197 -0.339255 0.164497 1.370018 -1.494684 1.380505 0.885084 0.835609 0.896235 -1.289541 0.233203 1.183198 -0.857934 -1.334234 -0.923351 0.769146 -0.377948 0.059114 -1.870615 -0.677868 0.038185 0.375301 0.964717 0.695051 -0.342140 -1.145463 -0.993246 -0.130573 1.213711 0.291241 1.106891 0.949571 0.463675 0.455723 0.398786 -0.015849 -1.397373 0.770062 0.083291 0.531798 0.049727 -0.734140 -0.963487 0.573561 -0.281942 -0.594503 0.770262 1.073983 -0.615706 -0.084794 -0.491630 -1.526969 -0.196881 0.165653 0.198357 0.974930 -0.954848 0.588474 -0.426883 0.177119 -0.916442 -1.885139 0.086894 0.456306 0.174285 -0.001308 -0.000585 0.284023 -0.365679 -0.548867 0.857848 0.699094 -0.140026 1.332454 1.601795 0.012415 0.243429 1.077369 1.859246 0.185910 0.033342 0.613008 1.068595 -0.683305 -0.128826 -1.655525 0.013086 0.062454 0.773042 0.127046 0.408652 1.195438 -0.185558 -1.299714 0.899675 -0.033648 -1.544602 0.655203 -0.713935 +response +14.453553 6.622825 13.671414 14.197518 12.860530 12.522856 14.214638 7.924264 12.506938 13.734205 14.710855 13.596223 5.890019 13.558654 14.043167 13.931391 13.218920 17.090560 15.199322 13.261667 15.760636 12.083855 14.344907 12.609494 11.932959 13.408674 13.700765 13.013366 15.794999 14.600198 16.275751 11.564349 14.809023 12.982361 15.003502 14.737337 15.747677 11.674508 14.047278 14.666917 13.806240 13.611149 13.347149 14.225152 14.718846 14.217216 14.418058 14.719634 12.799716 13.933038 15.264603 14.660387 9.738691 14.443424 14.417284 15.184538 13.344938 15.372943 13.811554 15.103777 15.383834 14.368612 12.525202 14.325033 15.259658 13.004547 14.515988 15.176982 14.924187 13.872430 15.395366 13.428076 15.203430 14.186631 13.305833 14.074624 14.103092 13.499669 11.584675 14.264891 14.885616 13.967297 16.604680 10.367606 14.743473 16.308827 14.108673 13.590988 14.674546 15.294047 14.686723 13.611422 11.970270 13.884157 15.071776 12.589816 13.818745 14.245317 14.406530 14.347941 \ No newline at end of file Added: trunk/Lib/sandbox/pyloess/tests/madeup_result =================================================================== --- trunk/Lib/sandbox/pyloess/tests/madeup_result 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/tests/madeup_result 2007-03-21 22:53:54 UTC (rev 2863) @@ -0,0 +1,16 @@ +loess(&madeup): +13.898675 5.225583 14.265096 14.237045 13.366442 13.157273 14.189032 7.971348 13.215581 12.835208 13.967757 14.457845 6.039091 14.722007 13.758002 14.654508 14.243303 14.733353 13.696778 12.510036 15.026972 14.346972 14.547927 11.702517 14.222303 14.288345 13.755227 13.742749 14.250887 14.188543 14.388616 12.552611 14.100045 14.552719 14.514971 14.556744 14.496872 12.868609 12.871890 14.427522 14.410413 14.598345 13.415146 14.731999 14.657565 14.778805 13.988940 13.723749 11.932352 14.908485 14.457978 14.616147 11.100703 14.254687 14.411890 14.519007 13.734456 14.634786 13.080897 14.415189 14.623631 13.340049 12.584224 14.510466 14.293842 13.954341 14.281046 14.643596 14.492646 14.497077 14.497688 13.732467 14.573564 14.548255 13.560984 13.917026 14.496924 14.452028 11.687567 13.865395 13.908958 14.184016 14.514209 10.835782 14.203921 15.273614 13.702645 14.383224 14.506619 14.707063 14.595778 13.877506 12.326903 14.236236 13.962165 12.281695 14.477443 13.192765 13.985441 13.206705 +loess(&madeup_new): +12.874079 10.889912 14.072472 14.688408 13.581655 13.741506 12.966195 11.778153 12.623840 12.391277 13.915575 14.549806 10.648311 13.714716 13.908051 14.338239 13.839956 14.661187 14.500423 12.892713 14.344422 14.557473 14.294094 14.258892 13.410545 14.058327 14.340850 12.675257 14.839750 12.706903 14.551439 14.002773 13.589104 14.094192 14.098484 14.246415 14.548803 11.925623 14.212327 14.501013 14.199258 14.517379 15.151176 14.202325 14.044125 14.549456 15.030205 12.957176 14.170346 14.166684 14.617600 14.160491 14.230993 14.821136 14.547624 14.489024 12.630700 14.292239 14.381246 14.834949 14.480650 14.747398 11.611371 14.519760 13.997474 14.591257 14.591759 14.478131 14.427821 14.785485 14.034793 12.821834 13.556879 14.606041 13.505266 12.561710 14.525273 14.555914 11.728344 13.296039 14.621341 14.570526 14.015254 14.451527 13.670446 15.113971 12.849321 14.570355 14.526773 13.616773 14.493652 14.496696 11.739043 14.886699 12.740301 12.265455 14.504240 13.584999 13.370259 15.378514 +loess(&madeup_new) (family = symmetric): +13.853372 13.076392 14.410502 14.317606 13.530344 13.909561 13.483542 13.661465 13.738437 13.662424 14.078653 14.471725 13.362504 14.161261 14.056621 14.370400 13.827138 14.543779 14.563051 13.263340 14.405462 14.511807 14.391442 13.655949 13.919863 14.406599 14.307597 13.717301 14.561751 13.479815 14.423533 13.588048 13.644027 14.268385 14.283955 14.361030 14.528760 13.151054 13.826620 14.570806 14.120641 14.538117 14.640103 14.309962 14.069715 14.527437 14.606612 13.824681 13.607361 14.370144 14.535820 14.399329 14.122194 14.580712 14.478250 14.541334 13.593458 14.346338 14.016117 14.580121 14.566098 14.522580 12.578184 14.528995 14.305679 14.422916 14.523434 14.533691 14.490958 14.574831 14.352653 13.714577 13.911857 14.540189 13.522831 13.495538 14.528432 14.462617 13.481391 13.705501 14.399779 14.509204 14.010568 13.623165 14.211318 14.586042 13.392231 14.520972 14.525897 13.822231 14.577431 14.267078 13.423198 14.589490 13.573646 13.655627 14.531561 13.811793 13.979165 14.705119 +loess(&madeup_new) (normalize = FALSE): +13.853372 13.076392 14.410502 14.317606 13.530344 13.909561 13.483542 13.661465 13.738437 13.662424 14.078653 14.471725 13.362504 14.161261 14.056621 14.370400 13.827138 14.543779 14.563051 13.263340 14.405462 14.511807 14.391442 13.655949 13.919863 14.406599 14.307597 13.717301 14.561751 13.479815 14.423533 13.588048 13.644027 14.268385 14.283955 14.361030 14.528760 13.151054 13.826620 14.570806 14.120641 14.538117 14.640103 14.309962 14.069715 14.527437 14.606612 13.824681 13.607361 14.370144 14.535820 14.399329 14.122194 14.580712 14.478250 14.541334 13.593458 14.346338 14.016117 14.580121 14.566098 14.522580 12.578184 14.528995 14.305679 14.422916 14.523434 14.533691 14.490958 14.574831 14.352653 13.714577 13.911857 14.540189 13.522831 13.495538 14.528432 14.462617 13.481391 13.705501 14.399779 14.509204 14.010568 13.623165 14.211318 14.586042 13.392231 14.520972 14.525897 13.822231 14.577431 14.267078 13.423198 14.589490 13.573646 13.655627 14.531561 13.811793 13.979165 14.705119 +predict(newdata1, m, &madeup, &madeup_pred, 0): +8.156780 14.493587 14.854142 +predict(newdata2, m, &madeup, &madeup_pred, 1): +14.491811 14.389726 +pointwise(&madeup_pred, m, coverage, &madeup_ci): +13.761833 14.491811 15.221789 13.656419 14.389726 15.123034 +anova(&madeup2, &madeup, &madeup_anova): +6.45034 81.2319 2.85933 0.0121449 Modified: trunk/Lib/sandbox/pyloess/tests/test_pyloess.py =================================================================== --- trunk/Lib/sandbox/pyloess/tests/test_pyloess.py 2007-03-21 21:28:18 UTC (rev 2862) +++ trunk/Lib/sandbox/pyloess/tests/test_pyloess.py 2007-03-21 22:53:54 UTC (rev 2863) @@ -17,42 +17,20 @@ from numpy import bool_, complex_, float_, int_, str_, object_ import numpy.core.numeric as numeric from numpy.core.records import recarray +fromiter = numpy.fromiter + from numpy.testing import NumpyTest, NumpyTestCase from numpy.testing.utils import build_err_msg, \ assert_equal, assert_almost_equal import pyloess reload(pyloess) -from pyloess import lowess, stl +from pyloess import lowess, stl, loess, loess_anova - -def get_co2data(): - "Reads CO2 data." - filename = os.path.join('tests','co2_data') - F = open(filename, 'r') - data = [] - for line in F.readlines(): - data.append([float(x) for x in line.rstrip().split()]) - return numpy.concatenate(data) - -def get_co2results(): - "Gets theoretical results of smoothed CO2." - filename = os.path.join('tests','co2_results_double') - F = open(filename, 'r') - result = [] - for line in F.readlines(): - result.append(numpy.fromiter((float(x) for x in line.rstrip().split()), - float_)) - return result - -def set_parameters(): - "Returns the parameters of the STL on CO2 data." - parameters = dict(np=12, ns=35, nt=19, nl=13, no=2, ni=1, - nsjump=4, ntjump=2, nljump=2, - isdeg=1, itdeg=1, ildeg=1) - return parameters -######################################################################## +#####--------------------------------------------------------------------------- +#---- --- LOWESS --- +#####--------------------------------------------------------------------------- class test_lowess(NumpyTestCase): "Test class for lowess." # @@ -61,7 +39,7 @@ X = [ 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8,10,12,14,50] Y = [18, 2,15, 6,10, 4,16,11, 7, 3,14,17,20,12, 9,13, 1, 8, 5,19] self.data = (X, Y) - # + #............................................ def test_lowess_1(self): "Tests lowess on typical data. part #1." (X, Y) = self.data @@ -71,7 +49,7 @@ Z = lowess(X, Y, f=0.25, nsteps=0, delta=0) assert_almost_equal(Z.smooth, YS, decimal=3) assert_almost_equal(Z.residuals+Z.smooth, Y, decimal=3) - # + #............................................ def test_lowess_2(self): "Tests lowess on typical data. part #2." (X, Y) = self.data @@ -81,7 +59,7 @@ Z = lowess(X, Y, f=0.25, nsteps=0, delta=3) assert_almost_equal(Z.smooth, YS, decimal=3) assert_almost_equal(Z.residuals+Z.smooth, Y, decimal=3) - # + #............................................ def test_lowess_3(self): "Tests lowess on typical data. part #3." (X, Y) = self.data @@ -92,17 +70,34 @@ assert_almost_equal(Z.smooth, YS, decimal=3) assert_almost_equal(Z.residuals+Z.smooth, Y, decimal=3) -#----------------------------------------------------------------------- +#####--------------------------------------------------------------------------- +#---- --- STL --- +#####--------------------------------------------------------------------------- class test_stl(NumpyTestCase): "Tests STL." # def __init__(self, *args, **kwds): NumpyTestCase.__init__(self, *args, **kwds) - co2_data = get_co2data() - co2_results = get_co2results() - parameters = set_parameters() + # Get CO2 data ................ + filename = os.path.join('tests','co2_data') + F = open(filename, 'r') + data = [] + for line in F.readlines(): + data.append([float(x) for x in line.rstrip().split()]) + co2_data = numpy.concatenate(data) + # Get CO2 results ............. + filename = os.path.join('tests','co2_results_double') + F = open(filename, 'r') + co2_results = [] + for line in F.readlines(): + co2_results.append(fromiter((float(x) for x in line.rstrip().split()), + float_)) + # + parameters = dict(np=12, ns=35, nt=19, nl=13, no=2, ni=1, + nsjump=4, ntjump=2, nljump=2, + isdeg=1, itdeg=1, ildeg=1) self.d = (co2_data, co2_results, parameters) - # + #............................................ def test_stl_1(self): "Tests a classic STL." (co2_data, co2_results, parameters) = self.d @@ -110,7 +105,7 @@ assert_almost_equal(co2_fitted.seasonal, co2_results[0], 6) assert_almost_equal(co2_fitted.trend, co2_results[1], 6) assert_almost_equal(co2_fitted.weights, co2_results[2], 6) - # + #............................................ def test_stl_2(self): "Tests a robust STL." (co2_data, co2_results, parameters) = self.d @@ -118,14 +113,278 @@ assert_almost_equal(co2_fitted.seasonal, co2_results[4], 6) assert_almost_equal(co2_fitted.trend, co2_results[5], 6) assert_almost_equal(co2_fitted.weights, co2_results[6], 6) + + +#####--------------------------------------------------------------------------- +#---- --- LOESS --- +#####--------------------------------------------------------------------------- + +class test_loess2d(NumpyTestCase): + "Test class for lowess." + # + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + dfile = open(os.path.join('tests','madeup_data'), 'r') + dfile.readline() + x = fromiter((float(v) for v in dfile.readline().rstrip().split()), + float_).reshape(-1,2) + dfile.readline() + y = fromiter((float(v) for v in dfile.readline().rstrip().split()), + float_) + dfile = open(os.path.join('tests','madeup_data'), 'r') + dfile.readline() + # + rfile = open(os.path.join('tests','madeup_result'), 'r') + results = [] + for i in range(8): + rfile.readline() + z = fromiter((float(v) for v in rfile.readline().rstrip().split()), + float_) + results.append(z) + # + newdata1 = numpy.array([[-2.5, 0.0, 2.5], [0., 0., 0.]]) + newdata2 = numpy.array([[-0.5, 0.5], [0., 0.]]) + # + madeup = loess(x,y) + self.d = (x, y, results, newdata1, newdata2, madeup) + # + def test_2dbasic(self): + "2D standard" + (x, y, results, _, _, madeup) = self.d + madeup = loess(x,y) + madeup.model.span = 0.5 + madeup.model.normalize = True + madeup.fit() + assert_almost_equal(madeup.outputs.fitted_values, results[0], 5) + assert_almost_equal(madeup.outputs.enp, 14.9, 1) + assert_almost_equal(madeup.outputs.s, 0.9693, 4) + # +# def test_2d_modflags_ez(self): +# "2D - modification of model flags" +# (x, y, results, newdata1, newdata2, madeup) = self.d +# madeup = cloess.loess(x,y) +# madeup.model.span = 0.8 +# madeup.model.drop_square_flags[0] = True +# madeup.model.parametric_flags[0] = True +# assert_equal(madeup.model.parametric_flags[:2],[1,0]) +# madeup.fit() +# assert_almost_equal(madeup.outputs.fitted_values, results[1], 5) +# assert_almost_equal(madeup.outputs.enp, 6.9, 1) +# assert_almost_equal(madeup.outputs.s, 1.4804, 4) + # + def test_2d_modflags_tot(self): + "2D - modification of model flags" + (x, y, results, _, _, madeup) = self.d + madeup = loess(x,y) + madeup.model.span = 0.8 + madeup.model.drop_square_flags = [True, False] + madeup.model.parametric_flags = [True, False] + assert_equal(madeup.model.parametric_flags[:2],[1,0]) + madeup.fit() + assert_almost_equal(madeup.outputs.fitted_values, results[1], 5) + assert_almost_equal(madeup.outputs.enp, 6.9, 1) + assert_almost_equal(madeup.outputs.s, 1.4804, 4) + # + def test_2d_modfamily(self): + "2D - family modification" + (_, _, results, _, _, madeup) = self.d + madeup.model.span = 0.8 + madeup.model.drop_square_flags = [True, False] + madeup.model.parametric_flags = [True, False] + madeup.model.family = "symmetric" + madeup.fit() + assert_almost_equal(madeup.outputs.fitted_values, results[2], 5) + assert_almost_equal(madeup.outputs.enp, 6.9, 1) + assert_almost_equal(madeup.outputs.s, 1.0868, 4) + # + def test_2d_modnormalize(self): + "2D - normalization modification" + (_, _, results, _, _, madeup) = self.d + madeup.model.span = 0.8 + madeup.model.drop_square_flags = [True, False] + madeup.model.parametric_flags = [True, False] + madeup.model.family = "symmetric" + madeup.model.normalize = False + madeup.fit() + assert_almost_equal(madeup.outputs.fitted_values, results[3], 5) + assert_almost_equal(madeup.outputs.enp, 6.9, 1) + assert_almost_equal(madeup.outputs.s, 1.0868, 4) + # + def test_2d_pred_nostderr(self): + "2D prediction - no stderr" + (_, _, results, newdata1, _, madeup) = self.d + madeup.model.span = 0.5 + madeup.model.normalize = True + madeup.predict(newdata1, stderror=False) + assert_almost_equal(madeup.predicted.values, results[4], 5) + # + madeup_pred = madeup.predict(newdata1, stderror=False) + assert_almost_equal(madeup_pred.values, results[4], 5) + # + def test_2d_pred_nodata(self): + "2D prediction - nodata" + (_, _, _, _, _, madeup) = self.d + try: + madeup.predict(None) + except ValueError: + pass + else: + raise AssertionError,"The test should have failed" + # + def test_2d_pred_stderr(self): + "2D prediction - w/ stderr" + (_, _, results, _, newdata2, madeup) = self.d + madeup.model.span = 0.5 + madeup.model.normalize = True + madeup_pred = madeup.predict(newdata2, stderror=True) + assert_almost_equal(madeup_pred.values, results[5], 5) + assert_almost_equal(madeup_pred.stderr, [0.276746, 0.278009], 5) + assert_almost_equal(madeup_pred.residual_scale, 0.969302, 6) + assert_almost_equal(madeup_pred.df, 81.2319, 4) + # Direct access + madeup.predict(newdata2, stderror=True) + assert_almost_equal(madeup.predicted.values, results[5], 5) + assert_almost_equal(madeup.predicted.stderr, [0.276746, 0.278009], 5) + assert_almost_equal(madeup.predicted.residual_scale, 0.969302, 6) + assert_almost_equal(madeup.predicted.df, 81.2319, 4) + # + def test_2d_pred_confinv(self): + "2D prediction - confidence" + (_, _, results, _, newdata2, madeup) = self.d + madeup.model.span = 0.5 + madeup.model.normalize = True + madeup_pred = madeup.predict(newdata2, stderror=True) + madeup.predicted.confidence(coverage=0.99) + assert_almost_equal(madeup.predicted.confidence_intervals.lower, + results[6][::3], 5) + assert_almost_equal(madeup.predicted.confidence_intervals.fit, + results[6][1::3], 5) + assert_almost_equal(madeup.predicted.confidence_intervals.upper, + results[6][2::3], 5) + # Direct access + confinv = madeup.predicted.confidence(coverage=0.99) + assert_almost_equal(confinv.lower, results[6][::3], 5) + assert_almost_equal(confinv.fit, results[6][1::3], 5) + assert_almost_equal(confinv.upper, results[6][2::3], 5) + +#####--------------------------------------------------------------------------- +#---- --- test 2D +#####--------------------------------------------------------------------------- +class test_loess_gas(NumpyTestCase): + "Test class for lowess." + # + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + NOx = numpy.array([4.818, 2.849, 3.275, 4.691, 4.255, 5.064, 2.118, 4.602, + 2.286, 0.970, 3.965, 5.344, 3.834, 1.990, 5.199, 5.283, + 3.752, 0.537, 1.640, 5.055, 4.937, 1.561]) + E = numpy.array([0.831, 1.045, 1.021, 0.970, 0.825, 0.891, 0.71, 0.801, + 1.074, 1.148, 1.000, 0.928, 0.767, 0.701, 0.807, 0.902, + 0.997, 1.224, 1.089, 0.973, 0.980, 0.665]) + gas_fit_E = numpy.array([0.665, 0.949, 1.224]) + newdata = numpy.array([0.6650000, 0.7581667, 0.8513333, 0.9445000, + 1.0376667, 1.1308333, 1.2240000]) + coverage = 0.99 + + rfile = open(os.path.join('tests','gas_result'), 'r') + results = [] + for i in range(8): + rfile.readline() + z = fromiter((float(v) for v in rfile.readline().rstrip().split()), + float_) + results.append(z) + self.d = (E, NOx, gas_fit_E, newdata, coverage, results) + # + def test_1dbasic(self): + "Basic test 1d" + (E, NOx, _, _, _, results) = self.d + gas = loess(E,NOx) + gas.model.span = 2./3. + gas.fit() + assert_almost_equal(gas.outputs.fitted_values, results[0], 6) + assert_almost_equal(gas.outputs.enp, 5.5, 1) + assert_almost_equal(gas.outputs.s, 0.3404, 4) + # + def test_1dbasic_alt(self): + "Basic test 1d - part #2" + (E, NOx, _, _, _, results) = self.d + gas_null = loess(E, NOx) + gas_null.model.span = 1.0 + gas_null.fit() + assert_almost_equal(gas_null.outputs.fitted_values, results[1], 6) + assert_almost_equal(gas_null.outputs.enp, 3.5, 1) + assert_almost_equal(gas_null.outputs.s, 0.5197, 4) + # + def test_1dpredict(self): + "Basic test 1d - prediction" + (E, NOx, gas_fit_E, _, _, results) = self.d + gas = loess(E,NOx, span=2./3.) + gas.fit() + gas.predict(gas_fit_E, stderror=False) + assert_almost_equal(gas.predicted.values, results[2], 6) + # + def test_1dpredict_2(self): + "Basic test 1d - new predictions" + (E, NOx, _, newdata, _, results) = self.d + gas = loess(E,NOx, span=2./3.) + gas.predict(newdata, stderror=True) + gas.predicted.confidence(0.99) + assert_almost_equal(gas.predicted.confidence_intervals.lower, + results[3][0::3], 6) + assert_almost_equal(gas.predicted.confidence_intervals.fit, + results[3][1::3], 6) + assert_almost_equal(gas.predicted.confidence_intervals.upper, + results[3][2::3], 6) + # + def test_anova(self): + "Tests anova" + (E, NOx, _, _, _, results) = self.d + gas = loess(E,NOx, span=2./3.) + gas.fit() + gas_null = loess(E, NOx, span=1.0) + gas_null.fit() + gas_anova = loess_anova(gas, gas_null) + gas_anova_theo = results[4] + assert_almost_equal(gas_anova.dfn, gas_anova_theo[0], 5) + assert_almost_equal(gas_anova.dfd, gas_anova_theo[1], 5) + assert_almost_equal(gas_anova.F_value, gas_anova_theo[2], 5) + assert_almost_equal(gas_anova.Pr_F, gas_anova_theo[3], 5) + # + def test_failures(self): + "Tests failures" + (E, NOx, gas_fit_E, _, _, _) = self.d + gas = loess(E,NOx, span=2./3.) + # This one should fail (all parametric) + gas.model.parametric_flags = True + self.assertRaises(ValueError, gas.fit) + # This one also (all drop_square) + gas.model.drop_square_flags = True + self.assertRaises(ValueError, gas.fit) + gas.model.degree = 1 + self.assertRaises(ValueError, gas.fit) + # This one should not (revert to std) + gas.model.parametric_flags = False + gas.model.drop_square_flags = False + gas.model.degree = 2 + gas.fit() + # Now, for predict ................. + gas.predict(gas_fit_E, stderror=False) + # This one should fail (extrapolation & blending) + self.assertRaises(ValueError, + gas.predict, gas.predicted.values, stderror=False) + # But this one should not .......... + gas.predict(gas_fit_E, stderror=False) + print "OK" + + + + + + ######################################################################## if __name__ == '__main__': NumpyTest().run() - # - co2_data = get_co2data() - co2_results = get_co2results() - parameters = set_parameters() - co2_fitted = stl(co2_data, robust=False, **parameters) + From scipy-svn at scipy.org Wed Mar 21 19:05:29 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 21 Mar 2007 18:05:29 -0500 (CDT) Subject: [Scipy-svn] r2864 - trunk/Lib/sandbox/pyloess Message-ID: <20070321230529.D679539C065@new.scipy.org> Author: pierregm Date: 2007-03-21 18:05:27 -0500 (Wed, 21 Mar 2007) New Revision: 2864 Removed: trunk/Lib/sandbox/pyloess/sandbox/ Log: From scipy-svn at scipy.org Thu Mar 22 09:46:19 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 22 Mar 2007 08:46:19 -0500 (CDT) Subject: [Scipy-svn] r2865 - in trunk/Lib/sandbox/timeseries/io/fame: . tests Message-ID: <20070322134619.904D639C154@new.scipy.org> Author: mattknox_ca Date: 2007-03-22 08:46:15 -0500 (Thu, 22 Mar 2007) New Revision: 2865 Modified: trunk/Lib/sandbox/timeseries/io/fame/core.py trunk/Lib/sandbox/timeseries/io/fame/tests/test_fame.py Log: updated to work with recent overhaul of timeseries module Modified: trunk/Lib/sandbox/timeseries/io/fame/core.py =================================================================== --- trunk/Lib/sandbox/timeseries/io/fame/core.py 2007-03-21 23:05:27 UTC (rev 2864) +++ trunk/Lib/sandbox/timeseries/io/fame/core.py 2007-03-22 13:46:15 UTC (rev 2865) @@ -3,6 +3,7 @@ import numpy import maskedarray as ma import timeseries as ts +from timeseries import const as _c import cfame from const import * @@ -14,23 +15,20 @@ def reverse_dict(d): return dict([(y, x) for x, y in d.iteritems()]) -def convert_dict(d, key_func=lambda x:x, val_func=lambda x:x): - return dict([(key_func(key), val_func(val)) for key, val in d.iteritems()]) - -basis_map = { HBSUND:"U", - HBSDAY:"D", - HBSBUS:"B"} +basis_map = { HBSUND:_c.FR_UND, + HBSDAY:_c.FR_DAY, + HBSBUS:_c.FR_BUS} basis_revmap = reverse_dict(basis_map) -observed_map = { HOBUND:"UNDEFINED", - HOBBEG:"BEGINNING", - HOBEND:"ENDING", - HOBAVG:"AVERAGED", - HOBSUM:"SUMMED", - HOBANN:"ANNUALIZED", - HOBFRM:"FORMULA", - HOBHI:"MAXIMUM", - HOBLO:"MINIMUM"} +observed_map = { HOBUND:ts.check_observed("UNDEFINED"), + HOBBEG:ts.check_observed("BEGINNING"), + HOBEND:ts.check_observed("ENDING"), + HOBAVG:ts.check_observed("AVERAGED"), + HOBSUM:ts.check_observed("SUMMED"), + HOBANN:"ANNUALIZED", #ts.check_observed("ANNUALIZED"), + HOBFRM:"FORMULA", #ts.check_observed("FORMULA"), + HOBHI:ts.check_observed("MAXIMUM"), + HOBLO:ts.check_observed("MINIMUM")} observed_revmap = reverse_dict(observed_map) observed_revmap['HIGH'] = HOBHI observed_revmap['LOW'] = HOBLO @@ -39,7 +37,7 @@ "translate user specified basis to FAME constant" if isinstance(basis, str): - freq = ts.freq_tostr(ts.freq_fromstr(basis)) + freq = ts.check_freq(basis) try: return basis_revmap[freq] except KeyError: @@ -47,75 +45,88 @@ "'DAILY', 'BUSINESS', or 'UNDEFINED'") else: if basis in basis_map: return basis - elif basis == ts.freq_fromstr('D'): return HBSDAY - elif basis == ts.freq_fromstr('B'): return HBSBUS - elif basis == ts.freq_fromstr('U'): return HBSUND + elif basis == _c.FR_DAY: return HBSDAY + elif basis == _c.FR_BUS: return HBSBUS + elif basis == _c.FR_UND: return HBSUND else: raise ValueError("Invalid Basis value") def translate_observed(observed): "translate user specified observed to FAME constant" if isinstance(observed, str): - return observed_revmap[ts.fmtObserv(observed)] + return observed_revmap[ts.check_observed(observed)] elif observed in (observed_map): return observed else: raise ValueError("Invalid Observed value") -freq_map = { HDAILY:"D", - HBUSNS:"B", - HMONTH:"M", - HWKSUN:"W", - HSEC :"S", - HMIN :"T", - HHOUR :"H", - HQTOCT:"Q", - HQTNOV:"Q", - HQTDEC:"Q", - HANJAN:"A", - HANFEB:"A", - HANMAR:"A", - HANAPR:"A", - HANMAY:"A", - HANJUN:"A", - HANJUL:"A", - HANAUG:"A", - HANSEP:"A", - HANOCT:"A", - HANNOV:"A", - HANDEC:"A" } -freq_map = convert_dict(freq_map, val_func=ts.freq_fromstr) +freq_map = { HDAILY:_c.FR_DAY, + HBUSNS:_c.FR_BUS, + HMONTH:_c.FR_MTH, + HWKSUN:_c.FR_WKSUN, + HWKMON:_c.FR_WKMON, + HWKTUE:_c.FR_WKTUE, + HWKWED:_c.FR_WKWED, + HWKTHU:_c.FR_WKTHU, + HWKFRI:_c.FR_WKFRI, + HWKSAT:_c.FR_WKSAT, + HSEC :_c.FR_SEC, + HMIN :_c.FR_MIN, + HHOUR :_c.FR_HR, + HQTOCT:_c.FR_QTR, + HQTNOV:_c.FR_QTR, + HQTDEC:_c.FR_QTR, + HANJAN:_c.FR_ANNJAN, + HANFEB:_c.FR_ANNFEB, + HANMAR:_c.FR_ANNMAR, + HANAPR:_c.FR_ANNAPR, + HANMAY:_c.FR_ANNMAY, + HANJUN:_c.FR_ANNJUN, + HANJUL:_c.FR_ANNJUL, + HANAUG:_c.FR_ANNAUG, + HANSEP:_c.FR_ANNSEP, + HANOCT:_c.FR_ANNOCT, + HANNOV:_c.FR_ANNNOV, + HANDEC:_c.FR_ANNDEC } -freq_revmap = { "D" : HDAILY, - "B" : HBUSNS, - "M" : HMONTH, - "W" : HWKSUN, - "S" : HSEC, - "T" : HMIN, - "H" : HHOUR, - "Q" : HQTDEC, - "A" : HANDEC} -freq_revmap = convert_dict(freq_revmap, key_func=ts.freq_fromstr) +freq_revmap = reverse_dict(freq_map) +freq_revmap[_c.FR_QTR] = HQTDEC -date_value_adjust = { 'A':1849, - 'Q':7396, - 'M':22188, - 'W':96477, - 'B':482381, - 'D':675333, - 'H':87648, - 'T':5258880, - 'S':315532800} -date_value_adjust = convert_dict(date_value_adjust, key_func=ts.freq_fromstr) +date_value_adjust = { _c.FR_ANNJAN:1849, + _c.FR_ANNFEB:1849, + _c.FR_ANNMAR:1849, + _c.FR_ANNAPR:1849, + _c.FR_ANNMAY:1849, + _c.FR_ANNJUN:1849, + _c.FR_ANNJUL:1849, + _c.FR_ANNAUG:1849, + _c.FR_ANNSEP:1849, + _c.FR_ANNOCT:1849, + _c.FR_ANNNOV:1849, + _c.FR_ANNDEC:1849, + _c.FR_QTR:7396, + _c.FR_MTH:22188, + _c.FR_WKSUN:96477, + _c.FR_WKMON:96477, + _c.FR_WKTUE:96477, + _c.FR_WKWED:96477, + _c.FR_WKTHU:96477, + _c.FR_WKFRI:96477, + _c.FR_WKSAT:96477, + _c.FR_BUS:482381, + _c.FR_DAY:675333, + _c.FR_HR:87648, + _c.FR_MIN:5258880, + _c.FR_SEC:315532800} def fametype_fromdata(data): """determine fame type code from a data object""" - + if isinstance(data, ts.DateArray) or isinstance(data, ts.Date): return freq_revmap[data.freq] elif hasattr(data, 'dtype'): dtypeStr = str(data.dtype) - + if dtypeStr[:5] == "float": if int(dtypeStr[5:]) > 32: return HPRECN else: return HNUMRC @@ -131,7 +142,7 @@ return HBOOLN else: raise ValueError("Unsupported dtype for fame database: %s", dtypeStr) - + elif isinstance(data, str): return HSTRNG elif isinstance(data, (int, float)): @@ -161,19 +172,19 @@ def __init__(self, data={}): for i, v in data.iteritems(): self[i.upper()] = v - + def __getitem__(self, key): if hasattr(key, 'upper'): key = key.upper() return super(CaseInsensitiveDict, self).__getitem__(key) - + def __setitem__(self, key, item): if hasattr(key, 'upper'): key = key.upper() super(CaseInsensitiveDict, self).__setitem__(key, item) -def _famedate_to_tsdate(fame_date, freqstr): +def _famedate_to_tsdate(fame_date, freq): "convert integer fame date to a timeseries Date" - value = fame_date + date_value_adjust[ts.freq_fromstr(freqstr)] - return ts.Date(freq=freqstr, value=value) + value = fame_date + date_value_adjust[freq] + return ts.Date(freq=freq, value=value) def _fame_params_from_pyobj_scalar(pyobj): @@ -221,7 +232,7 @@ :Construction: x = FameDb(conn_str, mode='r') -:Paramaters: +:Parameters: - `conn_str` (str) : valid connection string. Can be a physical path, or channel specification, etc. See FAME documentation on cfmopdb for valid connection strings. @@ -258,14 +269,14 @@ else: raise ValueError, "Database access mode not supported." self.mode = mode - + self.dbkey = cf_open(conn_str, intmode) - + def read(self, name, start_date=None, end_date=None, start_case=None, end_case=None, max_string_len=65): - + """read specified object(s) from database :Parameters: @@ -288,7 +299,7 @@ or series of strings. This is the maximum length of string that can be read. Lower values result in less memory usage, so you should specify this as low as is reasonable for your data. - + :Return: if `name` is a list of strings: case insensitive dictionary of the objects @@ -303,7 +314,7 @@ names = name items = CaseInsensitiveDict() - + #default to -1. This will get the entire range _start_case = _end_case = -1 _start_date = _end_date = -1 @@ -322,7 +333,7 @@ if start_case is not None: _start_case = start_case if end_case is not None: _end_case = end_case - + if len(set([_start_case, _end_case, _start_date, _end_date, -1])) != 1: checkFreq = True else: @@ -376,7 +387,7 @@ pyObj = numpyType(pyObj) elif result['class'] == HSERIE: - + if 'data' in result: vals = result['data'] mask = result['mask'] @@ -384,7 +395,7 @@ else: vals = [] mask = ma.nomask - + if result['type'] >= 8: # date type valadj = date_value_adjust[freq_map[result['type']]] if len(vals) > 0: vals += valadj @@ -392,7 +403,7 @@ freq=freq_map[result['type']]) else: data = numpy.array(vals, dtype=numpyType) - + if result['freq'] == HCASEX: pyObj = ma.array(data, mask=mask) else: @@ -405,7 +416,7 @@ value=result['startindex']+date_value_adjust[freq]) else: start_date = None - + pyObj = ts.time_series(data, freq=freq, start_date=start_date, observed=observed, mask=mask) @@ -414,7 +425,7 @@ if isSingle: return items.values()[0] - + return items #.............................................................................. def write_dict(self, objdict, @@ -554,7 +565,7 @@ - `end_date` (Date, *[None]*) : If None, data will be written until the end of `tser`. If specified, only data points on or before end_date will be written. """ - + if not isinstance(tser, ts.TimeSeries): raise ValueError("tser is not a valid time series") elif tser.has_missing_dates(): @@ -569,15 +580,15 @@ if overwrite or not exists: create = True else: create = False - + fame_params = _fame_params_from_pyobj_tser(tser) - + fame_cls = fame_params['cls'] fame_type = fame_params['type'] fame_freq = fame_params['freq'] fame_basis = fame_params['basis'] fame_observed = fame_params['observed'] - + if create: if exists: self.delete_obj(name) cf_create(self.dbkey, name, fame_cls, fame_freq, fame_type, fame_basis, fame_observed) @@ -591,10 +602,10 @@ return bdate else: return getattr(tser, attr) - + start_date = get_boundary_date(start_date, "start_date") end_date = get_boundary_date(end_date, "end_date") - + if start_date is not None: towrite = tser[start_date:end_date+1] @@ -645,7 +656,7 @@ - `end_case` (int, *[None]*) : If None, data will be written until the end of `cser`. If specified, only data points on or before end_case will be written. """ - + if not isinstance(cser, numpy.ndarray): raise ValueError("cser is not a valid ndarray") elif cser.ndim != 1: @@ -657,9 +668,9 @@ if overwrite or not exists: create = True else: create = False - + fame_params = _fame_params_from_pyobj_cser(cser) - + fame_cls = fame_params['cls'] fame_type = fame_params['type'] fame_freq = fame_params['freq'] @@ -696,15 +707,15 @@ return zero_represents + cser.size - 1 else: raise ValueError("unexpected argument: %s " % attr) - + start_case = get_boundary_case(start_case, "start_case") end_case = get_boundary_case(end_case, "end_case") - if start_case is not None: + if start_case is not None: # convert integer types to floats since FAME does not have an integer type s = start_case - zero_represents e = end_case - zero_represents - + fame_data = fame_data[s:e+1] fame_mask = fame_mask[s:e+1] newType = fametype_tonumpy(fame_type) @@ -725,7 +736,7 @@ - `name` (string) : database key that the object will be written to - `scalar` : one of the following: string, numpy scalar, int, float, list of strings (for name lists), Date, boolean""" - + fame_params = _fame_params_from_pyobj_scalar(scalar) fame_type = fame_params['type'] @@ -746,7 +757,7 @@ fame_data = "{" + ", ".join(scalar) + "}" else: raise ValueError("Unrecognized data type") - + if self.obj_exists(name): self.delete_obj(name) cf_create(self.dbkey, name, fame_params['cls'], @@ -759,7 +770,7 @@ newType = fametype_tonumpy(fame_type) if hasattr(fame_data, 'dtype') and newType != fame_data.dtype: fame_data = fame_data.astype(newType) - + if fame_type == HNAMEL: cf_write_namelist(self.dbkey, name, fame_data) else: @@ -786,10 +797,10 @@ parameters. Generally speaking, it is easier to use initialize_obj with a prototype object. """ - + if cls not in (HSERIE, HSCALA): raise ValueError("unrecognized object class: "+str(cls)) - + if freq is None: if cls == HSCALA: freq = HUNDFX @@ -815,7 +826,7 @@ param_func = _fame_params_from_pyobj_cser else: param_func = _fame_params_from_pyobj_scalar - + fame_params = param_func(pyobj) cf_create(self.dbkey, name, fame_params['cls'], @@ -827,7 +838,7 @@ def rename_obj(self, name, new_name): """rename fame object in database""" cf_rename_obj(self.dbkey, name, new_name) - + def copy_obj(self, target_db, source_name, target_name=None): """copy fame object to another destination""" if target_name is None: target_name = source_name @@ -871,9 +882,9 @@ ts_freq = freq_map[obj_sz['freq']] except KeyError: raise DBError("unsupported FAME frequency: %i", fame_freq) - + if obj_sz[date_type+'_year'] == -1: return None - + annDate = ts.Date(freq='A', year=obj_sz[date_type+'_year']) return annDate.asfreq(ts_freq, relation='BEFORE') + (obj_sz[date_type+'_period'] - 1) @@ -914,16 +925,16 @@ def obj_end_date(self, name): """get end_date of a FAME time series object""" return self.__ser_date(name, 'end') - + def obj_created(self, name): "get 'created' attribute of object in database" fame_date = cf_get_obj_attr(self.dbkey, name, "CREATED") - return _famedate_to_tsdate(fame_date, 's') + return _famedate_to_tsdate(fame_date, _c.FR_SEC) def obj_modified(self, name): "get 'modified' attribute of object in database" fame_date = cf_get_obj_attr(self.dbkey, name, "MODIFIED") - return _famedate_to_tsdate(fame_date, 's') + return _famedate_to_tsdate(fame_date, _c.FR_SEC) #.............................................................................. def db_desc(self): "get 'description' attribute of database" @@ -936,12 +947,12 @@ def db_created(self): "get 'created' attribute of database" fame_date = cf_get_db_attr(self.dbkey, "CREATED") - return _famedate_to_tsdate(fame_date, 's') + return _famedate_to_tsdate(fame_date, _c.FR_SEC) def db_modified(self): "get 'modified' attribute of database" fame_date = cf_get_db_attr(self.dbkey, "MODIFIED") - return _famedate_to_tsdate(fame_date, 's') + return _famedate_to_tsdate(fame_date, _c.FR_SEC) def db_is_open(self): "returns True if database is open. False otherwise" @@ -959,7 +970,7 @@ """performs a wildlist lookup on the database, using Fame syntax ("?" and "^"), returns a normal python list of strings""" res = cf_wildlist(self.dbkey, exp) - + if wildonly: exp = exp.replace("?", "(.*)") exp = exp.replace("^", "(.)") @@ -973,7 +984,7 @@ """Closes the database. Changes will be posted.""" if self.db_is_open(): cf_close(self.dbkey) - + def post(self): cf_post(self.dbkey) @@ -1002,7 +1013,7 @@ except: self.fameLock.release() raise - + return result cf_open = cFameCall(cfame.open) @@ -1041,7 +1052,7 @@ :Parameters: - option (str) : name of the option to set - setting (str) : value of the option to set - + :Example: set_option("DBSIZE", "LARGE") """ @@ -1049,5 +1060,5 @@ def license_expires(): """get date that license expires on""" fame_date = cf_license_expires() - adj_val = date_value_adjust[ts.freq_fromstr('D')] - return ts.Date(freq='D', value=fame_date+adj_val) + adj_val = date_value_adjust[_c.FR_DAY] + return ts.Date(freq=_c.FR_DAY, value=fame_date+adj_val) Modified: trunk/Lib/sandbox/timeseries/io/fame/tests/test_fame.py =================================================================== --- trunk/Lib/sandbox/timeseries/io/fame/tests/test_fame.py 2007-03-21 23:05:27 UTC (rev 2864) +++ trunk/Lib/sandbox/timeseries/io/fame/tests/test_fame.py 2007-03-22 13:46:15 UTC (rev 2865) @@ -19,6 +19,7 @@ from timeseries.io import fame from timeseries.io.fame import const +from timeseries import const as _c from timeseries import Report import timeseries as ts import maskedarray as ma @@ -85,15 +86,15 @@ data['scalars']['boolean'] = True for f in data['dates']: data['scalars']['date_'+f] = data['dates'][f] - + _desc = "my desc\nline 2" _doc = "my doc\nline 2" class test_write(NumpyTestCase): - + def setUp(self): self.db = fame.FameDb("testdb.db",'o') - + def test_main(self): "execute all the tests. Order is important here" @@ -127,7 +128,7 @@ "test writing all types of scalar values" for s in data['scalars']: self.db.write_scalar('$scalar_'+s, data['scalars'][s]) - + def _test_dict_scalars(self): "test writing multiple scalars at once using write_scalar_dict" self.db.write_scalar_dict({'$scalar_1':data['scalars']['float32'], @@ -175,10 +176,10 @@ ser = self.db.read('$tser_'+x) if str(ser.dtype)[:5] == 'float' and str(data['tser'][x].dtype)[:3] == 'int': ser = ser.astype(data['tser'][x].dtype) - + assert_mask_equal(ser.mask, data['tser'][x].mask) assert((ser == data['tser'][x]).all()) - + def _test_read_range_tser(self): "test reading a time series over specified ranges" src = data['tser']['float32'] @@ -186,32 +187,32 @@ s2 = src.start_date-2 e1 = src.end_date+2 e2 = src.end_date-2 - + dateList = [(s1, e1), (s1, e2), (s2, e1), (s2, e2)] - + for s, e in dateList: res = ts.adjust_endpoints(src, start_date=s, end_date=e) ser = self.db.read('$tser_float32', start_date=s, end_date=e) assert_array_equal(res, ser) - + def _test_write_append_tser(self): "test appending data to an existing time series" self.db.write_tser('$appendTSer', data['tser']['float32']) self.db.write_tser('$appendTSer', appendTSer) - + def _test_read_append_tser(self): "test reading of appended time series" result = ts.adjust_endpoints(data['tser']['float32'], start_date=data['tser']['float32'].start_date, end_date=appendTSer.end_date) result[appendTSer.start_date:appendTSer.end_date+1] = appendTSer - + ser = self.db.read('$appendTSer') - + assert_array_equal(result, ser) @@ -223,12 +224,12 @@ def _test_verify_write_range_tser(self): "verify that _test_write_range_write_tser worked as expected" - + ser = self.db.read('$rangeTSer') - + sDate = ts.Date(freq='A', year=2008) eDate = ts.Date(freq='A', year=2012) - + assert_array_equal(ser, rangeTSer[sDate:eDate+1]) def _test_write_empty_tser(self): @@ -240,7 +241,7 @@ "test reading a time series with no data" ser = self.db.read('$emptyTSer') assert(ser.start_date is None) - + def _test_overwrite_tser(self): "test overwriting a time series" self.db.write_tser('$tser_float32', data['tser']['bool'], overwrite=True) @@ -255,7 +256,7 @@ except fame.DBError: exception = True assert(exception) - + def _test_dict_tser(self): "test writing multiple time series at once using write_tser_dict" self.db.write_tser_dict({'$tser_1':data['tser']['float32'], @@ -275,7 +276,7 @@ ser = self.db.read('$cser_'+x) if str(ser.dtype)[:5] == 'float' and str(data['cser'][x].dtype)[:3] == 'int': ser = ser.astype(data['cser'][x].dtype) - + assert_mask_equal(ser.mask, data['cser'][x].mask) assert((ser == data['cser'][x]).all()) @@ -286,12 +287,12 @@ s2 = 1 e1 = 8 e2 = 4 - + caseList = [(s1, e1), (s1, e2), (s2, e1), (s2, e2)] - + for s, e in caseList: size = (e - s + 1) res = ma.array([0]*size , np.float32, mask=[1]*size ) @@ -308,14 +309,14 @@ "test appending to an existing case series" self.db.write_cser('$appendCSer', data['cser']['float32']) self.db.write_cser('$appendCSer', appendCSer, zero_represents=4) - + def _test_read_append_cser(self): "test reading of appended case series" - + result = ma.concatenate([data['cser']['float32'][:3], appendCSer]) ser = self.db.read('$appendCSer') assert_array_equal(result, ser) - + def _test_write_range_cser(self): "test writing over a specified range" self.db.write_cser('$rangeCSer', rangeCSer, @@ -323,11 +324,11 @@ def _test_verify_write_range_cser(self): "verify that _test_write_range_write_cser worked as expected" - + ser = self.db.read('$rangeCSer') result = ma.arange(9).astype(np.float32) result[:4] = ma.masked - + assert_array_equal(ser, result) def _test_write_empty_cser(self): @@ -338,13 +339,13 @@ "test reading a case series with no data" ser = self.db.read('$emptyCSer') assert_equal(ser.size, 0) - + def _test_overwrite_cser(self): "test overwriting a case series" self.db.write_cser('$cser_float32', data['cser']['bool'], overwrite=True) ser = self.db.read('$cser_float32') assert_array_equal(ser, data['cser']['bool']) - + def _test_assume_exists_cser(self): "check to see if the assume_exists flag works for write_cser" exception = False @@ -361,17 +362,17 @@ result = self.db.read(['$cser_1', '$cser_2']) assert_array_equal(result['$cser_1'], data['cser']['float32']) assert_array_equal(result['$cser_2'], data['cser']['float32']) - + def _test_whats(self): "test whats method" # just make sure it doesn't crash for now what_dict = self.db._whats('$tser_float32') - + def _test_exists(self): "test exists method" assert(self.db.obj_exists('$cser_float32')) assert(not self.db.obj_exists('$fake_series')) - + def _test_delete(self): "test delete method" assert(self.db.obj_exists('$cser_1')) @@ -389,12 +390,12 @@ res2 = sorted([x.upper() for x in list(data['cser'])]) assert_equal(wl1, res1) assert_equal(wl2, res2) - + def _test_restore(self): "test restore method" self.db.close() self.db = fame.FameDb("testdb.db",'s') - + self.db.delete_obj('$tser_float32') assert(not self.db.obj_exists('$tser_float32')) self.db.restore() @@ -409,12 +410,12 @@ modified = self.db.db_modified() desc = self.db.db_desc() doc = self.db.db_doc() - + assert(abs(ts.thisday('s') - created) < 100) assert(abs(ts.thisday('s') - modified) < 100) assert_equal(desc, _desc) assert_equal(doc, _doc) - + assert(self.db.db_is_open()) self.db.close() assert(not self.db.db_is_open()) @@ -432,13 +433,13 @@ proc.close() assert_equal(exists, "False") - + self.db.post() - + proc = os.popen('python -c "'+exist_script+'"') exists = proc.readlines()[0].strip('\n') proc.close() - + assert_equal(exists, "True") def _test_copy_rename(self): @@ -448,17 +449,17 @@ orig_obj = self.db.read("$tser_float32") copied_obj = db2.read("$copied_obj") assert_array_equal(orig_obj, copied_obj) - + db2.rename_obj("$copied_obj", "$renamed_obj") assert(db2.obj_exists("$renamed_obj")) assert(not db2.obj_exists("$copied_obj")) - + db2.close() - + def _test_obj_attribs(self): "test getting and setting object attributes" assert_equal(self.db.obj_freq("$freq_b"), data['freqs']['b'].freq) - + assert_equal(self.db.obj_start_date("$freq_b"), data['freqs']['b'].start_date) assert_equal(self.db.obj_end_date("$freq_b"), @@ -469,24 +470,24 @@ assert(abs(ts.thisday('s') - created) < 100) assert(abs(ts.thisday('s') - modified) < 100) - + self.db.set_obj_desc("$freq_b", _desc) self.db.set_obj_doc("$freq_b", _doc) - + desc = self.db.obj_desc("$freq_b") doc = self.db.obj_doc("$freq_b") - + assert_equal(desc, _desc) assert_equal(doc, _doc) - + self.db.set_obj_basis("$freq_b", const.HBSDAY) assert_equal(self.db.obj_basis("$freq_b"), const.HBSDAY) self.db.set_obj_basis("$freq_b", const.HBSBUS) assert_equal(self.db.obj_basis("$freq_b"), const.HBSBUS) - + self.db.set_obj_observed("$freq_b", "END") assert_equal(self.db.obj_observed("$freq_b"), "ENDING") - + self.db.set_obj_observed("$freq_b", "MAX") assert_equal(self.db.obj_observed("$freq_b"), "MAXIMUM") @@ -495,16 +496,16 @@ def _test_misc_funcs(self): "test FAME functions that aren't database methods" - assert_equal(fame.license_expires().freq, ts.freq_fromstr('D')) - + assert_equal(fame.license_expires().freq, _c.FR_DAY) + # just test that this doesn't crash for now fame.set_option("DBSIZE", "LARGE") def tearDown(self): self.db.close() - - + + ############################################################################### #------------------------------------------------------------------------------ if __name__ == "__main__": From scipy-svn at scipy.org Thu Mar 22 09:55:28 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 22 Mar 2007 08:55:28 -0500 (CDT) Subject: [Scipy-svn] r2866 - trunk/Lib/linsolve Message-ID: <20070322135528.B542439C06A@new.scipy.org> Author: nmarais Date: 2007-03-22 08:54:08 -0500 (Thu, 22 Mar 2007) New Revision: 2866 Modified: trunk/Lib/linsolve/linsolve.py Log: Indicate that scipy.linsolve.factorized is meant for sparse systems Modified: trunk/Lib/linsolve/linsolve.py =================================================================== --- trunk/Lib/linsolve/linsolve.py 2007-03-22 13:46:15 UTC (rev 2865) +++ trunk/Lib/linsolve/linsolve.py 2007-03-22 13:54:08 UTC (rev 2866) @@ -120,7 +120,7 @@ def factorized( A ): """ - Return a fuction for solving a linear system, with A pre-factorized. + Return a fuction for solving a sparse linear system, with A pre-factorized. Example: solve = factorized( A ) # Makes LU decomposition. From scipy-svn at scipy.org Fri Mar 23 11:00:01 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 23 Mar 2007 10:00:01 -0500 (CDT) Subject: [Scipy-svn] r2867 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070323150001.1BCC839C229@new.scipy.org> Author: mattknox_ca Date: 2007-03-23 09:59:50 -0500 (Fri, 23 Mar 2007) New Revision: 2867 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: added support for quarterly frequencies with different year ends Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-22 13:54:08 UTC (rev 2866) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-23 14:59:50 UTC (rev 2867) @@ -20,7 +20,52 @@ #define FR_ANNOCT 1010 /* Annual - October year end*/ #define FR_ANNNOV 1011 /* Annual - November year end*/ -#define FR_QTR 2000 /* Quarterly */ +/* The standard quarterly frequencies. Year is determined by what year the end + month lies in. */ +#define FR_QTR 2000 /* Quarterly - December year end (default quarterly) */ +#define FR_QTRDEC FR_QTR /* Quarterly - December year end */ +#define FR_QTRJAN 2001 /* Quarterly - January year end */ +#define FR_QTRFEB 2002 /* Quarterly - February year end */ +#define FR_QTRMAR 2003 /* Quarterly - March year end */ +#define FR_QTRAPR 2004 /* Quarterly - April year end */ +#define FR_QTRMAY 2005 /* Quarterly - May year end */ +#define FR_QTRJUN 2006 /* Quarterly - June year end */ +#define FR_QTRJUL 2007 /* Quarterly - July year end */ +#define FR_QTRAUG 2008 /* Quarterly - August year end */ +#define FR_QTRSEP 2009 /* Quarterly - September year end */ +#define FR_QTROCT 2010 /* Quarterly - October year end */ +#define FR_QTRNOV 2011 /* Quarterly - November year end */ + +/* End period based quarterly frequencies. Year is determined by what year the + end month lies in. */ +#define FR_QTREDEC FR_QTRDEC /* Quarterly - December year end*/ +#define FR_QTREJAN FR_QTRJAN /* Quarterly - January year end*/ +#define FR_QTREFEB FR_QTRFEB /* Quarterly - February year end*/ +#define FR_QTREMAR FR_QTRMAR /* Quarterly - March year end*/ +#define FR_QTREAPR FR_QTRAPR /* Quarterly - April year end*/ +#define FR_QTREMAY FR_QTRMAY /* Quarterly - May year end*/ +#define FR_QTREJUN FR_QTRJUN /* Quarterly - June year end*/ +#define FR_QTREJUL FR_QTRJUL /* Quarterly - July year end*/ +#define FR_QTREAUG FR_QTRAUG /* Quarterly - August year end*/ +#define FR_QTRESEP FR_QTRSEP /* Quarterly - September year end*/ +#define FR_QTREOCT FR_QTROCT /* Quarterly - October year end*/ +#define FR_QTRENOV FR_QTRNOV /* Quarterly - November year end*/ + +/* Starting period based quarterly frequencies. Year is determined by what year + the starting month lies in. */ +#define FR_QTRSDEC FR_QTRDEC+12 /* Quarterly - December year end*/ +#define FR_QTRSJAN FR_QTRJAN+12 /* Quarterly - January year end*/ +#define FR_QTRSFEB FR_QTRFEB+12 /* Quarterly - February year end*/ +#define FR_QTRSMAR FR_QTRMAR+12 /* Quarterly - March year end*/ +#define FR_QTRSAPR FR_QTRAPR+12 /* Quarterly - April year end*/ +#define FR_QTRSMAY FR_QTRMAY+12 /* Quarterly - May year end*/ +#define FR_QTRSJUN FR_QTRJUN+12 /* Quarterly - June year end*/ +#define FR_QTRSJUL FR_QTRJUL+12 /* Quarterly - July year end*/ +#define FR_QTRSAUG FR_QTRAUG+12 /* Quarterly - August year end*/ +#define FR_QTRSSEP FR_QTRSEP+12 /* Quarterly - September year end*/ +#define FR_QTRSOCT FR_QTROCT+12 /* Quarterly - October year end*/ +#define FR_QTRSNOV FR_QTRNOV+12 /* Quarterly - November year end*/ + #define FR_MTH 3000 /* Monthly */ #define FR_WK 4000 /* Weekly */ @@ -56,6 +101,8 @@ int from_a_year_end; //month the year ends on in the "from" frequency int to_a_year_end; //month the year ends on in the "to" frequency + int from_q_year_end; //month the year ends on in the "from" frequency + int to_q_year_end; //month the year ends on in the "to" frequency }; static struct asfreq_info NULL_AF_INFO; @@ -409,6 +456,7 @@ return -1; } +static int monthToQuarter(int month) { return ((month-1)/3)+1; } /* Sets the date part of the date_info struct using the indicated calendar. @@ -474,7 +522,7 @@ } dinfo->month = month; - dinfo->quarter = ((month-1)/3)+1; + dinfo->quarter = monthToQuarter(month); dinfo->day = dayoffset - month_offset[leap][month-1]; } @@ -601,15 +649,35 @@ else { return (long)(dinfo.year); } } - -static long asfreq_DtoQ(long fromDate, char relation, struct asfreq_info *af_info) { - +static long DtoQ_yq(long fromDate, struct asfreq_info *af_info, + int *year, int *quarter) { struct date_info dinfo; if (dInfoCalc_SetFromAbsDate(&dinfo, fromDate, GREGORIAN_CALENDAR)) return INT_ERR_CODE; - return (long)((dinfo.year - 1) * 4 + dinfo.quarter); + if (af_info->to_q_year_end != 12) { + dinfo.month -= af_info->to_q_year_end; + if (dinfo.month <= 0) { dinfo.month += 12; } + else { dinfo.year += 1; } + dinfo.quarter = monthToQuarter(dinfo.month); + } + + *year = dinfo.year; + *quarter = dinfo.quarter; + + return 0; } + +static long asfreq_DtoQ(long fromDate, char relation, struct asfreq_info *af_info) { + + int year, quarter; + + if (DtoQ_yq(fromDate, af_info, &year, &quarter) == INT_ERR_CODE) + { return INT_ERR_CODE; } + + return (long)((year - 1) * 4 + quarter); +} + static long asfreq_DtoM(long fromDate, char relation, struct asfreq_info *af_info) { struct date_info dinfo; @@ -673,7 +741,7 @@ static long asfreq_StoA(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoA(asfreq_StoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } static long asfreq_StoQ(long fromDate, char relation, struct asfreq_info *af_info) - { return asfreq_DtoQ(asfreq_StoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } + { return asfreq_DtoQ(asfreq_StoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } static long asfreq_StoM(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoM(asfreq_StoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } static long asfreq_StoW(long fromDate, char relation, struct asfreq_info *af_info) @@ -695,7 +763,7 @@ static long asfreq_TtoA(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoA(asfreq_TtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } static long asfreq_TtoQ(long fromDate, char relation, struct asfreq_info *af_info) - { return asfreq_DtoQ(asfreq_TtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } + { return asfreq_DtoQ(asfreq_TtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } static long asfreq_TtoM(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoM(asfreq_TtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } static long asfreq_TtoW(long fromDate, char relation, struct asfreq_info *af_info) @@ -719,7 +787,7 @@ static long asfreq_HtoA(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoA(asfreq_HtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } static long asfreq_HtoQ(long fromDate, char relation, struct asfreq_info *af_info) - { return asfreq_DtoQ(asfreq_HtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } + { return asfreq_DtoQ(asfreq_HtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } static long asfreq_HtoM(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoM(asfreq_HtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } static long asfreq_HtoW(long fromDate, char relation, struct asfreq_info *af_info) @@ -746,7 +814,7 @@ { return asfreq_DtoA(asfreq_BtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } static long asfreq_BtoQ(long fromDate, char relation, struct asfreq_info *af_info) - { return asfreq_DtoQ(asfreq_BtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } + { return asfreq_DtoQ(asfreq_BtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } static long asfreq_BtoM(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoM(asfreq_BtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } @@ -773,12 +841,12 @@ static long asfreq_WtoA(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoA(asfreq_WtoD(fromDate, 'A', af_info), relation, af_info); } static long asfreq_WtoQ(long fromDate, char relation, struct asfreq_info *af_info) { - return asfreq_DtoQ(asfreq_WtoD(fromDate, 'A', af_info), relation, &NULL_AF_INFO); } + return asfreq_DtoQ(asfreq_WtoD(fromDate, 'A', af_info), relation, af_info); } static long asfreq_WtoM(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoM(asfreq_WtoD(fromDate, 'A', af_info), relation, &NULL_AF_INFO); } static long asfreq_WtoW(long fromDate, char relation, struct asfreq_info *af_info) - { return asfreq_DtoW(asfreq_WtoD(fromDate, relation, af_info), relation, &NULL_AF_INFO); } + { return asfreq_DtoW(asfreq_WtoD(fromDate, relation, af_info), relation, af_info); } static long asfreq_WtoB(long fromDate, char relation, struct asfreq_info *af_info) { @@ -820,14 +888,10 @@ } static long asfreq_MtoA(long fromDate, char relation, struct asfreq_info *af_info) { - long year = (fromDate - 1) / 12 + 1; - long month = fromDate - (year - 1)*12; - if (month > af_info->to_a_year_end) { return year + 1; } - else { return year; } -} + return asfreq_DtoA(asfreq_MtoD(fromDate, 'A', &NULL_AF_INFO), relation, af_info); } -static long asfreq_MtoQ(long fromDate, char relation, struct asfreq_info *af_info) - { return (fromDate - 1) / 3 + 1; } +static long asfreq_MtoQ(long fromDate, char relation, struct asfreq_info *af_info) { + return asfreq_DtoQ(asfreq_MtoD(fromDate, 'A', &NULL_AF_INFO), relation, af_info); } static long asfreq_MtoW(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoW(asfreq_MtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } @@ -851,9 +915,16 @@ //************ FROM QUARTERLY *************** -static void QtoD_ym(long fromDate, long *y, long *m) { +static void QtoD_ym(long fromDate, long *y, long *m, struct asfreq_info *af_info) { + *y = (fromDate - 1) / 4 + 1; *m = (fromDate + 4) * 3 - 12 * (*y) - 2; + + if (af_info->from_q_year_end != 12) { + *m += af_info->from_q_year_end; + if (*m > 12) { *m -= 12; } + else { *y -= 1; } + } } static long asfreq_QtoD(long fromDate, char relation, struct asfreq_info *af_info) { @@ -861,35 +932,32 @@ long y, m, absdate; if (relation == 'B') { - QtoD_ym(fromDate, &y, &m); + QtoD_ym(fromDate, &y, &m, af_info); if ((absdate = absdate_from_ymd(y, m, 1)) == INT_ERR_CODE) return INT_ERR_CODE; return absdate; } else { - QtoD_ym(fromDate+1, &y, &m); + QtoD_ym(fromDate+1, &y, &m, af_info); if ((absdate = absdate_from_ymd(y, m, 1)) == INT_ERR_CODE) return INT_ERR_CODE; return absdate - 1; } } +static long asfreq_QtoQ(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoQ(asfreq_QtoD(fromDate, relation, af_info), relation, af_info); } + static long asfreq_QtoA(long fromDate, char relation, struct asfreq_info *af_info) { - long year = (fromDate - 1) / 4 + 1; - long quarter = fromDate - (year - 1)*4; - if (quarter > af_info->to_a_year_end) { return year + 1; } - else { return year; } -} + return asfreq_DtoA(asfreq_QtoD(fromDate, relation, af_info), relation, af_info); } static long asfreq_QtoM(long fromDate, char relation, struct asfreq_info *af_info) { - if (relation == 'B') { return fromDate * 3 - 2; } - else { return fromDate * 3; } -} + return asfreq_DtoM(asfreq_QtoD(fromDate, relation, af_info), relation, &NULL_AF_INFO); } static long asfreq_QtoW(long fromDate, char relation, struct asfreq_info *af_info) - { return asfreq_DtoW(asfreq_QtoD(fromDate, relation, &NULL_AF_INFO), relation, af_info); } + { return asfreq_DtoW(asfreq_QtoD(fromDate, relation, af_info), relation, af_info); } static long asfreq_QtoB(long fromDate, char relation, struct asfreq_info *af_info) { struct date_info dinfo; - if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_QtoD(fromDate, relation, &NULL_AF_INFO), + if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_QtoD(fromDate, relation, af_info), GREGORIAN_CALENDAR)) return INT_ERR_CODE; if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } @@ -898,11 +966,11 @@ static long asfreq_QtoH(long fromDate, char relation, struct asfreq_info *af_info) - { return asfreq_DtoH(asfreq_QtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } + { return asfreq_DtoH(asfreq_QtoD(fromDate, relation, af_info), relation, &NULL_AF_INFO); } static long asfreq_QtoT(long fromDate, char relation, struct asfreq_info *af_info) - { return asfreq_DtoT(asfreq_QtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } + { return asfreq_DtoT(asfreq_QtoD(fromDate, relation, af_info), relation, &NULL_AF_INFO); } static long asfreq_QtoS(long fromDate, char relation, struct asfreq_info *af_info) - { return asfreq_DtoS(asfreq_QtoD(fromDate, relation, &NULL_AF_INFO), relation, &NULL_AF_INFO); } + { return asfreq_DtoS(asfreq_QtoD(fromDate, relation, af_info), relation, &NULL_AF_INFO); } //************ FROM ANNUAL *************** @@ -925,62 +993,26 @@ return absdate + final_adj; } -static long asfreq_AtoQ(long fromDate, char relation, struct asfreq_info *af_info) { +static long asfreq_AtoA(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoA(asfreq_AtoD(fromDate, relation, af_info), relation, af_info); } - long quarter = asfreq_MtoQ(af_info->from_a_year_end, 'B', &NULL_AF_INFO); +static long asfreq_AtoQ(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoQ(asfreq_AtoD(fromDate, relation, af_info), relation, af_info); } - if (relation == 'B') { - return fromDate * 4 - 3 - (4 - quarter); - } else { - return fromDate * 4 - (4 - quarter); - } -} +static long asfreq_AtoM(long fromDate, char relation, struct asfreq_info *af_info) + { return asfreq_DtoM(asfreq_AtoD(fromDate, relation, af_info), relation, af_info); } -static long asfreq_AtoM(long fromDate, char relation, struct asfreq_info *af_info) { - if (relation == 'B') { - return fromDate * 12 - 11 - (12 - af_info->from_a_year_end); - } else { - return fromDate * 12 - (12 - af_info->from_a_year_end); - } -} - static long asfreq_AtoW(long fromDate, char relation, struct asfreq_info *af_info) { return asfreq_DtoW(asfreq_AtoD(fromDate, relation, af_info), relation, af_info); } static long asfreq_AtoB(long fromDate, char relation, struct asfreq_info *af_info) { - long year; - int month = (af_info->from_a_year_end + 1) % 12; + struct date_info dinfo; + if (dInfoCalc_SetFromAbsDate(&dinfo, asfreq_AtoD(fromDate, relation, af_info), + GREGORIAN_CALENDAR)) return INT_ERR_CODE; - struct date_info dailyDate; - - if (relation == 'B') { - - if (af_info->from_a_year_end == 12) {year = fromDate;} - else {year = fromDate - 1;} - - if (dInfoCalc_SetFromDateAndTime(&dailyDate, - year,month,1, 0, 0, 0, - GREGORIAN_CALENDAR)) return INT_ERR_CODE; - return DtoB_WeekendToMonday(dailyDate.absdate, dailyDate.day_of_week); - } else { - long absdate; - - if (af_info->from_a_year_end == 12) {year = fromDate+1;} - else {year = fromDate;} - - if (dInfoCalc_SetFromDateAndTime(&dailyDate, - year,month,1, 0, 0, 0, - GREGORIAN_CALENDAR)) return INT_ERR_CODE; - - absdate = dailyDate.absdate - 1; - - if(dInfoCalc_SetFromAbsDate(&dailyDate, - absdate, - GREGORIAN_CALENDAR)) return INT_ERR_CODE; - - return DtoB_WeekendToFriday(dailyDate.absdate, dailyDate.day_of_week); - } + if (relation == 'B') { return DtoB_WeekendToMonday(dinfo.absdate, dinfo.day_of_week); } + else { return DtoB_WeekendToFriday(dinfo.absdate, dinfo.day_of_week); } } static long asfreq_AtoH(long fromDate, char relation, struct asfreq_info *af_info) @@ -1007,6 +1039,7 @@ case FR_ANN: switch(toGroup) { + case FR_ANN: return &asfreq_AtoA; case FR_QTR: return &asfreq_AtoQ; case FR_MTH: return &asfreq_AtoM; case FR_WK: return &asfreq_AtoW; @@ -1022,6 +1055,7 @@ switch(toGroup) { case FR_ANN: return &asfreq_QtoA; + case FR_QTR: return &asfreq_QtoQ; case FR_MTH: return &asfreq_QtoM; case FR_WK: return &asfreq_QtoW; case FR_BUS: return &asfreq_QtoB; @@ -1251,7 +1285,7 @@ } static int calc_a_year_end(int freq, int group) { - int result = freq - group; + int result = (freq - group) % 12; if (result == 0) {return 12;} else {return result;} } @@ -1273,6 +1307,10 @@ case FR_ANN: { af_info->from_a_year_end = calc_a_year_end(fromFreq, fromGroup); } break; + case FR_QTR: { + af_info->from_q_year_end = calc_a_year_end(fromFreq, fromGroup); + } break; + } switch(toGroup) @@ -1283,21 +1321,13 @@ case FR_ANN: { af_info->to_a_year_end = calc_a_year_end(toFreq, toGroup); } break; + case FR_QTR: { + af_info->to_q_year_end = calc_a_year_end(toFreq, toGroup); + } break; } } -static int dInfo_year(struct date_info *dateObj) { return dateObj->year; } -static int dInfo_quarter(struct date_info *dateObj) { return dateObj->quarter; } -static int dInfo_month(struct date_info *dateObj) { return dateObj->month; } -static int dInfo_day(struct date_info *dateObj) { return dateObj->day; } -static int dInfo_day_of_year(struct date_info *dateObj) { return dateObj->day_of_year; } -static int dInfo_day_of_week(struct date_info *dateObj) { return dateObj->day_of_week; } -static int dInfo_week(struct date_info *dateObj) { return dInfoCalc_ISOWeek(dateObj); } -static int dInfo_hour(struct date_info *dateObj) { return dateObj->hour; } -static int dInfo_minute(struct date_info *dateObj) { return dateObj->minute; } -static int dInfo_second(struct date_info *dateObj) { return (int)dateObj->second; } - static double getAbsTime(int freq, long dailyDate, long originalDate) { long startOfDay, periodsPerDay; @@ -1361,9 +1391,9 @@ Py_DECREF(aliases); } -static int init_freq_group(int num_items, int num_roots, int group_const, - char item_abbrevs[][2][10], char group_prefixes[][10], - char item_const_names[][10]) { +static int init_freq_group(int num_items, int num_roots, int base_const, + char item_abbrevs[][2][10], char group_prefixes[][15], + char item_const_names[][15]) { int i; @@ -1382,8 +1412,8 @@ PyObject *alias_v1, *alias_v2; char *root, *alt; - if ((root = malloc((26) * sizeof(char))) == NULL) return INT_ERR_CODE; - if ((alt = malloc((26) * sizeof(char))) == NULL) return INT_ERR_CODE; + if ((root = malloc((30) * sizeof(char))) == NULL) return INT_ERR_CODE; + if ((alt = malloc((30) * sizeof(char))) == NULL) return INT_ERR_CODE; strcpy(root, group_prefixes[j]); strcpy(alt, group_prefixes[j]); @@ -1408,7 +1438,7 @@ PyTuple_SET_ITEM(aliases, j*k + 1, alias_v2); } - INIT_FREQ(item_const_names[i], group_const+i, aliases); + INIT_FREQ(item_const_names[i], base_const+i, aliases); } return 0; @@ -1440,10 +1470,15 @@ static int build_freq_dict() { - char ANN_prefixes[8][10] = { "A", "Y", "ANN", "ANNUAL", "ANNUALLY", + char ANN_prefixes[8][15] = { "A", "Y", "ANN", "ANNUAL", "ANNUALLY", "YR", "YEAR", "YEARLY" }; - char WK_prefixes[4][10] = { "W", "WK", "WEEK", "WEEKLY" }; + char QTRE_prefixes[8][15] = { "Q", "QTR", "QUARTER", "QUARTERLY", "Q-E", + "QTR-E", "QUARTER-E", "QUARTERLY-E"}; + char QTRS_prefixes[4][15] = { "Q-S", "QTR-S", "QUARTER-S", "QUARTERLY-S" }; + + char WK_prefixes[4][15] = { "W", "WK", "WEEK", "WEEKLY" }; + /* Note: order of this array must match up with how the Annual frequency constants are lined up */ char month_names[12][2][10] = { @@ -1460,7 +1495,16 @@ { "OCT", "OCTOBER" }, { "NOV", "NOVEMBER" }}; - char ANN_const_names[12][10] = { + char day_names[7][2][10] = { + { "SUN", "SUNDAY" }, + { "MON", "MONDAY" }, + { "TUE", "TUESDAY" }, + { "WED", "WEDNESDAY" }, + { "THU", "THURSDAY" }, + { "FRI", "FRIDAY" }, + { "SAT", "SATURDAY" }}; + + char ANN_const_names[12][15] = { "FR_ANNDEC", "FR_ANNJAN", "FR_ANNFEB", @@ -1474,16 +1518,35 @@ "FR_ANNOCT", "FR_ANNNOV"}; - char day_names[7][2][10] = { - { "SUN", "SUNDAY" }, - { "MON", "MONDAY" }, - { "TUE", "TUESDAY" }, - { "WED", "WEDNESDAY" }, - { "THU", "THURSDAY" }, - { "FRI", "FRIDAY" }, - { "SAT", "SATURDAY" }}; + char QTRE_const_names[12][15] = { + "FR_QTREDEC", + "FR_QTREJAN", + "FR_QTREFEB", + "FR_QTREMAR", + "FR_QTREAPR", + "FR_QTREMAY", + "FR_QTREJUN", + "FR_QTREJUL", + "FR_QTREAUG", + "FR_QTRESEP", + "FR_QTREOCT", + "FR_QTRENOV"}; - char WK_const_names[7][10] = { + char QTRS_const_names[12][15] = { + "FR_QTRSDEC", + "FR_QTRSJAN", + "FR_QTRSFEB", + "FR_QTRSMAR", + "FR_QTRSAPR", + "FR_QTRSMAY", + "FR_QTRSJUN", + "FR_QTRSJUL", + "FR_QTRSAUG", + "FR_QTRSSEP", + "FR_QTRSOCT", + "FR_QTRSNOV"}; + + char WK_const_names[7][15] = { "FR_WKSUN", "FR_WKMON", "FR_WKTUE", @@ -1498,9 +1561,6 @@ freq_dict_rev = PyDict_New(); freq_constants = PyDict_New(); - aliases = Py_BuildValue("(ssss)", "Q", "QTR", "QUARTER", "QUARTERLY"); - INIT_FREQ("FR_QTR", FR_QTR, aliases); - aliases = Py_BuildValue("(ssss)", "M", "MTH", "MONTH", "MONTHLY"); INIT_FREQ("FR_MTH", FR_MTH, aliases); @@ -1529,6 +1589,18 @@ return INT_ERR_CODE; } + ADD_FREQ_CONSTANT("FR_QTR", FR_QTR); + + if(init_freq_group(12, 8, FR_QTREDEC, + month_names, QTRE_prefixes, QTRE_const_names) == INT_ERR_CODE) { + return INT_ERR_CODE; + } + + if(init_freq_group(12, 4, FR_QTRSDEC, + month_names, QTRS_prefixes, QTRS_const_names) == INT_ERR_CODE) { + return INT_ERR_CODE; + } + ADD_FREQ_CONSTANT("FR_WK", FR_WK); if(init_freq_group(7, 4, FR_WK, @@ -1696,11 +1768,9 @@ if (month == def_info) { INIT_ERR(PyExc_ValueError, INSUFFICIENT_MSG); } - } else if (self->freq == FR_QTR) { - if (quarter == def_info && month == def_info) { + } else if (freq_group == FR_QTR) { + if (quarter == def_info) { INIT_ERR(PyExc_ValueError, INSUFFICIENT_MSG); - } else if (month != def_info) { - quarter = (int)asfreq_MtoQ(month, '-', &NULL_AF_INFO); } } else if (self->freq == FR_SEC) { if (month == def_info || @@ -1768,8 +1838,15 @@ self->value = adj_ordinal/7; } else if (self->freq == FR_MTH) { self->value = (year-1)*12 + month; - } else if (self->freq == FR_QTR) { - self->value = (year-1)*4 + quarter; + } else if (freq_group == FR_QTR) { + if ((self->freq - freq_group) > 12) { + // quarterly frequency with year determined by ending period + self->value = year*4 + quarter; + } else { + /* quarterly frequency with year determined by ending period + or has December year end*/ + self->value = (year-1)*4 + quarter; + } } else if (freq_group == FR_ANN) { self->value = year; } @@ -1890,8 +1967,13 @@ char *orig_fmt_str, *fmt_str; char *result; - char extra_fmts[1][2][10] = {{"%q", "^`XZ`^"}}; - int extra_fmts_found[1] = {0}; + int num_extra_fmts = 3; + + char extra_fmts[3][2][10] = {{"%q", "^`AB`^"}, + {"%f", "^`CD`^"}, + {"%F", "^`EF`^"}}; + + int extra_fmts_found[3] = {0,0,0}; int extra_fmts_found_one = 0; struct tm c_date; struct date_info tempDate; @@ -1931,7 +2013,7 @@ fmt_str = orig_fmt_str; // replace any special format characters with their place holder - for(i=0; i < 1; i++) { + for(i=0; i < num_extra_fmts; i++) { char *special_loc; if ((special_loc = strstr(fmt_str,extra_fmts[i][0])) != NULL) { char *tmp_str = fmt_str; @@ -1952,18 +2034,50 @@ if (extra_fmts_found_one) { free(fmt_str); } // replace any place holders with the appropriate value - for(i=0; i < 1; i++) { + for(i=0; i < num_extra_fmts; i++) { if (extra_fmts_found[i]) { char *tmp_str = result; char *extra_str; - if(strcmp(extra_fmts[i][0], "%q") == 0) { - if ((extra_str = malloc(2 * sizeof(char))) == NULL) { - free(tmp_str); - return PyErr_NoMemory(); + if (strcmp(extra_fmts[i][0], "%q") == 0 || + strcmp(extra_fmts[i][0], "%f") == 0 || + strcmp(extra_fmts[i][0], "%F") == 0) { + + struct asfreq_info af_info; + int qtr_freq, year, quarter, year_len; + + if (get_freq_group(self->freq) == FR_QTR) { + qtr_freq = self->freq; + } else { qtr_freq = FR_QTR; } + get_asfreq_info(FR_DAY, qtr_freq, &af_info); + + if(DtoQ_yq(absdate, &af_info, &year, &quarter) == INT_ERR_CODE) + { return NULL; } + + if(strcmp(extra_fmts[i][0], "%q") == 0) { + if ((extra_str = malloc(2 * sizeof(char))) == NULL) { + free(tmp_str); + return PyErr_NoMemory(); + } + sprintf(extra_str, "%i", quarter); + } else { + if ((qtr_freq % 1000) > 12) { year -= 1; } + + if (strcmp(extra_fmts[i][0], "%f") == 0) { + year_len = 2; + year = year % 100; + } else { year_len = 4; } + + if ((extra_str = malloc((year_len+1) * sizeof(char))) == NULL) { + free(tmp_str); + return PyErr_NoMemory(); + } + + if (year_len == 2 && year < 10) { + sprintf(extra_str, "0%i", year); + } else { sprintf(extra_str, "%i", year); } } - sprintf(extra_str, "%i", tempDate.quarter); } else { PyErr_SetString(PyExc_RuntimeError,"Unrecogized fmt string"); return NULL; @@ -1971,6 +2085,7 @@ result = str_replace(result, extra_fmts[i][1], extra_str); free(tmp_str); + free(extra_str); if (result == NULL) { return NULL; } } } @@ -1989,7 +2104,7 @@ PyObject *string_arg, *retval; if (freq_group == FR_ANN) { string_arg = Py_BuildValue("(s)", "%Y"); } - else if (freq_group == FR_QTR) { string_arg = Py_BuildValue("(s)", "%YQ%q"); } + else if (freq_group == FR_QTR) { string_arg = Py_BuildValue("(s)", "%FQ%q"); } else if (freq_group == FR_MTH) { string_arg = Py_BuildValue("(s)", "%b-%Y"); } else if (freq_group == FR_DAY || freq_group == FR_BUS || @@ -2222,11 +2337,45 @@ return PyInt_FromLong(dinfo.year); } +static int _DateObject_quarter_year(DateObject *self, int *year, int *quarter) { + + PyObject *daily_obj; + long absdate; + + struct asfreq_info af_info; + int qtr_freq; + + daily_obj = DateObject_toordinal(self); + absdate = PyInt_AsLong(daily_obj); + Py_DECREF(daily_obj); + + if (get_freq_group(self->freq) == FR_QTR) { + qtr_freq = self->freq; + } else { qtr_freq = FR_QTR; } + get_asfreq_info(FR_DAY, qtr_freq, &af_info); + + if(DtoQ_yq(absdate, &af_info, year, quarter) == INT_ERR_CODE) + { return INT_ERR_CODE; } + + if ((qtr_freq % 1000) > 12) { *year -= 1; } + + return 0; +} + static PyObject * +DateObject_qyear(DateObject *self, void *closure) { + int year, quarter; + if(_DateObject_quarter_year(self, + &year, &quarter) == INT_ERR_CODE) { return NULL; } + return PyInt_FromLong(year); +} + +static PyObject * DateObject_quarter(DateObject *self, void *closure) { - struct date_info dinfo; - if(DateObject_set_date_info(self, &dinfo) == -1) return NULL; - return PyInt_FromLong(dinfo.quarter); + int year, quarter; + if(_DateObject_quarter_year(self, + &year, &quarter) == INT_ERR_CODE) { return NULL; } + return PyInt_FromLong(quarter); } static PyObject * @@ -2305,6 +2454,12 @@ static PyGetSetDef DateObject_getseters[] = { {"year", (getter)DateObject_year, (setter)DateObject_ReadOnlyErr, "Returns the year.", NULL}, + {"qyear", (getter)DateObject_qyear, (setter)DateObject_ReadOnlyErr, + "For quarterly frequency dates, returns the year corresponding to the\n" + "year end (start) month. When using QTR or QTR-E based quarterly\n" + "frequencies, this is the fiscal year in a financial context.\n\n" + "For non-quarterly dates, this simply returns the year of the date.", + NULL}, {"quarter", (getter)DateObject_quarter, (setter)DateObject_ReadOnlyErr, "Returns the quarter.", NULL}, {"month", (getter)DateObject_month, (setter)DateObject_ReadOnlyErr, @@ -2785,74 +2940,68 @@ PyArrayObject *array; PyArrayObject *newArray; PyArrayIterObject *iterSource, *iterResult; - struct date_info convDate; - PyObject *val; - long dateNum, dInfo; - long absdate; - double abstime; + PyObject* (*getDateInfo)(DateObject*, void*) = NULL; - long (*toDaily)(long, char, struct asfreq_info*) = NULL; - int (*getDateInfo)(struct date_info*) = NULL; - struct asfreq_info af_info; - if (!PyArg_ParseTuple(args, "Ois:getDateInfo(array, freq, info)", &array, &freq, &info)) return NULL; newArray = (PyArrayObject *)PyArray_Copy(array); iterSource = (PyArrayIterObject *)PyArray_IterNew((PyObject *)array); iterResult = (PyArrayIterObject *)PyArray_IterNew((PyObject *)newArray); - toDaily = get_asfreq_func(freq, FR_DAY, 0); - get_asfreq_info(freq, FR_DAY, &af_info); switch(*info) { case 'Y': //year - getDateInfo = &dInfo_year; + getDateInfo = &DateObject_year; break; + case 'F': //"fiscal" year + getDateInfo = &DateObject_qyear; + break; case 'Q': //quarter - getDateInfo = &dInfo_quarter; + getDateInfo = &DateObject_quarter; break; case 'M': //month - getDateInfo = &dInfo_month; + getDateInfo = &DateObject_month; break; case 'D': //day - getDateInfo = &dInfo_day; + getDateInfo = &DateObject_day; break; case 'R': //day of year - getDateInfo = &dInfo_day_of_year; + getDateInfo = &DateObject_day_of_year; break; case 'W': //day of week - getDateInfo = &dInfo_day_of_week; + getDateInfo = &DateObject_day_of_week; break; case 'I': //week of year - getDateInfo = &dInfo_week; + getDateInfo = &DateObject_week; break; case 'H': //hour - getDateInfo = &dInfo_hour; + getDateInfo = &DateObject_hour; break; case 'T': //minute - getDateInfo = &dInfo_minute; + getDateInfo = &DateObject_minute; break; case 'S': //second - getDateInfo = &dInfo_second; + getDateInfo = &DateObject_second; break; default: return NULL; } while (iterSource->index < iterSource->size) { + DateObject *curr_date; + PyObject *val, *dInfo; val = PyArray_GETITEM(array, iterSource->dataptr); - dateNum = PyInt_AsLong(val); - Py_DECREF(val); - CHECK_ASFREQ(absdate = toDaily(dateNum, 'B', &af_info)); - abstime = getAbsTime(freq, absdate, dateNum); + curr_date = DateObject_FromFreqAndValue(freq, PyInt_AsLong(val)); + dInfo = getDateInfo(curr_date, NULL); - if(dInfoCalc_SetFromAbsDateTime(&convDate, absdate, abstime, GREGORIAN_CALENDAR)) return NULL; - dInfo = getDateInfo(&convDate); + PyArray_SETITEM(newArray, iterResult->dataptr, dInfo); - PyArray_SETITEM(newArray, iterResult->dataptr, PyInt_FromLong(dInfo)); + Py_DECREF(val); + Py_DECREF(curr_date); + Py_DECREF(dInfo); PyArray_ITER_NEXT(iterSource); PyArray_ITER_NEXT(iterResult); From scipy-svn at scipy.org Fri Mar 23 11:00:27 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 23 Mar 2007 10:00:27 -0500 (CDT) Subject: [Scipy-svn] r2868 - trunk/Lib/sandbox/timeseries Message-ID: <20070323150027.9BBB539C229@new.scipy.org> Author: mattknox_ca Date: 2007-03-23 10:00:24 -0500 (Fri, 23 Mar 2007) New Revision: 2868 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: added qyear property to DateArray Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-23 14:59:50 UTC (rev 2867) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-23 15:00:24 UTC (rev 2868) @@ -269,6 +269,15 @@ "Returns the year." return self.__getdateinfo__('Y') @property + def qyear(self): + """For quarterly frequency dates, returns the year corresponding to the +year end (start) month. When using QTR or QTR-E based quarterly +frequencies, this is the fiscal year in a financial context. + +For non-quarterly dates, this simply returns the year of the date.""" + + return self.__getdateinfo__('F') + @property def second(self): "Returns the seconds." return self.__getdateinfo__('S') From scipy-svn at scipy.org Fri Mar 23 11:01:01 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Fri, 23 Mar 2007 10:01:01 -0500 (CDT) Subject: [Scipy-svn] r2869 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070323150101.44EAF39C229@new.scipy.org> Author: mattknox_ca Date: 2007-03-23 10:00:56 -0500 (Fri, 23 Mar 2007) New Revision: 2869 Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py Log: updated unit tests for new weekly, annual, and quarterly frequencies Modified: trunk/Lib/sandbox/timeseries/tests/test_dates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-03-23 15:00:24 UTC (rev 2868) +++ trunk/Lib/sandbox/timeseries/tests/test_dates.py 2007-03-23 15:00:56 UTC (rev 2869) @@ -26,6 +26,7 @@ from maskedarray.testutils import assert_equal, assert_array_equal import timeseries as ts +from timeseries import const as C from timeseries.parser import DateFromString, DateTimeFromString from timeseries import * from timeseries.cseries import freq_dict @@ -114,7 +115,7 @@ "Tests that values don't get mutated when constructing dates from a value" print "starting test_consistent_value..." freqs = [x[0] for x in freq_dict.values() if x[0] != 'U'] - print freqs + for f in freqs: today = thisday(f) assert_equal(Date(freq=f, value=today.value), today) @@ -143,7 +144,17 @@ def test_properties(self): a_date = Date(freq='A', year=2007) - q_date = Date(freq='Q', year=2007, quarter=1) + + q_date = Date(freq=C.FR_QTREDEC, year=2007, quarter=1) + + qedec_date = Date(freq=C.FR_QTREDEC, year=2007, quarter=1) + qejan_date = Date(freq=C.FR_QTREJAN, year=2007, quarter=1) + qejun_date = Date(freq=C.FR_QTREJUN, year=2007, quarter=1) + + qsdec_date = Date(freq=C.FR_QTREDEC, year=2007, quarter=1) + qsjan_date = Date(freq=C.FR_QTREJAN, year=2007, quarter=1) + qsjun_date = Date(freq=C.FR_QTREJUN, year=2007, quarter=1) + m_date = Date(freq='M', year=2007, month=1) w_date = Date(freq='W', year=2007, month=1, day=7) b_date = Date(freq='B', year=2007, month=1, day=1) @@ -158,8 +169,10 @@ assert_equal(a_date.year, 2007) for x in range(3): - assert_equal((q_date+x).year, 2007) - assert_equal((q_date+x).quarter, x+1) + for qd in (qedec_date, qejan_date, qejun_date, + qsdec_date, qsjan_date, qsjun_date): + assert_equal((qd+x).qyear, 2007) + assert_equal((qd+x).quarter, x+1) for x in range(11): @@ -240,6 +253,10 @@ for dWrap, assert_func in self.dateWrap: date_A = dWrap(Date(freq='A', year=2007)) + + date_AJAN = dWrap(Date(freq=C.FR_ANNJAN, year=2007)) + date_AJUN = dWrap(Date(freq=C.FR_ANNJUN, year=2007)) + date_A_to_Q_before = dWrap(Date(freq='Q', year=2007, quarter=1)) date_A_to_Q_after = dWrap(Date(freq='Q', year=2007, quarter=4)) date_A_to_M_before = dWrap(Date(freq='M', year=2007, month=1)) @@ -263,6 +280,11 @@ date_A_to_S_after = dWrap(Date(freq='S', year=2007, month=12, day=31, hour=23, minute=59, second=59)) + date_AJAN_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=31)) + date_AJAN_to_D_before = dWrap(Date(freq='D', year=2006, month=2, day=1)) + date_AJUN_to_D_after = dWrap(Date(freq='D', year=2007, month=6, day=30)) + date_AJUN_to_D_before = dWrap(Date(freq='D', year=2006, month=7, day=1)) + assert_func(date_A.asfreq('Q', "BEFORE"), date_A_to_Q_before) assert_func(date_A.asfreq('Q', "AFTER"), date_A_to_Q_after) assert_func(date_A.asfreq('M', "BEFORE"), date_A_to_M_before) @@ -280,13 +302,26 @@ assert_func(date_A.asfreq('S', "BEFORE"), date_A_to_S_before) assert_func(date_A.asfreq('S', "AFTER"), date_A_to_S_after) + assert_func(date_AJAN.asfreq('D', "BEFORE"), date_AJAN_to_D_before) + assert_func(date_AJAN.asfreq('D', "AFTER"), date_AJAN_to_D_after) + assert_func(date_AJUN.asfreq('D', "BEFORE"), date_AJUN_to_D_before) + assert_func(date_AJUN.asfreq('D', "AFTER"), date_AJUN_to_D_after) + def test_conv_quarterly(self): "frequency conversion tests: from Quarterly Frequency" for dWrap, assert_func in self.dateWrap: date_Q = dWrap(Date(freq='Q', year=2007, quarter=1)) date_Q_end_of_year = dWrap(Date(freq='Q', year=2007, quarter=4)) + + date_QEJAN = dWrap(Date(freq=C.FR_QTREJAN, year=2007, quarter=1)) + date_QEJUN = dWrap(Date(freq=C.FR_QTREJUN, year=2007, quarter=1)) + + date_QSJAN = dWrap(Date(freq=C.FR_QTRSJAN, year=2007, quarter=1)) + date_QSJUN = dWrap(Date(freq=C.FR_QTRSJUN, year=2007, quarter=1)) + date_QSDEC = dWrap(Date(freq=C.FR_QTRSDEC, year=2007, quarter=1)) + date_Q_to_A = dWrap(Date(freq='A', year=2007)) date_Q_to_M_before = dWrap(Date(freq='M', year=2007, month=1)) date_Q_to_M_after = dWrap(Date(freq='M', year=2007, month=3)) @@ -309,6 +344,21 @@ date_Q_to_S_after = dWrap(Date(freq='S', year=2007, month=3, day=31, hour=23, minute=59, second=59)) + date_QEJAN_to_D_before = dWrap(Date(freq='D', year=2006, month=2, day=1)) + date_QEJAN_to_D_after = dWrap(Date(freq='D', year=2006, month=4, day=30)) + + date_QEJUN_to_D_before = dWrap(Date(freq='D', year=2006, month=7, day=1)) + date_QEJUN_to_D_after = dWrap(Date(freq='D', year=2006, month=9, day=30)) + + date_QSJAN_to_D_before = dWrap(Date(freq='D', year=2007, month=2, day=1)) + date_QSJAN_to_D_after = dWrap(Date(freq='D', year=2007, month=4, day=30)) + + date_QSJUN_to_D_before = dWrap(Date(freq='D', year=2007, month=7, day=1)) + date_QSJUN_to_D_after = dWrap(Date(freq='D', year=2007, month=9, day=30)) + + date_QSDEC_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_QSDEC_to_D_after = dWrap(Date(freq='D', year=2007, month=3, day=31)) + assert_func(date_Q.asfreq('A'), date_Q_to_A) assert_func(date_Q_end_of_year.asfreq('A'), date_Q_to_A) @@ -327,7 +377,18 @@ assert_func(date_Q.asfreq('S', "BEFORE"), date_Q_to_S_before) assert_func(date_Q.asfreq('S', "AFTER"), date_Q_to_S_after) + assert_func(date_QEJAN.asfreq('D', "BEFORE"), date_QEJAN_to_D_before) + assert_func(date_QEJAN.asfreq('D', "AFTER"), date_QEJAN_to_D_after) + assert_func(date_QEJUN.asfreq('D', "BEFORE"), date_QEJUN_to_D_before) + assert_func(date_QEJUN.asfreq('D', "AFTER"), date_QEJUN_to_D_after) + assert_func(date_QSJAN.asfreq('D', "BEFORE"), date_QSJAN_to_D_before) + assert_func(date_QSJAN.asfreq('D', "AFTER"), date_QSJAN_to_D_after) + assert_func(date_QSJUN.asfreq('D', "BEFORE"), date_QSJUN_to_D_before) + assert_func(date_QSJUN.asfreq('D', "AFTER"), date_QSJUN_to_D_after) + assert_func(date_QSDEC.asfreq('D', "BEFORE"), date_QSDEC_to_D_before) + assert_func(date_QSDEC.asfreq('D', "AFTER"), date_QSDEC_to_D_after) + def test_conv_monthly(self): "frequency conversion tests: from Monthly Frequency" @@ -380,6 +441,30 @@ for dWrap, assert_func in self.dateWrap: date_W = dWrap(Date(freq='W', year=2007, month=1, day=1)) + + date_WSUN = dWrap(Date(freq='W-SUN', year=2007, month=1, day=7)) + date_WSAT = dWrap(Date(freq='W-SAT', year=2007, month=1, day=6)) + date_WFRI = dWrap(Date(freq='W-FRI', year=2007, month=1, day=5)) + date_WTHU = dWrap(Date(freq='W-THU', year=2007, month=1, day=4)) + date_WWED = dWrap(Date(freq='W-WED', year=2007, month=1, day=3)) + date_WTUE = dWrap(Date(freq='W-TUE', year=2007, month=1, day=2)) + date_WMON = dWrap(Date(freq='W-MON', year=2007, month=1, day=1)) + + date_WSUN_to_D_before = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_WSUN_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=7)) + date_WSAT_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=31)) + date_WSAT_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=6)) + date_WFRI_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=30)) + date_WFRI_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=5)) + date_WTHU_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=29)) + date_WTHU_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=4)) + date_WWED_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=28)) + date_WWED_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=3)) + date_WTUE_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=27)) + date_WTUE_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=2)) + date_WMON_to_D_before = dWrap(Date(freq='D', year=2006, month=12, day=26)) + date_WMON_to_D_after = dWrap(Date(freq='D', year=2007, month=1, day=1)) + date_W_end_of_year = dWrap(Date(freq='W', year=2007, month=12, day=31)) date_W_end_of_quarter = dWrap(Date(freq='W', year=2007, month=3, day=31)) date_W_end_of_month = dWrap(Date(freq='W', year=2007, month=1, day=31)) @@ -428,8 +513,25 @@ assert_func(date_W.asfreq('B', "BEFORE"), date_W_to_B_before) assert_func(date_W.asfreq('B', "AFTER"), date_W_to_B_after) + assert_func(date_W.asfreq('D', "BEFORE"), date_W_to_D_before) assert_func(date_W.asfreq('D', "AFTER"), date_W_to_D_after) + + assert_func(date_WSUN.asfreq('D', "BEFORE"), date_WSUN_to_D_before) + assert_func(date_WSUN.asfreq('D', "AFTER"), date_WSUN_to_D_after) + assert_func(date_WSAT.asfreq('D', "BEFORE"), date_WSAT_to_D_before) + assert_func(date_WSAT.asfreq('D', "AFTER"), date_WSAT_to_D_after) + assert_func(date_WFRI.asfreq('D', "BEFORE"), date_WFRI_to_D_before) + assert_func(date_WFRI.asfreq('D', "AFTER"), date_WFRI_to_D_after) + assert_func(date_WTHU.asfreq('D', "BEFORE"), date_WTHU_to_D_before) + assert_func(date_WTHU.asfreq('D', "AFTER"), date_WTHU_to_D_after) + assert_func(date_WWED.asfreq('D', "BEFORE"), date_WWED_to_D_before) + assert_func(date_WWED.asfreq('D', "AFTER"), date_WWED_to_D_after) + assert_func(date_WTUE.asfreq('D', "BEFORE"), date_WTUE_to_D_before) + assert_func(date_WTUE.asfreq('D', "AFTER"), date_WTUE_to_D_after) + assert_func(date_WMON.asfreq('D', "BEFORE"), date_WMON_to_D_before) + assert_func(date_WMON.asfreq('D', "AFTER"), date_WMON_to_D_after) + assert_func(date_W.asfreq('H', "BEFORE"), date_W_to_H_before) assert_func(date_W.asfreq('H', "AFTER"), date_W_to_H_after) assert_func(date_W.asfreq('T', "BEFORE"), date_W_to_T_before) @@ -502,7 +604,19 @@ date_B_monday = dWrap(Date(freq='B', year=2007, month=1, day=8)) date_D_to_A = dWrap(Date(freq='A', year=2007)) - date_D_to_Q = dWrap(Date(freq='Q', year=2007, quarter=1)) + + date_Deoq_to_AJAN = dWrap(Date(freq='A-JAN', year=2008)) + date_Deoq_to_AJUN = dWrap(Date(freq='A-JUN', year=2007)) + date_Deoq_to_ADEC = dWrap(Date(freq='A-DEC', year=2007)) + + date_D_to_QEJAN = dWrap(Date(freq=C.FR_QTREJAN, year=2007, quarter=4)) + date_D_to_QEJUN = dWrap(Date(freq=C.FR_QTREJUN, year=2007, quarter=3)) + date_D_to_QEDEC = dWrap(Date(freq=C.FR_QTREDEC, year=2007, quarter=1)) + + date_D_to_QSJAN = dWrap(Date(freq=C.FR_QTRSJAN, year=2006, quarter=4)) + date_D_to_QSJUN = dWrap(Date(freq=C.FR_QTRSJUN, year=2006, quarter=3)) + date_D_to_QSDEC = dWrap(Date(freq=C.FR_QTRSDEC, year=2007, quarter=1)) + date_D_to_M = dWrap(Date(freq='M', year=2007, month=1)) date_D_to_W = dWrap(Date(freq='W', year=2007, month=1, day=7)) @@ -520,9 +634,19 @@ hour=23, minute=59, second=59)) assert_func(date_D.asfreq('A'), date_D_to_A) + + assert_func(date_D_end_of_quarter.asfreq('A-JAN'), date_Deoq_to_AJAN) + assert_func(date_D_end_of_quarter.asfreq('A-JUN'), date_Deoq_to_AJUN) + assert_func(date_D_end_of_quarter.asfreq('A-DEC'), date_Deoq_to_ADEC) + assert_func(date_D_end_of_year.asfreq('A'), date_D_to_A) - assert_func(date_D.asfreq('Q'), date_D_to_Q) - assert_func(date_D_end_of_quarter.asfreq('Q'), date_D_to_Q) + assert_func(date_D_end_of_quarter.asfreq('Q'), date_D_to_QEDEC) + assert_func(date_D.asfreq(C.FR_QTREJAN), date_D_to_QEJAN) + assert_func(date_D.asfreq(C.FR_QTREJUN), date_D_to_QEJUN) + assert_func(date_D.asfreq(C.FR_QTREDEC), date_D_to_QEDEC) + assert_func(date_D.asfreq(C.FR_QTRSJAN), date_D_to_QSJAN) + assert_func(date_D.asfreq(C.FR_QTRSJUN), date_D_to_QSJUN) + assert_func(date_D.asfreq(C.FR_QTRSDEC), date_D_to_QSDEC) assert_func(date_D.asfreq('M'), date_D_to_M) assert_func(date_D_end_of_month.asfreq('M'), date_D_to_M) assert_func(date_D.asfreq('W'), date_D_to_W) From scipy-svn at scipy.org Mon Mar 26 11:11:50 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 26 Mar 2007 10:11:50 -0500 (CDT) Subject: [Scipy-svn] r2870 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070326151150.0DDE039C272@new.scipy.org> Author: mattknox_ca Date: 2007-03-26 10:11:46 -0500 (Mon, 26 Mar 2007) New Revision: 2870 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: updated doc string for strfmt method of Date class Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-23 15:00:56 UTC (rev 2869) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-26 15:11:46 UTC (rev 2870) @@ -1958,8 +1958,17 @@ ":Parameters:\n" " - fmt : string\n" " Formatting string. Uses the same directives as in the time.strftime\n" -" function in the standard Python time module. In addition, a %q directive\n" -" directive is recognized which represents the 'quarter' of the date"; +" function in the standard Python time module. In addition, a few other\n" +" directives are supported:\n" +" %q - the 'quarter' of the date\n" +" %f - Year without century as a decimal number [00,99]. The\n" +" 'year' in this case is the year of the date determined by\n" +" the year for the current quarter. This is the same as %y\n" +" unless the Date is one of the 'qtr-s' frequencies\n" +" %F - Year with century as a decimal number. The 'year' in this\n" +" case is the year of the date determined by the year for\n" +" the current quarter. This is the same as %Y unless the\n" +" Date is one of the 'qtr-s' frequencies\n"; static PyObject * DateObject_strfmt(DateObject *self, PyObject *args) { @@ -2501,18 +2510,18 @@ 0, /* nb_positive */ 0, /* nb_absolute */ 0, /* nb_nonzero */ - 0, /* nb_invert */ - 0, /* nb_lshift */ - 0, /* nb_rshift */ - 0, /* nb_and */ - 0, /* nb_xor */ - 0, /* nb_or */ - 0, /* nb_coerce */ - (unaryfunc)DateObject___int__, /* nb_int */ - (unaryfunc)0, /* nb_long */ - (unaryfunc)DateObject___float__, /* nb_float */ - (unaryfunc)0, /* nb_oct */ - (unaryfunc)0, /* nb_hex */ + 0, /* nb_invert */ + 0, /* nb_lshift */ + 0, /* nb_rshift */ + 0, /* nb_and */ + 0, /* nb_xor */ + 0, /* nb_or */ + 0, /* nb_coerce */ + (unaryfunc)DateObject___int__, /* nb_int */ + (unaryfunc)0, /* nb_long */ + (unaryfunc)DateObject___float__, /* nb_float */ + (unaryfunc)0, /* nb_oct */ + (unaryfunc)0, /* nb_hex */ }; static PyMethodDef DateObject_methods[] = { @@ -3051,9 +3060,9 @@ PyModule_AddObject(m, "Date", (PyObject *)&DateType); if(build_freq_dict(m) == INT_ERR_CODE) { - PyErr_SetString( \ - PyExc_ImportError, \ - "initialization of module timeseries.cseries failed"); + PyErr_SetString( \ + PyExc_ImportError, \ + "initialization of module timeseries.cseries failed"); return; }; From scipy-svn at scipy.org Mon Mar 26 11:40:36 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 26 Mar 2007 10:40:36 -0500 (CDT) Subject: [Scipy-svn] r2871 - trunk/Lib/sandbox/timeseries Message-ID: <20070326154036.8F70A39C26E@new.scipy.org> Author: mattknox_ca Date: 2007-03-26 10:40:30 -0500 (Mon, 26 Mar 2007) New Revision: 2871 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: updated documentation for prevbusday function Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-26 15:11:46 UTC (rev 2870) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-26 15:40:30 UTC (rev 2871) @@ -91,7 +91,17 @@ #####--------------------------------------------------------------------------- def prevbusday(day_end_hour=18, day_end_min=0): - "Returns the previous business day." + """Returns the previous business day (Monday-Friday) at business frequency. + +:Parameters: + - day_end_hour : (int, *[18]* ) + - day_end_min : (int, *[0]*) + +:Return values: + If it is currently Saturday or Sunday, then the preceding Friday will be + returned. If it is later than the specified day_end_hour and day_end_min, + thisday('b') will be returned. Otherwise, thisday('b')-1 will be returned. +""" tempDate = dt.datetime.now() dateNum = tempDate.hour + float(tempDate.minute)/60 checkNum = day_end_hour + float(day_end_min)/60 From scipy-svn at scipy.org Mon Mar 26 15:36:08 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 26 Mar 2007 14:36:08 -0500 (CDT) Subject: [Scipy-svn] r2872 - trunk/Lib/sandbox/timeseries Message-ID: <20070326193608.0414B39C175@new.scipy.org> Author: mattknox_ca Date: 2007-03-26 14:36:03 -0500 (Mon, 26 Mar 2007) New Revision: 2872 Modified: trunk/Lib/sandbox/timeseries/tseries.py Log: - added "pct" function - changed series argument of concatenate_series to *series Modified: trunk/Lib/sandbox/timeseries/tseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tseries.py 2007-03-26 15:40:30 UTC (rev 2871) +++ trunk/Lib/sandbox/timeseries/tseries.py 2007-03-26 19:36:03 UTC (rev 2872) @@ -48,7 +48,8 @@ 'time_series', 'tsmasked', 'mask_period','mask_inside_period','mask_outside_period','compressed', 'adjust_endpoints','align_series','aligned','convert','group_byperiod', -'tshift','fill_missing_dates', 'stack', 'concatenate_series','empty_like', +'pct','tshift','fill_missing_dates', 'stack', 'concatenate_series', +'empty_like', 'day_of_week','day_of_year','day','month','quarter','year', 'hour','minute','second', 'tofile','asrecords','flatten', 'check_observed', @@ -1231,33 +1232,28 @@ #............................................................................... def tshift(series, nper, copy=True): """Returns a series of the same size as `series`, with the same -start_date and end_date, but values shifted by `nper`. This is useful -for doing things like calculating a percentage change. -Eg. pct_change = 100 * (series/tshift(series, -1, copy=False) - 1) -Note: By default the data is copied, but if you are using the result in -a way that is going to make a copy anyway (like the above example) then -you may want to bypass copying the data. +start_date and end_date, but values shifted by `nper`. :Parameters: - - `series` (TimeSeries) : TimeSeries object to shift - - `nper` (int) : number of periods to shift. Negative numbers - shift values to the right, positive to the left - - `copy` (boolean, *[True]*) : copies the data if True, returns - a view if False. + - series : (TimeSeries) + TimeSeries object to shift + - nper : (int) + number of periods to shift. Negative numbers shift values to the + right, positive to the left + - copy : (boolean, *[True]*) + copies the data if True, returns a view if False. :Example: ->>> series = tseries.time_series([0,1,2,3], start_date=tdates.Date(freq='A', year=2005)) +>>> series = time_series([0,1,2,3], start_date=Date(freq='A', year=2005)) >>> series timeseries(data = [0 1 2 3], dates = [2005 ... 2008], - freq = A) + freq = A-DEC) >>> tshift(series, -1) timeseries(data = [-- 0 1 2], dates = [2005 ... 2008], - freq = A) -""" - #Backup series attributes - options = _attrib_dict(series) + freq = A-DEC) +>>> pct_change = 100 * (series/tshift(series, -1, copy=False) - 1)""" newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype), mask=True) if copy: @@ -1278,6 +1274,36 @@ return newseries TimeSeries.tshift = tshift #............................................................................... +def pct(series, nper=1): + """Returns the rolling percentage change of the series. + +:Parameters: + - series : (TimeSeries) + TimeSeries object to to calculate percentage chage for + - nper : (int) + number of periods for percentage change + +:Example: +>>> series = time_series([2.,1.,2.,3.], start_date=Date(freq='A', year=2005)) +>>> pct(series) +timeseries(data = [-- -50.0 100.0 50.0], + dates = [2005 ... 2008], + freq = A-DEC) +>>> pct(series, 2) +timeseries(data = [-- -- 0.0 200.0], + dates = [2005 ... 2008], + freq = A-DEC)""" + + newdata = masked_array(numeric.empty(series.shape, dtype=series.dtype), + mask=True) + if nper < newdata.size: + newdata[nper:] = 100*(series._series[nper:]/series._series[:-nper] - 1) + newseries = newdata.view(type(series)) + newseries._dates = series._dates + newseries.copy_attributes(series) + return newseries +TimeSeries.pct = pct +#............................................................................... def fill_missing_dates(data, dates=None, freq=None,fill_value=None): """Finds and fills the missing dates in a time series. The data corresponding to the initially missing dates are masked, or filled to @@ -1378,13 +1404,18 @@ return time_series(MA.column_stack(series), series[0]._dates, **_attrib_dict(series[0])) #............................................................................... -def concatenate_series(series, keep_gap=True): +def concatenate_series(*series, **kwargs): """Concatenates a sequence of series, by chronological order. Overlapping data are processed in a FIFO basis: the data from the first series of the sequence will be overwritten by the data of the second series, and so forth. If keep_gap is true, any gap between consecutive, non overlapping series are kept: the corresponding data are masked. """ + + keep_gap = kwargs.pop('keep_gap', True) + if len(kwargs) > 0: + raise KeyError("unrecognized keyword: %s" % list(kwargs)[0]) + common_f = _compare_frequencies(*series) start_date = min([s.start_date for s in series if s.start_date is not None]) end_date = max([s.end_date for s in series if s.end_date is not None]) From scipy-svn at scipy.org Mon Mar 26 15:37:16 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Mon, 26 Mar 2007 14:37:16 -0500 (CDT) Subject: [Scipy-svn] r2873 - trunk/Lib/sandbox/timeseries/tests Message-ID: <20070326193716.ACAD139C175@new.scipy.org> Author: mattknox_ca Date: 2007-03-26 14:37:12 -0500 (Mon, 26 Mar 2007) New Revision: 2873 Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py Log: updated test for concatenate_series to use new argument style for multiple series Modified: trunk/Lib/sandbox/timeseries/tests/test_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-03-26 19:36:03 UTC (rev 2872) +++ trunk/Lib/sandbox/timeseries/tests/test_timeseries.py 2007-03-26 19:37:12 UTC (rev 2873) @@ -540,19 +540,19 @@ # ser_1 = time_series(data, dates) ser_2 = time_series(data, dates=dates+10) - newseries = concatenate_series([ser_1, ser_2]) + newseries = concatenate_series(ser_1, ser_2) assert_equal(newseries._data,[0,1,2,3,4,0,0,0,0,0,0,1,2,3,4]) assert_equal(newseries._mask,[1,0,0,0,0]+[1]*5+[1,0,0,0,0]) # ser_1 = time_series(data, dates) ser_2 = time_series(data, dates=dates+10) - newseries = concatenate_series([ser_1, ser_2], keep_gap=False) + newseries = concatenate_series(ser_1, ser_2, keep_gap=False) assert_equal(newseries._data,[0,1,2,3,4,0,1,2,3,4]) assert_equal(newseries._mask,[1,0,0,0,0]+[1,0,0,0,0]) assert newseries.has_missing_dates() # ser_2 = time_series(data, dates=dates+3) - newseries = concatenate_series([ser_1, ser_2]) + newseries = concatenate_series(ser_1, ser_2) assert_equal(newseries._data,[0,1,2,0,1,2,3,4]) assert_equal(newseries._mask,[1,0,0,1,0,0,0,0]) # From scipy-svn at scipy.org Tue Mar 27 02:39:04 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 27 Mar 2007 01:39:04 -0500 (CDT) Subject: [Scipy-svn] r2874 - in trunk/Lib/sandbox/pyloess: . src tests Message-ID: <20070327063904.81D0639C08F@new.scipy.org> Author: pierregm Date: 2007-03-27 01:38:36 -0500 (Tue, 27 Mar 2007) New Revision: 2874 Added: trunk/Lib/sandbox/pyloess/examples.py trunk/Lib/sandbox/pyloess/mpyloess.py trunk/Lib/sandbox/pyloess/src/_mloess.c trunk/Lib/sandbox/pyloess/src/_mloess.pyx trunk/Lib/sandbox/pyloess/tests/test_mpyloess.py Modified: trunk/Lib/sandbox/pyloess/pyloess.py trunk/Lib/sandbox/pyloess/setup.py trunk/Lib/sandbox/pyloess/src/_loess.c trunk/Lib/sandbox/pyloess/src/_loess.pyx trunk/Lib/sandbox/pyloess/src/c_python.pxd trunk/Lib/sandbox/pyloess/tests/test_pyloess.py Log: pyloess : lowess now an object w/ inputs/parameters/outputs, to match loess pyloess : in lowess, renamed the f parameter to 'span' for readability _loess.pyx : Fixed a bug w/ model.degree _loess.pyx : Forced inputs to float_ mpyloess/_mloess.pyx : Add loess support for masked array Added: trunk/Lib/sandbox/pyloess/examples.py =================================================================== --- trunk/Lib/sandbox/pyloess/examples.py 2007-03-26 19:37:12 UTC (rev 2873) +++ trunk/Lib/sandbox/pyloess/examples.py 2007-03-27 06:38:36 UTC (rev 2874) @@ -0,0 +1,63 @@ +""" +Wrapper to lowess and stl routines. + +:author: Pierre GF Gerard-Marchant +:contact: pierregm_at_uga_edu +:date: $Date$ +:version: $Id$ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author$)" +__version__ = '1.0' +__revision__ = "$Revision$" +__date__ = '$Date$' + + +import os + +import numpy +from numpy import fromiter +from numpy import bool_, float_ + +#import maskedarray as MA + +import pyloess +from pyloess import loess + +com_example = [ +""" +# Get some example data ................................... +dfile = open(os.path.join('tests','madeup_data'), 'r') +dfile.readline() +x = fromiter((float(v) for v in dfile.readline().rstrip().split()), + float_).reshape(-1,2) +dfile.readline() +y = fromiter((float(v) for v in dfile.readline().rstrip().split()), + float_) +""", + +""" +# Get some additional info for prediction ................. +newdata1 = numpy.array([[-2.5, 0.0, 2.5], [0., 0., 0.]]) +newdata2 = numpy.array([[-0.5, 0.5], [0., 0.]]) +""", + +""" +# Create a new loess object ............................... +madeup = loess(x,y) +# ... and prints the parameters +print madeup.model,'\\n', madeup.control +""", + +""" +# Modify some of the model parameters ..................... +madeup.model.update(span=0.8, normalize=False) +print madeup.model +""" +] + + + +if 1: + for com in com_example: + print com + exec(com) Property changes on: trunk/Lib/sandbox/pyloess/examples.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Added: trunk/Lib/sandbox/pyloess/mpyloess.py =================================================================== --- trunk/Lib/sandbox/pyloess/mpyloess.py 2007-03-26 19:37:12 UTC (rev 2873) +++ trunk/Lib/sandbox/pyloess/mpyloess.py 2007-03-27 06:38:36 UTC (rev 2874) @@ -0,0 +1,843 @@ +# pylint: disable-msg=E1101 +""" +Wrapper to lowess, loess and stl routines, with support for masked arrays. + +LOWESS: +Initial Fortran code available at: +http://netlib.bell-labs.com/netlib/go/lowess.f.gz + +initial author: W. S. Cleveland, 1979. +Simple to double precision conversion of the Fortran code by Pierre +Gerard-Marchant, 2007/03. + +STL: +Initial Fortran code available at: +http://netlib.bell-labs.com/netlib/a/stl.gz +Initial Authors: R. B. Cleveland, W. S. Cleveland, J. E. McRae, and +I. Terpenning, 1990. +Simple-to-double precision conversion of the Fortran code by Pierre +Gerard-Marchant, 2007/03. + +LOESS: +Initial C/Fortran package avialable at +http://netlib.bell-labs.com/netlib/a/dloess.gz +Initial authors: W. S. Cleveland, E. Grosse and Shyu +Adaptation to Pyrex/Python by Pierre Gerard-Marchant, 2007/03 + +:author: Pierre GF Gerard-Marchant +:contact: pierregm_at_uga_edu +:date: $Date$ +:version: $Id$ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author$)" +__version__ = '1.0' +__revision__ = "$Revision$" +__date__ = '$Date$' + +import numpy +from numpy import bool_, complex_, float_, int_, str_, object_ +import numpy.core.numeric as numeric +from numpy.core.records import recarray +narray = numeric.array +nempty = numeric.empty +nlogical_not = numpy.logical_not + +import maskedarray.core +from maskedarray.core import masked, nomask, mask_or +from maskedarray.core import masked_array as marray + +import _lowess, _stl, _mloess + + +#####--------------------------------------------------------------------------- +#--- --- STL --- +#####--------------------------------------------------------------------------- +class lowess: + """An object for robust locally weighted regression. + +:IVariables: + inputs : + parameters : + outputs : + + +Method +------ + The fitted values are computed by using the nearest neighbor + routine and robust locally weighted regression of degree 1 + with the tricube weight function. A few additional features + have been added. Suppose r is FN truncated to an integer. + Let h be the distance to the r-th nearest neighbor + from X[i]. All points within h of X[i] are used. Thus if + the r-th nearest neighbor is exactly the same distance as + other points, more than r points can possibly be used for + the smooth at X[i]. There are two cases where robust + locally weighted regression of degree 0 is actually used at + X[i]. One case occurs when h is 0.0. The second case + occurs when the weighted standard error of the X[i] with + respect to the weights w[j] is less than .001 times the + range of the X[i], where w[j] is the weight assigned to the + j-th point of X (the tricube weight times the robustness + weight) divided by the sum of all of the weights. Finally, + if the w[j] are all zero for the smooth at X[i], the fitted + value is taken to be Y[i]. + +References +---------- + W. S. Cleveland. 1978. Visual and Computational Considerations in + Smoothing Scatterplots by Locally Weighted Regression. In + Computer Science and Statistics: Eleventh Annual Symposium on the + Interface, pages 96-100. Institute of Statistics, North Carolina + State University, Raleigh, North Carolina, 1978. + + W. S. Cleveland, 1979. Robust Locally Weighted Regression and + Smoothing Scatterplots. Journal of the American Statistical + Association, 74:829-836, 1979. + + W. S. Cleveland, 1981. LOWESS: A Program for Smoothing Scatterplots + by Robust Locally Weighted Regression. The American Statistician, + 35:54. + """ + #............................................ + class _inputs(object): + """Inputs of the lowess fit. + +:IVariables: + x : ndarray + A (n,) float ndarray of observations (sorted by increasing values). + y : ndarray + A (n,) float ndarray of responses (sorted by increasing x). + + """ + def __init__(self, x, y): + x = marray(x, copy=False, subok=True, dtype=float_, order='F').ravel() + y = marray(y, copy=False, subok=True, dtype=float_, order='F').ravel() + if x.size != y.size: + msg = "Incompatible size between observations (%s) and response (%s)!" + raise ValueError(msg % (x.size, y.size)) + idx = x.argsort() + self._x = x[idx] + self._y = y[idx] + self._mask = mask_or(self._x._mask, self._y._mask, + copy=False, small_mask=False) + #..... + x = property(fget=lambda self:self._x) + y = property(fget=lambda self:self._y) + #............................................ + class _parameters(object): + """Parameters of the lowess fit. + +:IVariables: + span : float *[0.5]* + Fraction of the total number of points used to compute each fitted value. + As f increases the smoothed values become smoother. Choosing f in the range + .2 to .8 usually results in a good fit. + nsteps : integer *[2]* + Number of iterations in the robust fit. If nsteps=0, the nonrobust fit + is returned; setting nsteps=2 should serve most purposes. + delta : integer *[0]* + Nonnegative parameter which may be used to save computations. + If N (the number of observations) is less than 100, set delta=0.0; + if N is greater than 100 you should find out how delta works by reading + the additional instructions section. + """ + def __init__(self, span, nsteps, delta, caller): + self.activated = False + self._span = span + self._nsteps = nsteps + self._delta = delta + self._caller = caller + #..... + def _get_span(self): + "Gets the current span." + return self._span + def _set_span(self, span): + "Sets the current span, and refit if needed." + if span <= 0 or span > 1: + raise ValueError("span should be between zero and one!") + self._span = span + if self.activated: + self._caller.fit() + span = property(fget=_get_span, fset=_set_span) + #..... + def _get_nsteps(self): + "Gets the current number of iterations." + return self._nsteps + def _set_nsteps(self, nsteps): + "Sets the current number of iterations, and refit if needed." + if nsteps < 0: + raise ValueError("nsteps should be positive!") + self._nsteps = nsteps + if self.activated: + self._caller.fit() + nsteps = property(fget=_get_nsteps, fset=_set_nsteps) + #..... + def _get_delta(self): + "Gets the current delta." + return self._delta + def _set_delta(self, delta): + "Sets the current delta, and refit if needed." + if delta < 0: + raise ValueError("delta should be positive!") + self._delta = delta + if self.activated: + self._caller.fit() + delta = property(fget=_get_delta, fset=_set_delta) + #............................................ + class _outputs(object): + """Outputs of the lowess fit. + +:IVariables: + fitted_values : ndarray + A (n,) ndarray of fitted values (readonly). + fitted_residuals : ndarray + A (n,) ndarray of residuals (readonly). + weights : ndarray + A (n,) ndarray of robust weights (readonly). + """ + def __init__(self, n): + self._fval = marray(nempty((n,), dtype=float_, order='F')) + self._rw = marray(nempty((n,), dtype=float_, order='F')) + self._fres = marray(nempty((n,), dtype=float_, order='F')) + #..... + fitted_values = property(fget=lambda self:self._fval) + robust_weights = property(fget=lambda self:self._rw) + fitted_residuals = property(fget=lambda self:self._fres) + #............................................ + def __init__(self, x, y, span=0.5, nsteps=2, delta=0): + """ +:Parameters: + x : ndarray + Abscissas of the points on the scatterplot; the values in X must be + ordered from smallest to largest. + y : ndarray + Ordinates of the points on the scatterplot. + span : Float *[0.5]* + Fraction of the total number of points used to compute each fitted value. + As span increases the smoothed values become smoother. Choosing span in + the range .2 to .8 usually results in a good fit. + nsteps : Integer *[2]* + Number of iterations in the robust fit. If nsteps=0, the nonrobust fit + is returned; setting nsteps=2 should serve most purposes. + delta : Integer *[0]* + Nonnegative parameter which may be used to save computations. + If N (the number of elements in x) is less than 100, set delta=0.0; + if N is greater than 100 you should find out how delta works by reading + the additional instructions section. + """ + # Chek the input data ......... + # Initialize the attributes ... + self.inputs = lowess._inputs(x,y) + self.parameters = lowess._parameters(span, nsteps, delta, self) + self.outputs = self._outputs(self.inputs._x.size) + # Force a fit ................. + self.fit() + + #............................................ + def fit(self): + # Check the mask ......... + mask = self.inputs._mask + if mask.any(): + unmask = nlogical_not(mask) + (x, y) = (self.inputs._x[unmask], self.inputs._y[unmask]) + else: + unmask = slice(None,None) + (x, y) = (self.inputs._x, self.inputs._y) + # Get the parameters ..... + self.parameters.activated = True + f = self.parameters._span + nsteps = self.parameters._nsteps + delta = self.parameters._delta + (tmp_s, tmp_w, tmp_r) = _lowess.lowess(x, y, f, nsteps, delta) + # Process the outputs ..... + #... set the values + self.outputs._fval[unmask] = tmp_s[:] + self.outputs._rw[unmask] = tmp_w[:] + self.outputs._fres[unmask] = tmp_r[:] + #... set the masks + self.outputs._fval._set_mask(mask) + self.outputs._rw._set_mask(mask) + self.outputs._fres._set_mask(mask) + # Clean up the mess ....... + del(tmp_s, tmp_w, tmp_r) + return self.outputs + +#####--------------------------------------------------------------------------- +#--- --- STL --- +#####--------------------------------------------------------------------------- +class stl: + class _inputs: + def __init__(self, y): + self.y = marray(y, subok=True, copy=False).ravel() + self._mask = self.y._mask + if self._mask.any(): + raise ValueError("Masked arrays should be filled first!") + self.y_eff = self.y.compressed() + #............................................ + class _model(object): + """Model parameters of the STL fit. + +:IVariables: + np : Integer *[12]* + Period of the seasonal component. + For example, if the time series is monthly with a yearly cycle, then + np=12. + ns : Integer *[7]* + Length of the seasonal smoother. + The value of ns should be an odd integer greater than or equal to 3. + A value ns>6 is recommended. As ns increases the values of the + seasonal component at a given point in the seasonal cycle (e.g., January + values of a monthly series with a yearly cycle) become smoother. + nt : Integer *[None]* + Length of the trend smoother. + The value of nt should be an odd integer greater than or equal to 3. + A value of nt between 1.5*np and 2*np is recommended. As nt increases, + the values of the trend component become smoother. + If nt is None, it is estimated as the smallest odd integer greater + or equal to (1.5*np)/[1-(1.5/ns)] + nl : Integer *[None]* + Length of the low-pass filter. + The value of nl should be an odd integer greater than or equal to 3. + The smallest odd integer greater than or equal to np is used by default. + isdeg : Integer *[1]* + Degree of locally-fitted polynomial in seasonal smoothing. + The value is 0 or 1. + itdeg : Integer *[1]* + Degree of locally-fitted polynomial in trend smoothing. + The value is 0 or 1. + ildeg : Integer *[1]* + Degree of locally-fitted polynomial in low-pass smoothing. + The value is 0 or 1. + """ + def __init__(self, + np=12, ns=7, nt=None, nl=13, + isdeg=1, itdeg=1, ildeg=1, caller=None): + self._np = np + self._ns = ns + # + self._nt = nt + if nt is None: + self._nt = max(int((1.5*np/(1.-1.5/ns))+0.5), 3) + else: + self._nt = nt + if not self._nt % 2: + self._nt += 1 + # + if nl is None: + self._nl = max(np, 3) + else: + self._nl = nl + if not self._nl % 2: + self._nl += 1 + # + self._isdeg = isdeg + self._itdeg = itdeg + self._ildeg = ildeg + self.activated = False + self.caller = caller + #..... + def _get_np(self): + "Gets the current seasonal period." + return self._np + def _set_np(self, np): + "Sets the current seasonal period." + self._np = max(np,2) + if self.activated: + self.caller.fit() + np = property(fget=_get_np, fset=_set_np) + #..... + def _get_ns(self): + "Gets the length of the seasonal smoother." + return self._ns + def _set_ns(self, ns): + "Sets the length of the seasonal smoother." + self._ns = max(ns, 3) + if self._ns %2 == 0: + self._ns += 1 + if self.activated: + self.caller.fit() + ns = property(fget=_get_ns, fset=_set_ns) + #..... + def _get_nt(self): + "Gets the length of the trend smoother." + return self._nt + def _set_nt(self, nt): + "Sets the length of the trend smoother." + self._nt = nt + if self.activated: + self.caller.fit() + nt = property(fget=_get_nt, fset=_set_nt) + #..... + def _get_nl(self): + "Gets the length of the trend smoother." + return self._nl + def _set_nl(self, nl): + "Sets the length of the trend smoother." + self._nl = nl + if self.activated: + self.caller.fit() + nl = property(fget=_get_nl, fset=_set_nl) + #..... + def _get_isdeg(self): + "Gets the degree of the seasonal smoother." + return self._isdeg + def _set_isdeg(self, isdeg): + "Sets the degree of the seasonal smoother." + if isdeg > 2 or isdeg < 0: + raise ValueError("The degree of the seasonal smoother should be 1 or 0.") + self._isdeg = int(isdeg) + if self.activated: + self.caller.fit() + isdeg = property(fget=_get_isdeg, fset=_set_isdeg) + #..... + def _get_itdeg(self): + "Gets the degree of the trend smoother." + return self._itdeg + def _set_itdeg(self, itdeg): + "Sets the degree of the trend smoother." + if itdeg > 2 or itdeg < 0: + raise ValueError("The degree of the trend smoother should be 1 or 0.") + self._itdeg = int(itdeg) + if self.activated: + self.caller.fit() + itdeg = property(fget=_get_itdeg, fset=_set_itdeg) + #..... + def _get_ildeg(self): + "Gets the degree of the low-pass smoother." + return self._ildeg + def _set_ildeg(self, ildeg): + "Sets the degree of the low-pass smoother." + if ildeg > 2 or ildeg < 0: + raise ValueError("The degree of the low-pass smoother should be 1 or 0.") + self._ildeg = int(ildeg) + if self.activated: + self.caller.fit() + ildeg = property(fget=_get_ildeg, fset=_set_ildeg) + + #............................................ + class _control(object): + """Control parameters of the STL fit. + +:IVariables: + nsjump : Integer *[None]* + Skipping value for seasonal smoothing. + The seasonal smoother skips ahead nsjump points and then linearly + interpolates in between. The value of nsjump should be a positive + integer; if nsjump=1, a seasonal smooth is calculated at all n points. + To make the procedure run faster, a reasonable choice for nsjump is + 10%-20% of ns. By default, nsjump= 0.1*ns. + ntjump : Integer *[1]* + Skipping value for trend smoothing. If None, ntjump= 0.1*nt + nljump : Integer *[1]* + Skipping value for low-pass smoothing. If None, nljump= 0.1*nl + robust : Boolean *[True]* + Flag indicating whether robust fitting should be performed. + ni : Integer *[None]* + Number of loops for updating the seasonal and trend components. + The value of ni should be a positive integer. + See the next argument for advice on the choice of ni. + If ni is None, ni is set to 1 for robust fitting, to 5 otherwise. + no : Integer *[0]* + Number of iterations of robust fitting. The value of no should + be a nonnegative integer. If the data are well behaved without + outliers, then robustness iterations are not needed. In this case + set no=0, and set ni=2 to 5 depending on how much security + you want that the seasonal-trend looping converges. + If outliers are present then no=3 is a very secure value unless + the outliers are radical, in which case no=5 or even 10 might + be better. If no>0 then set ni to 1 or 2. + If None, then no is set to 15 for robust fitting, to 0 otherwise. + """ + def __init__(self, + nsjump=None,ntjump=None,nljump=None, + robust=True, ni=None,no=None, caller=None): + (self._nsjump, self._ntjump, self._nljump) = (nsjump, ntjump, nljump) + #... + if robust: + if ni is None: + ni = 1 + if no is None: + no = 15 + else: + if ni is None: + ni = 5 + if no is None: + no = 0 + (self._robust, self._ni, self._no) = (robust, ni, no) + #... + self.activated = False + self.caller = caller + #.... + def _get_nsjump(self): + "Gets the skipping value for seasonal smoothing." + return self._nsjump + def _set_nsjump(self, nsjump): + "Sets the skipping value for seasonal smoothing." + self._nsjump = nsjump + if self.activated: + self.caller.fit() + nsjump = property(fget=_get_nsjump, fset=_set_nsjump) + #.... + def _get_ntjump(self): + "Gets the skipping value for trend smoothing." + return self._ntjump + def _set_ntjump(self, ntjump): + "Sets the skipping value for trend smoothing." + self._ntjump = ntjump + if self.activated: + self.caller.fit() + ntjump = property(fget=_get_ntjump, fset=_set_ntjump) + #.... + def _get_nljump(self): + "Gets the skipping value for low-pass smoothing." + return self._nljump + def _set_nljump(self, nljump): + "Set the skipping value for low-pass smoothings" + self._nljump = nljump + if self.activated: + self.caller.fit() + nljump = property(fget=_get_nljump, fset=_set_nljump) + #.... + def _get_robust(self): + "Gets whether robust fitting should be performed." + return self._robust + def _set_robust(self, robust): + "Sets whether robust fitting should be performed." + self._robust = robust + if self.activated: + self.caller.fit() + robust = property(fget=_get_robust, fset=_set_robust) + #.... + def _get_ni(self): + "Gets the number of loops." + return self._ni + def _set_ni(self, ni): + "Sets the number of loops." + if ni < 0: + raise ValueError("The number of loops should be positive!") + self._ni = ni + if self.activated: + self.caller.fit() + ni = property(fget=_get_ni, fset=_set_ni) + #.... + def _get_no(self): + "Gets the number of iterations for robust fitting." + return self._no + def _set_no(self, no): + "Sets the number of iterations for robust fitting." + if no < 0 : + raise ValueError("The number of iterations should be positive!") + self._no = no + if self.activated: + self.caller.fit() + no = property(fget=_get_no, fset=_set_no) + #............................................ + class _outputs(object): + """Outputs of the STL fit. + +:IVariables: + seasonal : ndarray + Seasonal fitted values. + trend : ndarray + Trend fitted values. + residuals : ndarray + Fitted residuals. + weights : ndarray + Local robust weights. The final local robust weights are all 1 if no=0. + """ + def __init__(self, n): + self._seasonal = marray(nempty((n,), float_)) + self._trend = marray(nempty((n,), float_)) + self._weights = marray(nempty((n,), float_)) + self._residuals = marray(nempty((n,), float_)) + #..... + seasonal = property(fget=lambda self:self._seasonal) + trend = property(fget=lambda self:self._trend) + weights = property(fget=lambda self:self._weights) + residuals = property(fget=lambda self:self._residuals) + #............................................. + def __init__(self, y, **options): + """Decomposes a time series into seasonal and trend components. + +:Parameters: + y : ndarray + Time series to be decomposed. + np : Integer *[12]* + Period of the seasonal component. + For example, if the time series is monthly with a yearly cycle, then + np=12. + ns : Integer *[7]* + Length of the seasonal smoother. + The value of ns should be an odd integer greater than or equal to 3. + A value ns>6 is recommended. As ns increases the values of the + seasonal component at a given point in the seasonal cycle (e.g., January + values of a monthly series with a yearly cycle) become smoother. + nt : Integer *[None]* + Length of the trend smoother. + The value of nt should be an odd integer greater than or equal to 3. + A value of nt between 1.5*np and 2*np is recommended. As nt increases, + the values of the trend component become smoother. + If nt is None, it is estimated as the smallest odd integer greater + or equal to (1.5*np)/[1-(1.5/ns)] + nl : Integer *[None]* + Length of the low-pass filter. + The value of nl should be an odd integer greater than or equal to 3. + The smallest odd integer greater than or equal to np is used by default. + isdeg : Integer *[1]* + Degree of locally-fitted polynomial in seasonal smoothing. + The value is 0 or 1. + itdeg : Integer *[1]* + Degree of locally-fitted polynomial in trend smoothing. + The value is 0 or 1. + ildeg : Integer *[1]* + Degree of locally-fitted polynomial in low-pass smoothing. + The value is 0 or 1. + nsjump : Integer *[None]* + Skipping value for seasonal smoothing. + The seasonal smoother skips ahead nsjump points and then linearly + interpolates in between. The value of nsjump should be a positive + integer; if nsjump=1, a seasonal smooth is calculated at all n points. + To make the procedure run faster, a reasonable choice for nsjump is + 10%-20% of ns. By default, nsjump= 0.1*ns. + ntjump : Integer *[1]* + Skipping value for trend smoothing. If None, ntjump= 0.1*nt + nljump : Integer *[1]* + Skipping value for low-pass smoothing. If None, nljump= 0.1*nl + robust : Boolean *[True]* + Flag indicating whether robust fitting should be performed. + ni : Integer *[None]* + Number of loops for updating the seasonal and trend components. + The value of ni should be a positive integer. + See the next argument for advice on the choice of ni. + If ni is None, ni is set to 1 for robust fitting, to 5 otherwise. + no : Integer *[0]* + Number of iterations of robust fitting. The value of no should + be a nonnegative integer. If the data are well behaved without + outliers, then robustness iterations are not needed. In this case + set no=0, and set ni=2 to 5 depending on how much security + you want that the seasonal-trend looping converges. + If outliers are present then no=3 is a very secure value unless + the outliers are radical, in which case no=5 or even 10 might + be better. If no>0 then set ni to 1 or 2. + If None, then no is set to 15 for robust fitting, to 0 otherwise. + """ + self.inputs = stl._inputs(y) + self.model = stl._model(**dict(np=options.get('np',12), + ns=options.get('ns',7), + nt=options.get('nt',None), + nl=options.get('nl',13), + isdeg=options.get('isdeg',1), + itdeg=options.get('itdeg',1), + ildeg=options.get('ildeg',1), + caller=self)) + optcontrol = dict( + nsjump=options.get('nsjump',int(0.1*self.model.ns+0.9)), + ntjump=options.get('ntjump',int(0.1*self.model.nt+0.9)), + nljump=options.get('nljump',int(0.1*self.model.nl+0.9)), + robust=options.get('robust',True), + ni=options.get('ni',None), + no=options.get('no',None),) + self.control = stl._control(**optcontrol) + self.outputs = stl._outputs(len(self.inputs.y)) + # Force a fit ................. + self.fit() + + #............................................ + def fit(self): + # Get the input ............... + y = self.inputs.y_eff + mask = self.inputs._mask + if mask is nomask: + unmask = slice(None,None) + else: + unmask = nlogical_not(mask) + # Get the parameters .......... + model = self.model + (np, ns, nt, nl) = (model.np, model.ns, model.nt, model.nl) + (isdeg, itdeg, ildeg) = (model.isdeg, model.itdeg, model.ildeg) + control = self.control + (nsjump, ntjump, nljump) = (control.nsjump, control.ntjump, control.nljump) + (ni, no) = (control.ni, control.no) + # Compute the fit ............. + (rw,szn,trn,work) = _stl.stl(y,np,ns,nt,nl,isdeg,itdeg,ildeg, + nsjump,ntjump,nljump,ni,no,) + # Process the outputs ..... + #... set the values + self.outputs.trend[unmask] = trn.flat + self.outputs.seasonal[unmask] = szn.flat + self.outputs.weights[unmask] = rw.flat + self.outputs.residuals[unmask] = (y-trn-szn) + #... set the masks + self.outputs.trend._set_mask(mask) + self.outputs.seasonal._set_mask(mask) + self.outputs.weights._set_mask(mask) + self.outputs.residuals._set_mask(mask) + # Clean up the mess ....... + self.model.activated = self.control.activated = True + del(trn, rw, szn) + return self.outputs + + + + + +def fstl(y, np=12, ns=7, nt=None, nl=13, isdeg=1, itdeg=1, ildeg=1, + nsjump=None,ntjump=None,nljump=None, robust=True, ni=None,no=None): + """Decomposes a time series into seasonal and trend components. + +:Parameters: + y : Numerical array + Time Series to be decomposed. + np : Integer *[12]* + Period of the seasonal component. + For example, if the time series is monthly with a yearly cycle, then + np=12. + ns : Integer *[7]* + Length of the seasonal smoother. + The value of ns should be an odd integer greater than or equal to 3. + A value ns>6 is recommended. As ns increases the values of the + seasonal component at a given point in the seasonal cycle (e.g., January + values of a monthly series with a yearly cycle) become smoother. + nt : Integer *[None]* + Length of the trend smoother. + The value of nt should be an odd integer greater than or equal to 3. + A value of nt between 1.5*np and 2*np is recommended. As nt increases, + the values of the trend component become smoother. + If nt is None, it is estimated as the smallest odd integer greater + or equal to (1.5*np)/[1-(1.5/ns)] + nl : Integer *[None]* + Length of the low-pass filter. + The value of nl should be an odd integer greater than or equal to 3. + The smallest odd integer greater than or equal to np is used by default. + isdeg : Integer *[1]* + Degree of locally-fitted polynomial in seasonal smoothing. + The value is 0 or 1. + itdeg : Integer *[1]* + Degree of locally-fitted polynomial in trend smoothing. + The value is 0 or 1. + ildeg : Integer *[1]* + Degree of locally-fitted polynomial in low-pass smoothing. + The value is 0 or 1. + nsjump : Integer *[None]* + Skipping value for seasonal smoothing. + The seasonal smoother skips ahead nsjump points and then linearly + interpolates in between. The value of nsjump should be a positive + integer; if nsjump=1, a seasonal smooth is calculated at all n points. + To make the procedure run faster, a reasonable choice for nsjump is + 10%-20% of ns. By default, nsjump= 0.1*ns. + ntjump : Integer *[1]* + Skipping value for trend smoothing. If None, ntjump= 0.1*nt + nljump : Integer *[1]* + Skipping value for low-pass smoothing. If None, nljump= 0.1*nl + robust : Boolean *[True]* + Flag indicating whether robust fitting should be performed. + ni : Integer *[None]* + Number of loops for updating the seasonal and trend components. + The value of ni should be a positive integer. + See the next argument for advice on the choice of ni. + If ni is None, ni is set to 1 for robust fitting, to 5 otherwise. + no : Integer *[0]* + Number of iterations of robust fitting. The value of no should + be a nonnegative integer. If the data are well behaved without + outliers, then robustness iterations are not needed. In this case + set no=0, and set ni=2 to 5 depending on how much security + you want that the seasonal-trend looping converges. + If outliers are present then no=3 is a very secure value unless + the outliers are radical, in which case no=5 or even 10 might + be better. If no>0 then set ni to 1 or 2. + If None, then no is set to 15 for robust fitting, to 0 otherwise. + +Returns: + A recarray of estimated trend values ('trend'), estimated seasonal + components ('seasonal'), local robust weights ('weights') and fit + residuals ('residuals'). + The final local robust weights are all 1 if no=0. + +Reference +--------- + + R. B. Cleveland, W. S. Cleveland, J. E. McRae and I. Terpenning. + 1990. STL: A Seasonal-Trend Decomposition Procedure Based on LOESS + (with Discussion). Journal of Official Statistics, 6:3-73. + + + """ + ns = max(ns, 3) + if ns % 2 == 0: + ns += 1 + np = max(2, np) + if nt is None: + nt = max(int((1.5*np/(1.-1.5/ns))+0.5), 3) + if not nt % 2: + nt += 1 + if nl is None: + nl = max(3,np) + if not nl % 2: + nl += 1 + if nsjump is None: + nsjump = int(0.1*ns + 0.9) + if ntjump is None: + ntjump = int(0.1*nt + 0.9) + if nljump is None: + nljump = int(0.1*nl + 0.9) + if robust: + if ni is None: + ni = 1 + if no is None: + no = 15 + else: + if ni is None: + ni = 5 + if no is None: + no = 0 + + if hasattr(y,'_mask') and numpy.any(y._mask): + raise ValueError,"Missing values should first be filled !" + y = numeric.array(y, subok=True, copy=False).ravel() + (rw,szn,trn,work) = _stl.stl(y,np,ns,nt,nl,isdeg,itdeg,ildeg, + nsjump,ntjump,nljump,ni,no,) + dtyp = [('trend', float_), ('seasonal', float_), + ('residuals', float_), ('weights', float_)] + result = numeric.fromiter(zip(trn,szn,y-trn-szn,rw), dtype=dtyp) + return result.view(recarray) + +#####--------------------------------------------------------------------------- +#--- --- Loess --- +#####--------------------------------------------------------------------------- +loess = _mloess.loess +loess_anova = _mloess.anova + +################################################################################ +if __name__ == '__main__': + from maskedarray.testutils import assert_almost_equal + from maskedarray import masked_values + from numpy import fromiter + import os + + if 1: + NOx = marray([4.818, 2.849, 3.275, 4.691, 4.255, 5.064, 2.118, 4.602, + 2.286, 0.970, 3.965, 5.344, 3.834, 1.990, 5.199, 5.283, + -9999, -9999, 3.752, 0.537, 1.640, 5.055, 4.937, 1.561]) + NOx = maskedarray.masked_values(NOx, -9999) + E = marray([0.831, 1.045, 1.021, 0.970, 0.825, 0.891, 0.71, 0.801, + 1.074, 1.148, 1.000, 0.928, 0.767, 0.701, 0.807, 0.902, + -9999, -9999, 0.997, 1.224, 1.089, 0.973, 0.980, 0.665]) + gas_fit_E = numpy.array([0.665, 0.949, 1.224]) + newdata = numpy.array([0.6650000, 0.7581667, 0.8513333, 0.9445000, + 1.0376667, 1.1308333, 1.2240000]) + coverage = 0.99 + + rfile = open(os.path.join('tests','gas_result'), 'r') + results = [] + for i in range(8): + rfile.readline() + z = fromiter((float(v) for v in rfile.readline().rstrip().split()), + float_) + results.append(z) + # + gas = loess(E,NOx) + gas.model.span = 2./3. + gas.fit() + assert_almost_equal(gas.outputs.fitted_values.compressed(), results[0], 6) + assert_almost_equal(gas.outputs.enp, 5.5, 1) + assert_almost_equal(gas.outputs.s, 0.3404, 4) \ No newline at end of file Property changes on: trunk/Lib/sandbox/pyloess/mpyloess.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Modified: trunk/Lib/sandbox/pyloess/pyloess.py =================================================================== --- trunk/Lib/sandbox/pyloess/pyloess.py 2007-03-26 19:37:12 UTC (rev 2873) +++ trunk/Lib/sandbox/pyloess/pyloess.py 2007-03-27 06:38:36 UTC (rev 2874) @@ -39,13 +39,16 @@ import numpy.core.numeric as numeric from numpy.core.records import recarray +from numpy.core import array as narray +from numpy.core import empty as nempty + import _lowess, _stl, _loess #####--------------------------------------------------------------------------- #--- --- STL --- #####--------------------------------------------------------------------------- -def lowess(x,y,f=0.5,nsteps=2,delta=0): +def flowess(x,y,span=0.5,nsteps=2,delta=0): """Performs a robust locally weighted regression (lowess). Outputs a *3xN* array of fitted values, residuals and fit weights. @@ -57,7 +60,7 @@ ordered from smallest to largest. y : ndarray Ordinates of the points on the scatterplot. - f : Float *[0.5]* + span : Float *[0.5]* Fraction of the total number of points used to compute each fitted value. As f increases the smoothed values become smoother. Choosing f in the range .2 to .8 usually results in a good fit. @@ -145,10 +148,224 @@ 35:54. """ - dtyp = [('smooth',float_), ('weigths', float_), ('residuals', float_)] - return numeric.fromiter(zip(*_lowess.lowess(x,y,f,nsteps,delta,)), - dtype=dtyp).view(recarray) + x = narray(x, copy=False, subok=True, dtype=float_) + y = narray(y, copy=False, subok=True, dtype=float_) + if x.size != y.size: + raise ValueError("Incompatible size between observations and response!") + + + out_dtype = [('smooth',float_), ('weigths', float_), ('residuals', float_)] + return numeric.fromiter(zip(*_lowess.lowess(x,y,span,nsteps,delta,)), + dtype=out_dtype).view(recarray) + +class lowess: + """An object for robust locally weighted regression. + +:IVariables: + inputs : An object storing the inputs. + x : A (n,) ndarray of observations (sorted by increasing values). + y : A (n,) ndarray of responses (sorted by increasing x). + parameters : An object storing the control parameters. + span : Fraction of the total number of points used in the smooth. + nsteps : Number of iterations of the robust fit. + delta : Parameter used to save computation time + outputs : An object storing the outputs. + smooth : A (n,) ndarray of fitted values. + residuals : A (n,) ndarray of fitted residuals. + weights : A (n,) ndarray of robust weights. + + +Method +------ + The fitted values are computed by using the nearest neighbor + routine and robust locally weighted regression of degree 1 + with the tricube weight function. A few additional features + have been added. Suppose r is FN truncated to an integer. + Let h be the distance to the r-th nearest neighbor + from X[i]. All points within h of X[i] are used. Thus if + the r-th nearest neighbor is exactly the same distance as + other points, more than r points can possibly be used for + the smooth at X[i]. There are two cases where robust + locally weighted regression of degree 0 is actually used at + X[i]. One case occurs when h is 0.0. The second case + occurs when the weighted standard error of the X[i] with + respect to the weights w[j] is less than .001 times the + range of the X[i], where w[j] is the weight assigned to the + j-th point of X (the tricube weight times the robustness + weight) divided by the sum of all of the weights. Finally, + if the w[j] are all zero for the smooth at X[i], the fitted + value is taken to be Y[i]. + +References +---------- + W. S. Cleveland. 1978. Visual and Computational Considerations in + Smoothing Scatterplots by Locally Weighted Regression. In + Computer Science and Statistics: Eleventh Annual Symposium on the + Interface, pages 96-100. Institute of Statistics, North Carolina + State University, Raleigh, North Carolina, 1978. + + W. S. Cleveland, 1979. Robust Locally Weighted Regression and + Smoothing Scatterplots. Journal of the American Statistical + Association, 74:829-836, 1979. + + W. S. Cleveland, 1981. LOWESS: A Program for Smoothing Scatterplots + by Robust Locally Weighted Regression. The American Statistician, + 35:54. + """ + #............................................ + class _inputs(object): + """Inputs of the lowess fit. + +:IVariables: + x : ndarray + A (n,) float ndarray of observations (sorted by increasing values). + y : ndarray + A (n,) float ndarray of responses (sorted by increasing x). + """ + def __init__(self, x, y): + x = narray(x, copy=False, subok=True, dtype=float_).ravel() + y = narray(y, copy=False, subok=True, dtype=float_).ravel() + if x.size != y.size: + msg = "Incompatible size between observations (%s) and response (%s)!" + raise ValueError(msg % (x.size, y.size)) + idx = x.argsort() + self._x = x[idx] + self._y = y[idx] + #..... + x = property(fget=lambda self:self._x) + y = property(fget=lambda self:self._y) + #............................................ + class _parameters(object): + """Parameters of the lowess fit. + +:IVariables: + span : float *[0.5]* + Fraction of the total number of points used to compute each fitted value. + As f increases the smoothed values become smoother. Choosing f in the range + .2 to .8 usually results in a good fit. + nsteps : integer *[2]* + Number of iterations in the robust fit. If nsteps=0, the nonrobust fit + is returned; setting nsteps=2 should serve most purposes. + delta : integer *[0]* + Nonnegative parameter which may be used to save computations. + If N (the number of observations) is less than 100, set delta=0.0; + if N is greater than 100 you should find out how delta works by reading + the additional instructions section. + """ + def __init__(self, span, nsteps, delta, caller): + self.activated = False + self._span = span + self._nsteps = nsteps + self._delta = delta + self._caller = caller + #..... + def _get_span(self): + "Gets the current span." + return self._span + def _set_span(self, span): + "Sets the current span, and refit if needed." + if span <= 0 or span > 1: + raise ValueError("span should be between zero and one!") + self._span = span + if self.activated: + self._caller.fit() + span = property(fget=_get_span, fset=_set_span) + #..... + def _get_nsteps(self): + "Gets the current number of iterations." + return self._nsteps + def _set_nsteps(self, nsteps): + "Sets the current number of iterations, and refit if needed." + if nsteps < 0: + raise ValueError("nsteps should be positive!") + self._nsteps = nsteps + if self.activated: + self._caller.fit() + nsteps = property(fget=_get_nsteps, fset=_set_nsteps) + #..... + def _get_delta(self): + "Gets the current delta." + return self._delta + def _set_delta(self, delta): + "Sets the current delta, and refit if needed." + if delta < 0: + raise ValueError("delta should be positive!") + self._delta = delta + if self.activated: + self._caller.fit() + delta = property(fget=_get_delta, fset=_set_delta) + #............................................ + class _outputs(object): + """Outputs of the lowess fit. + +:IVariables: + fitted_values : ndarray + A (n,) ndarray of fitted values (readonly). + fitted_residuals : ndarray + A (n,) ndarray of residuals (readonly). + weights : ndarray + A (n,) ndarray of robust weights (readonly). + """ + def __init__(self, n): + self._fval = nempty((n,), float_) + self._rw = nempty((n,), float_) + self._fres = nempty((n,), float_) + #..... + fitted_values = property(fget=lambda self:self._fval) + robust_weights = property(fget=lambda self:self._rw) + fitted_residuals = property(fget=lambda self:self._fres) + + #............................................ + def __init__(self, x, y, span=0.5, nsteps=2, delta=0): + """ +:Parameters: + x : ndarray + Abscissas of the points on the scatterplot; the values in X must be + ordered from smallest to largest. + y : ndarray + Ordinates of the points on the scatterplot. + span : Float *[0.5]* + Fraction of the total number of points used to compute each fitted value. + As span increases the smoothed values become smoother. Choosing span in + the range .2 to .8 usually results in a good fit. + nsteps : Integer *[2]* + Number of iterations in the robust fit. If nsteps=0, the nonrobust fit + is returned; setting nsteps=2 should serve most purposes. + delta : Integer *[0]* + Nonnegative parameter which may be used to save computations. + If N (the number of elements in x) is less than 100, set delta=0.0; + if N is greater than 100 you should find out how delta works by reading + the additional instructions section. + """ + # Chek the input data ......... + # Initialize the attributes ... + self.inputs = lowess._inputs(x,y) + self.parameters = lowess._parameters(span, nsteps, delta, self) + self.outputs = lowess._outputs(self.inputs._x.size) + # Force a fit ................. + self.fit() + + #............................................ + def fit(self): + """Computes the lowess fit. Returns a lowess.outputs object.""" + (x, y) = (self.inputs._x, self.inputs._y) + # Get the parameters ..... + self.parameters.activated = True + f = self.parameters._span + nsteps = self.parameters._nsteps + delta = self.parameters._delta + (tmp_s, tmp_w, tmp_r) = _lowess.lowess(x, y, f, nsteps, delta) + # Process the outputs ..... + #... set the values + self.outputs.fitted_values[:] = tmp_s.flat + self.outputs.robust_weights[:] = tmp_w.flat + self.outputs.fitted_residuals[:] = tmp_r.flat + # Clean up the mess ....... + del(tmp_s, tmp_w, tmp_r) + return self.outputs + + #####--------------------------------------------------------------------------- #--- --- STL --- #####--------------------------------------------------------------------------- @@ -393,3 +610,9 @@ """ loess_anova = _loess.anova + +################################################################################ +if __name__ == '__main__': + from maskedarray.testutils import assert_almost_equal + from maskedarray import masked_values + Modified: trunk/Lib/sandbox/pyloess/setup.py =================================================================== --- trunk/Lib/sandbox/pyloess/setup.py 2007-03-26 19:37:12 UTC (rev 2873) +++ trunk/Lib/sandbox/pyloess/setup.py 2007-03-27 06:38:36 UTC (rev 2874) @@ -29,15 +29,25 @@ build_info = {} dict_append(build_info, **blas_info) dict_append(build_info, libraries=['floess']) - c_sources = ['_loess.c', 'loess.c', 'loessc.c', 'misc.c', 'predict.c',] + c_sources = ['loess.c', 'loessc.c', 'misc.c', 'predict.c',] confgr.add_extension('_loess', - sources=[join('src', x) for x in c_sources], + sources=[join('src','_loess.c')] + \ + [join('src', x) for x in c_sources], depends = [join('src','*.h'), join('src','*.pyx'), join('src','*.pxd') ], **build_info ) + confgr.add_extension('_mloess', + sources=[join('src','_mloess.c')] + \ + [join('src', x) for x in c_sources], + depends = [join('src','*.h'), + join('src','*.pyx'), + join('src','*.pxd') + ], + **build_info + ) confgr.add_data_dir('tests') return confgr Modified: trunk/Lib/sandbox/pyloess/src/_loess.c =================================================================== --- trunk/Lib/sandbox/pyloess/src/_loess.c 2007-03-26 19:37:12 UTC (rev 2873) +++ trunk/Lib/sandbox/pyloess/src/_loess.c 2007-03-27 06:38:36 UTC (rev 2874) @@ -1,4 +1,4 @@ -/* Generated by Pyrex 0.9.5.1a on Wed Mar 21 17:37:22 2007 */ +/* Generated by Pyrex 0.9.5.1a on Sun Mar 25 18:15:15 2007 */ #include "Python.h" #include "structmember.h" @@ -71,6 +71,14 @@ struct __pyx_obj_6_loess_loess_inputs { PyObject_HEAD loess_inputs (*_base); + PyArrayObject *w_ndr; + PyArrayObject *x; + PyArrayObject *y; + PyArrayObject *masked; + PyArrayObject *x_eff; + PyArrayObject *y_eff; + int nobs; + int npar; }; @@ -101,13 +109,19 @@ struct __pyx_obj_6_loess_loess_outputs { PyObject_HEAD + struct __pyx_vtabstruct_6_loess_loess_outputs *__pyx_vtab; loess_outputs (*_base); long nobs; long npar; int activated; }; +struct __pyx_vtabstruct_6_loess_loess_outputs { + PyObject *((*setup)(struct __pyx_obj_6_loess_loess_outputs *,loess_outputs (*),long ,long )); +}; +static struct __pyx_vtabstruct_6_loess_loess_outputs *__pyx_vtabptr_6_loess_loess_outputs; + struct __pyx_obj_6_loess_conf_intervals { PyObject_HEAD struct __pyx_vtabstruct_6_loess_conf_intervals *__pyx_vtab; @@ -146,8 +160,6 @@ struct __pyx_obj_6_loess_loess_kd_tree *kd_tree; struct __pyx_obj_6_loess_loess_outputs *outputs; struct __pyx_obj_6_loess_loess_predicted *predicted; - long nobs; - long npar; }; @@ -168,9 +180,9 @@ static PyTypeObject *__pyx_ptype_6_loess_loess_predicted = 0; static PyTypeObject *__pyx_ptype_6_loess_loess = 0; static PyTypeObject *__pyx_ptype_6_loess_anova = 0; -static PyObject *__pyx_k32; -static PyObject *__pyx_k33; -static PyObject *__pyx_k34; +static PyObject *__pyx_k9; +static PyObject *__pyx_k10; +static PyObject *__pyx_k11; static PyObject *(__pyx_f_6_loess_floatarray_from_data(int ,int ,double (*))); /*proto*/ static PyObject *(__pyx_f_6_loess_boolarray_from_data(int ,int ,int (*))); /*proto*/ @@ -178,40 +190,18 @@ /* Implementation of _loess */ static char (__pyx_k1[]) = "A (n,) ndarray of weights to be given to individual observations in the \n sum of squared residuals that forms the local fitting criterion. If not\n None, the weights should be non negative. If the different observations\n have non-equal variances, the weights should be inversely proportional \n to the variances.\n By default, an unweighted fit is carried out (all the weights are one).\n "; -static char (__pyx_k2[]) = "Number of observations."; -static char (__pyx_k3[]) = "Number of independent variables."; -static char (__pyx_k4[]) = "\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n "; -static char (__pyx_k5[]) = "\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n "; -static char (__pyx_k6[]) = "\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n "; -static char (__pyx_k7[]) = "\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n "; -static char (__pyx_k8[]) = "\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n "; -static char (__pyx_k9[]) = "\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n "; -static char (__pyx_k10[]) = "Smoothing factor, as a fraction of the number of points to take into\n account. By default, span=0.75."; -static char (__pyx_k11[]) = "\n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n "; -static char (__pyx_k12[]) = "\n family : string [\"gaussian\"]\n Determines the assumed distribution of the errors. The values are \n \"gaussian\" or \"symmetric\". If \"gaussian\" is selected, the fit is \n performed with least-squares. If \"symmetric\" is selected, the fit\n is performed robustly by redescending M-estimators.\n "; -static char (__pyx_k13[]) = "\n parametric_flags : sequence [ [False]*p ]\n Indicates which independent variables should be conditionally-parametric\n (if there are two or more independent variables). The argument should \n be a sequence of booleans, with the same size as the number of independent \n variables, specified in the order of the predictor group ordered in x. \n "; -static char (__pyx_k14[]) = "\n drop_square : sequence [ [False]* p]\n When there are two or more independent variables and when a 2nd order\n polynomial is used, \"drop_square_flags\" specifies those numeric predictors \n whose squares should be dropped from the set of fitting variables. \n The method of specification is the same as for parametric. \n "; -static char (__pyx_k15[]) = "\n fitted_values : ndarray\n The (n,) ndarray of fitted values.\n "; -static char (__pyx_k16[]) = "\n fitted_residuals : ndarray\n The (n,) ndarray of fitted residuals (observations - fitted values).\n "; -static char (__pyx_k17[]) = "\n pseudovalues : ndarray\n The (n,) ndarray of adjusted values of the response when robust estimation \n is used.\n "; -static char (__pyx_k18[]) = "\n diagonal :\n Diagonal of the operator hat matrix.\n "; -static char (__pyx_k19[]) = "\n robust : ndarray\n The (n,) ndarray of robustness weights for robust fitting.\n "; -static char (__pyx_k20[]) = "Equivalent number of parameters."; -static char (__pyx_k21[]) = "\n enp : float\n Equivalent number of parameters.\n "; -static char (__pyx_k22[]) = "\n s : float\n Estimate of the scale of residuals.\n "; -static char (__pyx_k23[]) = "\n one_delta: float\n Statistical parameter used in the computation of standard errors.\n "; -static char (__pyx_k24[]) = "\n two_delta : float\n Statistical parameter used in the computation of standard errors.\n "; -static char (__pyx_k25[]) = "\n trace_hat : float \n Trace of the operator hat matrix.\n "; -static char (__pyx_k26[]) = "\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n "; -static char (__pyx_k27[]) = "\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n "; -static char (__pyx_k28[]) = "\n residual_scale : float\n Estimate of the scale of the residuals\n "; -static char (__pyx_k29[]) = "\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n "; -static char (__pyx_k31[]) = "\n:Keywords:\n x : ndarray\n A (n,p) ndarray of independent variables, with n the number of observations\n and p the number of variables.\n y : ndarray\n A (n,) ndarray of observations\n weights : ndarray\n A (n,) ndarray of weights to be given to individual observations in the \n sum of squared residuals that forms the local fitting criterion. If not\n None, the weights should be non negative. If the different observations\n have non-equal variances, the weights should be inversely proportional \n to the variances.\n By default, an unweighted fit is carried out (all the weights are one).\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n span : float [0.75]\n Smoothing factor, as a fraction of the number of points to take into\n account. \n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n family : string [\"gaussian\"]\n Determines the assumed distribution of the errors. The values are \n \"gaussian\" or \"symmetric\". If \"gaussian\" is selected, the fit is \n performed with least-squares. If \"symmetric\" is selected, the fit\n is performed robustly by redescending M-estimators.\n parametric_flags : sequence [ [False]*p ]\n Indicates which independent variables should be conditionally-parametric\n (if there are two or more independent variables). The argument should \n be a sequence of booleans, with the same size as the number of independent \n variables, specified in the order of the predictor group ordered in x. \n drop_square : sequence [ [False]* p]\n When there are two or more independent variables and when a 2nd order\n polynomial is used, \"drop_square_flags\" specifies those numeric predictors \n whose squares should be dropped from the set of fitting variables. \n The method of specification is the same as for parametric. \n \n:Outputs:\n fitted_values : ndarray\n The (n,) ndarray of fitted values.\n fitted_residuals : ndarray\n The (n,) ndarray of fitted residuals (observations - fitted values).\n enp : float\n Equivalent number of parameters.\n s : float\n Estimate of the scale of residuals.\n one_delta: float\n Statistical parameter used in the computation of standard errors.\n two_delta : float\n Statistical parameter used in the computation of standard errors.\n pseudovalues : ndarray\n The (n,) ndarray of adjusted values of the response when robust estimation \n is used.\n trace_hat : float \n Trace of the operator hat matrix.\n diagonal :\n Diagonal of the operator hat matrix.\n robust : ndarray\n The (n,) ndarray of robustness weights for robust fitting.\n divisor : ndarray\n The (p,) array of normalization divisors for numeric predictors.\n \n\n newdata : ndarray\n The (m,p) array of independent variables where the surface must be estimated.\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n residual_scale : float\n Estimate of the scale of the residuals\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n nest : integer\n Number of new observations.\n \n \n"; +static char (__pyx_k2[]) = "\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n "; +static char (__pyx_k3[]) = "\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n "; +static char (__pyx_k4[]) = "\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n "; +static char (__pyx_k5[]) = "\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n "; +static char (__pyx_k6[]) = "\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n "; +static char (__pyx_k8[]) = "\n \n\n newdata : ndarray\n The (m,p) array of independent variables where the surface must be estimated.\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n residual_scale : float\n Estimate of the scale of the residuals\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n nest : integer\n Number of new observations.\n \n \n"; static PyObject *__pyx_n_c_python; static PyObject *__pyx_n_c_numpy; static PyObject *__pyx_n_numpy; static PyObject *__pyx_n_narray; +static PyObject *__pyx_n_float_; static PyObject *__pyx_n_c_loess; static PyObject *__pyx_n_array; static PyObject *__pyx_n_False; @@ -228,36 +218,36 @@ PyObject *__pyx_4 = 0; __pyx_v_a_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":19 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":20 */ __pyx_v_size = (__pyx_v_rows * __pyx_v_cols); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":20 */ - __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":21 */ + __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} Py_INCREF(((PyObject *)__pyx_1)); Py_DECREF(((PyObject *)__pyx_v_a_ndr)); __pyx_v_a_ndr = ((PyArrayObject *)((PyObject *)__pyx_1)); Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":21 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":22 */ __pyx_2 = (__pyx_v_cols > 1); if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":22 */ - __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} - __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":23 */ + __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3); __pyx_1 = 0; __pyx_3 = 0; - if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; goto __pyx_L1;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":23 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":24 */ Py_INCREF(((PyObject *)__pyx_v_a_ndr)); __pyx_r = ((PyObject *)__pyx_v_a_ndr); goto __pyx_L0; @@ -288,44 +278,44 @@ PyObject *__pyx_4 = 0; __pyx_v_a_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":28 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":29 */ __pyx_v_size = (__pyx_v_rows * __pyx_v_cols); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":29 */ - __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":30 */ + __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;} Py_INCREF(((PyObject *)__pyx_1)); Py_DECREF(((PyObject *)__pyx_v_a_ndr)); __pyx_v_a_ndr = ((PyArrayObject *)((PyObject *)__pyx_1)); Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":30 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":31 */ __pyx_2 = (__pyx_v_cols > 1); if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":31 */ - __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} - __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":32 */ + __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3); __pyx_1 = 0; __pyx_3 = 0; - if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":32 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_astype); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} - __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_bool); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":33 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_astype); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_bool); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4); __pyx_4 = 0; - __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -345,135 +335,299 @@ return __pyx_r; } -static PyObject *__pyx_f_6_loess_12loess_inputs_1x___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6_loess_12loess_inputs_1x___get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - Py_INCREF(__pyx_v_self); +static PyObject *__pyx_n_copy; +static PyObject *__pyx_n_True; +static PyObject *__pyx_n_subok; +static PyObject *__pyx_n_dtype; +static PyObject *__pyx_n_order; +static PyObject *__pyx_n_C; +static PyObject *__pyx_n_ndim; +static PyObject *__pyx_n_ValueError; +static PyObject *__pyx_n_len; +static PyObject *__pyx_n_ravel; +static PyObject *__pyx_n_ones; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":198 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->n,((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->p,((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->x); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; +static PyObject *__pyx_k22p; - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("_loess.loess_inputs.x.__get__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} +static char (__pyx_k22[]) = "The array of indepedent varibales should be 2D at most!"; -static PyObject *__pyx_f_6_loess_12loess_inputs_1y___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6_loess_12loess_inputs_1y___get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; +static int __pyx_f_6_loess_12loess_inputs___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_6_loess_12loess_inputs___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_x_data = 0; + PyObject *__pyx_v_y_data = 0; + int __pyx_r; PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + int __pyx_5; + static char *__pyx_argnames[] = {"x_data","y_data",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_x_data, &__pyx_v_y_data)) return -1; Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_x_data); + Py_INCREF(__pyx_v_y_data); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":202 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->n,1,((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->y); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":89 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + Py_INCREF(__pyx_v_x_data); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x_data); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_float_); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_dtype, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->x)); + ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->x = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; - __pyx_r = Py_None; Py_INCREF(Py_None); + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":90 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + Py_INCREF(__pyx_v_y_data); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_y_data); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_float_); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_dtype, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->y)); + ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->y = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":92 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->x), __pyx_n_ndim); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_2, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + __pyx_5 = __pyx_5 == 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__pyx_5) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":93 */ + ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->npar = 1; + goto __pyx_L2; + } + __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->x), __pyx_n_ndim); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;} + __pyx_4 = PyInt_FromLong(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_3, __pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; goto __pyx_L1;} + __pyx_5 = __pyx_5 == 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (__pyx_5) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":95 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->x), __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong((-1)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + __pyx_3 = PyObject_GetItem(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_5 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->npar = __pyx_5; + goto __pyx_L2; + } + /*else*/ { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":97 */ + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + Py_INCREF(__pyx_k22p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k22p); + __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_2, 0, 0); + Py_DECREF(__pyx_2); __pyx_2 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":98 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->x)); + PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->x)); + __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_5 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->nobs = __pyx_5; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":100 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->x), __pyx_n_ravel); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->x_eff)); + ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->x_eff = ((PyArrayObject *)__pyx_3); + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":101 */ + Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->y)); + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->y_eff)); + ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->y_eff = ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->y; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":102 */ + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_4, __pyx_n_ones); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->nobs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); + __pyx_2 = 0; + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_float_); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_2, __pyx_n_dtype, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_3 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->w_ndr)); + ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->w_ndr = ((PyArrayObject *)__pyx_3); + __pyx_3 = 0; + + __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("_loess.loess_inputs.y.__get__"); - __pyx_r = 0; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_loess.loess_inputs.__init__"); + __pyx_r = -1; __pyx_L0:; Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_x_data); + Py_DECREF(__pyx_v_y_data); return __pyx_r; } static PyObject *__pyx_f_6_loess_12loess_inputs_7weights___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6_loess_12loess_inputs_7weights___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; - PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":213 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->n,1,((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->weights); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":114 */ + Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->w_ndr)); + __pyx_r = ((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->w_ndr); goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("_loess.loess_inputs.weights.__get__"); - __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } -static PyObject *__pyx_n_ndim; static PyObject *__pyx_n_size; -static PyObject *__pyx_n_ValueError; -static PyObject *__pyx_k35p; +static PyObject *__pyx_k26p; -static char (__pyx_k35[]) = "Invalid size of the 'weights' vector!"; +static char (__pyx_k26[]) = "Invalid size of the 'weights' vector!"; static int __pyx_f_6_loess_12loess_inputs_7weights___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_w); /*proto*/ static int __pyx_f_6_loess_12loess_inputs_7weights___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_w) { PyArrayObject *__pyx_v_w_ndr; int __pyx_r; PyObject *__pyx_1 = 0; - int __pyx_2; + PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + int __pyx_5; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_w); __pyx_v_w_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":218 */ - __pyx_1 = PyArray_FROMANY(__pyx_v_w,NPY_DOUBLE,1,1,NPY_OWNDATA); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;} - Py_INCREF(((PyObject *)((PyArrayObject *)__pyx_1))); + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":119 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;} + Py_INCREF(__pyx_v_w); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_w); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_w_ndr)); - __pyx_v_w_ndr = ((PyArrayObject *)__pyx_1); - Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_v_w_ndr = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":219 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_ndim); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} - __pyx_2 = __pyx_2 > 0; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":120 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_ndim); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_2, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} + __pyx_5 = __pyx_5 > 0; Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (!__pyx_2) { - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} - __pyx_3 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} - __pyx_2 = __pyx_2 != 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (!__pyx_5) { + __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_size); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} + __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->nobs); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_3, __pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} + __pyx_5 = __pyx_5 != 0; Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; } - if (__pyx_2) { + if (__pyx_5) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":220 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;} - __Pyx_Raise(__pyx_1, __pyx_k35p, 0); + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":121 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; goto __pyx_L1;} + __Pyx_Raise(__pyx_1, __pyx_k26p, 0); Py_DECREF(__pyx_1); __pyx_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":221 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":122 */ + Py_INCREF(((PyObject *)__pyx_v_w_ndr)); + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->w_ndr)); + ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->w_ndr = __pyx_v_w_ndr; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":123 */ ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->weights = ((double (*))__pyx_v_w_ndr->data); __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); __Pyx_AddTraceback("_loess.loess_inputs.weights.__set__"); __pyx_r = -1; __pyx_L0:; @@ -483,60 +637,14 @@ return __pyx_r; } -static PyObject *__pyx_f_6_loess_12loess_inputs_4nobs___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6_loess_12loess_inputs_4nobs___get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - Py_INCREF(__pyx_v_self); - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":226 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("_loess.loess_inputs.nobs.__get__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static PyObject *__pyx_f_6_loess_12loess_inputs_4npar___get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_6_loess_12loess_inputs_4npar___get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - Py_INCREF(__pyx_v_self); - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":231 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_inputs *)__pyx_v_self)->_base->p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("_loess.loess_inputs.npar.__get__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - static PyObject *__pyx_f_6_loess_13loess_control_7surface___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6_loess_13loess_control_7surface___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":248 */ - __pyx_1 = PyString_FromString(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":174 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -556,11 +664,11 @@ static PyObject *__pyx_n_interpolate; static PyObject *__pyx_n_direct; -static PyObject *__pyx_k38p; -static PyObject *__pyx_k39p; +static PyObject *__pyx_k29p; +static PyObject *__pyx_k30p; -static char (__pyx_k38[]) = "Invalid value for the 'surface' argument: "; -static char (__pyx_k39[]) = "should be in ('interpolate', 'direct')."; +static char (__pyx_k29[]) = "Invalid value for the 'surface' argument: "; +static char (__pyx_k30[]) = "should be in ('interpolate', 'direct')."; static int __pyx_f_6_loess_13loess_control_7surface___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_surface); /*proto*/ static int __pyx_f_6_loess_13loess_control_7surface___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_surface) { @@ -575,47 +683,47 @@ Py_INCREF(__pyx_v_surface); __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":250 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;} - __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":176 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;} + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;} Py_INCREF(__pyx_n_interpolate); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_interpolate); Py_INCREF(__pyx_n_direct); PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_direct); - __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;} + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;} __pyx_3 = !__pyx_3; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_3) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":251 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} - __pyx_1 = PyNumber_Add(__pyx_k38p, __pyx_k39p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":177 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} + __pyx_1 = PyNumber_Add(__pyx_k29p, __pyx_k30p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_1, 0, 0); Py_DECREF(__pyx_1); __pyx_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":253 */ - __pyx_2 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;} - __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":179 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_tmpx); __pyx_v_tmpx = __pyx_4; __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":254 */ - __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":180 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;} ((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->surface = __pyx_5; __pyx_r = 0; @@ -639,8 +747,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":265 */ - __pyx_1 = PyString_FromString(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":191 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -659,9 +767,9 @@ static PyObject *__pyx_n_approximate; static PyObject *__pyx_n_exact; -static PyObject *__pyx_k42p; +static PyObject *__pyx_k33p; -static char (__pyx_k42[]) = "Invalid value for the 'statistics' argument: should be in ('approximate', 'exact')."; +static char (__pyx_k33[]) = "Invalid value for the 'statistics' argument: should be in ('approximate', 'exact')."; static int __pyx_f_6_loess_13loess_control_10statistics___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_statistics); /*proto*/ static int __pyx_f_6_loess_13loess_control_10statistics___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_statistics) { @@ -676,46 +784,46 @@ Py_INCREF(__pyx_v_statistics); __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":267 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} - __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":193 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;} Py_INCREF(__pyx_n_approximate); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_approximate); Py_INCREF(__pyx_n_exact); PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_exact); - __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;} __pyx_3 = !__pyx_3; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_3) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":268 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} - Py_INCREF(__pyx_k42p); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k42p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":194 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + Py_INCREF(__pyx_k33p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k33p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":270 */ - __pyx_2 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;} - __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":196 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_tmpx); __pyx_v_tmpx = __pyx_1; __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":271 */ - __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":197 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;} ((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->statistics = __pyx_5; __pyx_r = 0; @@ -739,8 +847,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":287 */ - __pyx_1 = PyString_FromString(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":213 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -756,9 +864,9 @@ return __pyx_r; } -static PyObject *__pyx_k45p; +static PyObject *__pyx_k36p; -static char (__pyx_k45[]) = "Invalid value for the 'trace_hat' argument: should be in ('approximate', 'exact')."; +static char (__pyx_k36[]) = "Invalid value for the 'trace_hat' argument: should be in ('approximate', 'exact')."; static int __pyx_f_6_loess_13loess_control_9trace_hat___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_trace_hat); /*proto*/ static int __pyx_f_6_loess_13loess_control_9trace_hat___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_trace_hat) { @@ -773,46 +881,46 @@ Py_INCREF(__pyx_v_trace_hat); __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":289 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} - __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":215 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;} Py_INCREF(__pyx_n_approximate); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_approximate); Py_INCREF(__pyx_n_exact); PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_exact); - __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; goto __pyx_L1;} __pyx_3 = !__pyx_3; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_3) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":290 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} - Py_INCREF(__pyx_k45p); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k45p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":216 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} + Py_INCREF(__pyx_k36p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k36p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":292 */ - __pyx_2 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;} - __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":218 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_tmpx); __pyx_v_tmpx = __pyx_1; __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":293 */ - __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":219 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;} ((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->trace_hat = __pyx_5; __pyx_r = 0; @@ -836,8 +944,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":302 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":228 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -853,9 +961,9 @@ return __pyx_r; } -static PyObject *__pyx_k46p; +static PyObject *__pyx_k37p; -static char (__pyx_k46[]) = "Invalid number of iterations: should be positive"; +static char (__pyx_k37[]) = "Invalid number of iterations: should be positive"; static int __pyx_f_6_loess_13loess_control_10iterations___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_iterations); /*proto*/ static int __pyx_f_6_loess_13loess_control_10iterations___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_iterations) { @@ -867,30 +975,30 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_iterations); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":304 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_iterations, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":230 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_iterations, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; goto __pyx_L1;} __pyx_2 = __pyx_2 < 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":305 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} - Py_INCREF(__pyx_k46p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k46p); - __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":231 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} + Py_INCREF(__pyx_k37p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k37p); + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":306 */ - __pyx_2 = PyInt_AsLong(__pyx_v_iterations); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":232 */ + __pyx_2 = PyInt_AsLong(__pyx_v_iterations); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;} ((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->iterations = __pyx_2; __pyx_r = 0; @@ -913,8 +1021,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":318 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":244 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -930,9 +1038,9 @@ return __pyx_r; } -static PyObject *__pyx_k47p; +static PyObject *__pyx_k38p; -static char (__pyx_k47[]) = "Invalid value for the cell argument: should be positive"; +static char (__pyx_k38[]) = "Invalid value for the cell argument: should be positive"; static int __pyx_f_6_loess_13loess_control_4cell___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_cell); /*proto*/ static int __pyx_f_6_loess_13loess_control_4cell___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_cell) { @@ -945,30 +1053,30 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_cell); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":320 */ - __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_cell, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":246 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_cell, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; goto __pyx_L1;} __pyx_2 = __pyx_2 <= 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":321 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;} - Py_INCREF(__pyx_k47p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k47p); - __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":247 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;} + Py_INCREF(__pyx_k38p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k38p); + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":322 */ - __pyx_5 = PyFloat_AsDouble(__pyx_v_cell); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":248 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_cell); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; goto __pyx_L1;} ((struct __pyx_obj_6_loess_loess_control *)__pyx_v_self)->_base->cell = __pyx_5; __pyx_r = 0; @@ -1023,122 +1131,122 @@ __pyx_v_iterations = Py_None; Py_INCREF(Py_None); __pyx_v_cell = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":326 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":252 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} Py_INCREF(__pyx_n_surface); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_surface); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_surface); __pyx_v_surface = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":327 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":253 */ __pyx_4 = __pyx_v_surface != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":328 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_surface, __pyx_v_surface) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":254 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_surface, __pyx_v_surface) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":330 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":256 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;} Py_INCREF(__pyx_n_statistics); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_statistics); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_statistics); __pyx_v_statistics = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":331 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":257 */ __pyx_4 = __pyx_v_statistics != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":332 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_statistics, __pyx_v_statistics) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":258 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_statistics, __pyx_v_statistics) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} goto __pyx_L3; } __pyx_L3:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":334 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":260 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;} Py_INCREF(__pyx_n_trace_hat); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_trace_hat); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_trace_hat); __pyx_v_trace_hat = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":335 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":261 */ __pyx_4 = __pyx_v_trace_hat != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":336 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_trace_hat, __pyx_v_trace_hat) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":262 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_trace_hat, __pyx_v_trace_hat) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; goto __pyx_L1;} goto __pyx_L4; } __pyx_L4:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":338 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":264 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} Py_INCREF(__pyx_n_iterations); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_iterations); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_iterations); __pyx_v_iterations = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":339 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":265 */ __pyx_4 = __pyx_v_iterations != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":340 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_iterations, __pyx_v_iterations) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":266 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_iterations, __pyx_v_iterations) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; goto __pyx_L1;} goto __pyx_L5; } __pyx_L5:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":342 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":268 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} Py_INCREF(__pyx_n_cell); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_cell); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_cell); __pyx_v_cell = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":343 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":269 */ __pyx_4 = __pyx_v_cell != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":344 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":270 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;} goto __pyx_L6; } __pyx_L6:; @@ -1166,21 +1274,21 @@ static PyObject *__pyx_n_join; -static PyObject *__pyx_k53p; -static PyObject *__pyx_k54p; -static PyObject *__pyx_k55p; -static PyObject *__pyx_k56p; -static PyObject *__pyx_k57p; -static PyObject *__pyx_k58p; -static PyObject *__pyx_k59p; +static PyObject *__pyx_k44p; +static PyObject *__pyx_k45p; +static PyObject *__pyx_k46p; +static PyObject *__pyx_k47p; +static PyObject *__pyx_k48p; +static PyObject *__pyx_k49p; +static PyObject *__pyx_k50p; -static char (__pyx_k53[]) = "Control :"; -static char (__pyx_k54[]) = "Surface type : %s"; -static char (__pyx_k55[]) = "Statistics : %s"; -static char (__pyx_k56[]) = "Trace estimation : %s"; -static char (__pyx_k57[]) = "Cell size : %s"; -static char (__pyx_k58[]) = "Nb iterations : %s"; -static char (__pyx_k59[]) = "\n"; +static char (__pyx_k44[]) = "Control :"; +static char (__pyx_k45[]) = "Surface type : %s"; +static char (__pyx_k46[]) = "Statistics : %s"; +static char (__pyx_k47[]) = "Trace estimation : %s"; +static char (__pyx_k48[]) = "Cell size : %s"; +static char (__pyx_k49[]) = "Nb iterations : %s"; +static char (__pyx_k50[]) = "\n"; static PyObject *__pyx_f_6_loess_13loess_control___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6_loess_13loess_control___str__(PyObject *__pyx_v_self) { @@ -1195,25 +1303,25 @@ Py_INCREF(__pyx_v_self); __pyx_v_strg = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":348 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k54p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":274 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k45p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;} - __pyx_3 = PyNumber_Remainder(__pyx_k55p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k46p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;} - __pyx_4 = PyNumber_Remainder(__pyx_k56p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k47p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;} - __pyx_5 = PyNumber_Remainder(__pyx_k57p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k48p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;} - __pyx_6 = PyNumber_Remainder(__pyx_k58p, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} + __pyx_6 = PyNumber_Remainder(__pyx_k49p, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyList_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;} - Py_INCREF(__pyx_k53p); - PyList_SET_ITEM(__pyx_1, 0, __pyx_k53p); + __pyx_1 = PyList_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; goto __pyx_L1;} + Py_INCREF(__pyx_k44p); + PyList_SET_ITEM(__pyx_1, 0, __pyx_k44p); PyList_SET_ITEM(__pyx_1, 1, __pyx_2); PyList_SET_ITEM(__pyx_1, 2, __pyx_3); PyList_SET_ITEM(__pyx_1, 3, __pyx_4); @@ -1228,12 +1336,12 @@ __pyx_v_strg = __pyx_1; __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":354 */ - __pyx_2 = PyObject_GetAttr(__pyx_k59p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":280 */ + __pyx_2 = PyObject_GetAttr(__pyx_k50p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;} Py_INCREF(__pyx_v_strg); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -1261,13 +1369,13 @@ PyObject *__pyx_r; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":375 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":335 */ __pyx_v_self->_base = __pyx_v_base; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":376 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":336 */ __pyx_v_self->npar = __pyx_v_npar; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":386 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":337 */ Py_INCREF(((PyObject *)__pyx_v_self)); __pyx_r = ((PyObject *)__pyx_v_self); goto __pyx_L0; @@ -1286,13 +1394,13 @@ PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":399 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_bool); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->normalize); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":341 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_bool); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->normalize); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_2; @@ -1319,8 +1427,8 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_normalize); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":401 */ - __pyx_1 = PyInt_AsLong(__pyx_v_normalize); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":343 */ + __pyx_1 = PyInt_AsLong(__pyx_v_normalize); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;} ((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->normalize = __pyx_1; __pyx_r = 0; @@ -1340,8 +1448,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":407 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":347 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -1357,9 +1465,9 @@ return __pyx_r; } -static PyObject *__pyx_k60p; +static PyObject *__pyx_k51p; -static char (__pyx_k60[]) = "Span should be between 0 and 1!"; +static char (__pyx_k51[]) = "Span should be between 0 and 1!"; static int __pyx_f_6_loess_11loess_model_4span___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_span); /*proto*/ static int __pyx_f_6_loess_11loess_model_4span___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_span) { @@ -1372,36 +1480,36 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_span); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":409 */ - __pyx_2 = PyFloat_FromDouble(0.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":349 */ + __pyx_2 = PyFloat_FromDouble(0.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;} __pyx_1 = __pyx_1 <= 0; Py_DECREF(__pyx_2); __pyx_2 = 0; if (!__pyx_1) { - __pyx_2 = PyFloat_FromDouble(1.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} + __pyx_2 = PyFloat_FromDouble(1.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;} __pyx_1 = __pyx_1 > 0; Py_DECREF(__pyx_2); __pyx_2 = 0; } if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":410 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;} - Py_INCREF(__pyx_k60p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k60p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":350 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;} + Py_INCREF(__pyx_k51p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k51p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":411 */ - __pyx_5 = PyFloat_AsDouble(__pyx_v_span); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":351 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_span); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;} ((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->span = __pyx_5; __pyx_r = 0; @@ -1424,8 +1532,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":420 */ - __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":355 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -1441,9 +1549,9 @@ return __pyx_r; } -static PyObject *__pyx_k61p; +static PyObject *__pyx_k52p; -static char (__pyx_k61[]) = "Degree should be between 0 and 2!"; +static char (__pyx_k52[]) = "Degree should be between 0 and 2!"; static int __pyx_f_6_loess_11loess_model_6degree___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_degree); /*proto*/ static int __pyx_f_6_loess_11loess_model_6degree___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_degree) { @@ -1455,34 +1563,38 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_degree); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":422 */ - __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":357 */ + __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; goto __pyx_L1;} __pyx_1 = __pyx_1 < 0; Py_DECREF(__pyx_2); __pyx_2 = 0; if (!__pyx_1) { - __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; goto __pyx_L1;} __pyx_1 = __pyx_1 > 0; Py_DECREF(__pyx_2); __pyx_2 = 0; } if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":423 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} - Py_INCREF(__pyx_k61p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k61p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":358 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;} + Py_INCREF(__pyx_k52p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k52p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":359 */ + __pyx_1 = PyInt_AsLong(__pyx_v_degree); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; goto __pyx_L1;} + ((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->degree = __pyx_1; + __pyx_r = 0; goto __pyx_L0; __pyx_L1:; @@ -1503,8 +1615,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":434 */ - __pyx_1 = PyString_FromString(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":363 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -1523,9 +1635,9 @@ static PyObject *__pyx_n_symmetric; static PyObject *__pyx_n_gaussian; -static PyObject *__pyx_k64p; +static PyObject *__pyx_k55p; -static char (__pyx_k64[]) = "Invalid value for the 'family' argument: should be in ('symmetric', 'gaussian')."; +static char (__pyx_k55[]) = "Invalid value for the 'family' argument: should be in ('symmetric', 'gaussian')."; static int __pyx_f_6_loess_11loess_model_6family___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_family); /*proto*/ static int __pyx_f_6_loess_11loess_model_6family___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_family) { @@ -1538,38 +1650,38 @@ Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_family); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":436 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_family, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} - __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":365 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_family, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; goto __pyx_L1;} Py_INCREF(__pyx_n_symmetric); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_symmetric); Py_INCREF(__pyx_n_gaussian); PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_gaussian); - __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; goto __pyx_L1;} __pyx_3 = !__pyx_3; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_3) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":437 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} - Py_INCREF(__pyx_k64p); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k64p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":366 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} + Py_INCREF(__pyx_k55p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k55p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":439 */ - __pyx_5 = PyString_AsString(__pyx_v_family); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":368 */ + __pyx_5 = PyString_AsString(__pyx_v_family); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;} ((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->family = __pyx_5; __pyx_r = 0; @@ -1592,8 +1704,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":450 */ - __pyx_1 = __pyx_f_6_loess_boolarray_from_data(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->parametric); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":372 */ + __pyx_1 = __pyx_f_6_loess_boolarray_from_data(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->parametric); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -1610,10 +1722,6 @@ } static PyObject *__pyx_n_atleast_1d; -static PyObject *__pyx_n_copy; -static PyObject *__pyx_n_True; -static PyObject *__pyx_n_subok; -static PyObject *__pyx_n_dtype; static PyObject *__pyx_n_min; @@ -1634,62 +1742,62 @@ Py_INCREF(__pyx_v_paramf); __pyx_v_p_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":454 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_atleast_1d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":376 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_atleast_1d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} Py_INCREF(__pyx_v_paramf); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_paramf); - __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} - __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; goto __pyx_L1;} - __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_bool); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_bool); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - if (PyDict_SetItem(__pyx_4, __pyx_n_dtype, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_dtype, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; - __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5); __pyx_5 = 0; - __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_6); __pyx_6 = 0; - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_p_ndr)); __pyx_v_p_ndr = ((PyArrayObject *)__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":456 */ - __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} - __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} - __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":378 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;} + __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); PyTuple_SET_ITEM(__pyx_2, 1, __pyx_5); __pyx_4 = 0; __pyx_5 = 0; - __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_7 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;} + __pyx_7 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; for (__pyx_v_i = 0; __pyx_v_i < __pyx_7; ++__pyx_v_i) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":457 */ - __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; goto __pyx_L1;} - __pyx_4 = PyObject_GetItem(((PyObject *)__pyx_v_p_ndr), __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":379 */ + __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; goto __pyx_L1;} + __pyx_4 = PyObject_GetItem(((PyObject *)__pyx_v_p_ndr), __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_8 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; goto __pyx_L1;} + __pyx_8 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; (((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->parametric[__pyx_v_i]) = __pyx_8; } @@ -1718,8 +1826,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":468 */ - __pyx_1 = __pyx_f_6_loess_boolarray_from_data(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->drop_square); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":383 */ + __pyx_1 = __pyx_f_6_loess_boolarray_from_data(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->drop_square); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -1753,62 +1861,62 @@ Py_INCREF(__pyx_v_drop_sq); __pyx_v_d_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":472 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_atleast_1d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":387 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_atleast_1d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} Py_INCREF(__pyx_v_drop_sq); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_drop_sq); - __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} - __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; goto __pyx_L1;} - __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_bool); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_bool); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - if (PyDict_SetItem(__pyx_4, __pyx_n_dtype, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_dtype, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; - __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5); __pyx_5 = 0; - __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_6); __pyx_6 = 0; - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_d_ndr)); __pyx_v_d_ndr = ((PyArrayObject *)__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":474 */ - __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} - __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} - __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_d_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":389 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;} + __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_d_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); PyTuple_SET_ITEM(__pyx_2, 1, __pyx_5); __pyx_4 = 0; __pyx_5 = 0; - __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_7 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; goto __pyx_L1;} + __pyx_7 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; for (__pyx_v_i = 0; __pyx_v_i < __pyx_7; ++__pyx_v_i) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":475 */ - __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; goto __pyx_L1;} - __pyx_4 = PyObject_GetItem(((PyObject *)__pyx_v_d_ndr), __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":390 */ + __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;} + __pyx_4 = PyObject_GetItem(((PyObject *)__pyx_v_d_ndr), __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_8 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; goto __pyx_L1;} + __pyx_8 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; (((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->_base->drop_square[__pyx_v_i]) = __pyx_8; } @@ -1870,146 +1978,146 @@ __pyx_v_parametric = Py_None; Py_INCREF(Py_None); __pyx_v_drop_square = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":478 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":393 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; goto __pyx_L1;} Py_INCREF(__pyx_n_family); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_family); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_family); __pyx_v_family = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":479 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":394 */ __pyx_4 = __pyx_v_family != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":480 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_family, __pyx_v_family) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":395 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_family, __pyx_v_family) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":482 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":397 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;} Py_INCREF(__pyx_n_span); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_span); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_span); __pyx_v_span = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":483 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":398 */ __pyx_4 = __pyx_v_span != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":484 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_span, __pyx_v_span) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":399 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_span, __pyx_v_span) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} goto __pyx_L3; } __pyx_L3:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":486 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":401 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;} Py_INCREF(__pyx_n_degree); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_degree); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_degree); __pyx_v_degree = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":487 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":402 */ __pyx_4 = __pyx_v_degree != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":488 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_degree, __pyx_v_degree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":403 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_degree, __pyx_v_degree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; goto __pyx_L1;} goto __pyx_L4; } __pyx_L4:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":490 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":405 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; goto __pyx_L1;} Py_INCREF(__pyx_n_normalize); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_normalize); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_normalize); __pyx_v_normalize = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":491 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":406 */ __pyx_4 = __pyx_v_normalize != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":492 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_normalize, __pyx_v_normalize) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":407 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_normalize, __pyx_v_normalize) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; goto __pyx_L1;} goto __pyx_L5; } __pyx_L5:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":494 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":409 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} Py_INCREF(__pyx_n_parametric); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_parametric); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_parametric); __pyx_v_parametric = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":495 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":410 */ __pyx_4 = __pyx_v_parametric != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":496 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_parametric) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":411 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_parametric) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; goto __pyx_L1;} goto __pyx_L6; } __pyx_L6:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":498 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":413 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; goto __pyx_L1;} Py_INCREF(__pyx_n_drop_square); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_drop_square); Py_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_2, 1, Py_None); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_v_drop_square); __pyx_v_drop_square = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":499 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":414 */ __pyx_4 = __pyx_v_drop_square != Py_None; if (__pyx_4) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":500 */ - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_drop_square_flags, __pyx_v_drop_square) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":415 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_drop_square_flags, __pyx_v_drop_square) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; goto __pyx_L1;} goto __pyx_L7; } __pyx_L7:; @@ -2036,64 +2144,43 @@ return __pyx_r; } -static PyObject *__pyx_n_id; +static PyObject *__pyx_k68p; -static PyObject *__pyx_k77p; +static char (__pyx_k68[]) = ""; -static char (__pyx_k77[]) = "loess model parameters @%s"; - static PyObject *__pyx_f_6_loess_11loess_model___repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6_loess_11loess_model___repr__(PyObject *__pyx_v_self) { PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":503 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;} - Py_INCREF(__pyx_v_self); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyNumber_Remainder(__pyx_k77p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_r = __pyx_1; - __pyx_1 = 0; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":418 */ + Py_INCREF(__pyx_k68p); + __pyx_r = __pyx_k68p; goto __pyx_L0; __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("_loess.loess_model.__repr__"); - __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } -static PyObject *__pyx_k78p; -static PyObject *__pyx_k79p; -static PyObject *__pyx_k80p; -static PyObject *__pyx_k81p; -static PyObject *__pyx_k82p; -static PyObject *__pyx_k83p; -static PyObject *__pyx_k84p; -static PyObject *__pyx_k85p; +static PyObject *__pyx_k69p; +static PyObject *__pyx_k70p; +static PyObject *__pyx_k71p; +static PyObject *__pyx_k72p; +static PyObject *__pyx_k73p; +static PyObject *__pyx_k74p; +static PyObject *__pyx_k75p; +static PyObject *__pyx_k76p; -static char (__pyx_k78[]) = "Model parameters....."; -static char (__pyx_k79[]) = "family : %s"; -static char (__pyx_k80[]) = "span : %s"; -static char (__pyx_k81[]) = "degree : %s"; -static char (__pyx_k82[]) = "normalized : %s"; -static char (__pyx_k83[]) = "parametric : %s"; -static char (__pyx_k84[]) = "drop_square : %s"; -static char (__pyx_k85[]) = "\n"; +static char (__pyx_k69[]) = "Model parameters....."; +static char (__pyx_k70[]) = "Family : %s"; +static char (__pyx_k71[]) = "Span : %s"; +static char (__pyx_k72[]) = "Degree : %s"; +static char (__pyx_k73[]) = "Normalized : %s"; +static char (__pyx_k74[]) = "Parametric : %s"; +static char (__pyx_k75[]) = "Drop_square : %s"; +static char (__pyx_k76[]) = "\n"; static PyObject *__pyx_f_6_loess_11loess_model___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6_loess_11loess_model___str__(PyObject *__pyx_v_self) { @@ -2109,32 +2196,32 @@ Py_INCREF(__pyx_v_self); __pyx_v_strg = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":506 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k79p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":421 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k70p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;} - __pyx_3 = PyNumber_Remainder(__pyx_k80p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k71p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;} - __pyx_4 = PyNumber_Remainder(__pyx_k81p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k72p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_normalize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; goto __pyx_L1;} - __pyx_5 = PyNumber_Remainder(__pyx_k82p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_normalize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k73p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_parametric_flags); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; goto __pyx_L1;} - __pyx_6 = PySequence_GetSlice(__pyx_1, 0, ((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_parametric_flags); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;} + __pyx_6 = PySequence_GetSlice(__pyx_1, 0, ((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyNumber_Remainder(__pyx_k83p, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k74p, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; - __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_drop_square_flags); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;} - __pyx_7 = PySequence_GetSlice(__pyx_6, 0, ((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_drop_square_flags); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;} + __pyx_7 = PySequence_GetSlice(__pyx_6, 0, ((struct __pyx_obj_6_loess_loess_model *)__pyx_v_self)->npar); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; - __pyx_6 = PyNumber_Remainder(__pyx_k84p, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; goto __pyx_L1;} + __pyx_6 = PyNumber_Remainder(__pyx_k75p, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; goto __pyx_L1;} Py_DECREF(__pyx_7); __pyx_7 = 0; - __pyx_7 = PyList_New(7); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; goto __pyx_L1;} - Py_INCREF(__pyx_k78p); - PyList_SET_ITEM(__pyx_7, 0, __pyx_k78p); + __pyx_7 = PyList_New(7); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;} + Py_INCREF(__pyx_k69p); + PyList_SET_ITEM(__pyx_7, 0, __pyx_k69p); PyList_SET_ITEM(__pyx_7, 1, __pyx_2); PyList_SET_ITEM(__pyx_7, 2, __pyx_3); PyList_SET_ITEM(__pyx_7, 3, __pyx_4); @@ -2151,12 +2238,12 @@ __pyx_v_strg = __pyx_7; __pyx_7 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":514 */ - __pyx_2 = PyObject_GetAttr(__pyx_k85p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":429 */ + __pyx_2 = PyObject_GetAttr(__pyx_k76p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; goto __pyx_L1;} Py_INCREF(__pyx_v_strg); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -2181,14 +2268,46 @@ return __pyx_r; } +static PyObject *__pyx_f_6_loess_13loess_outputs_setup(struct __pyx_obj_6_loess_loess_outputs *__pyx_v_self,loess_outputs (*__pyx_v_base),long __pyx_v_nobs,long __pyx_v_npar) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":468 */ + __pyx_v_self->_base = __pyx_v_base; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":469 */ + __pyx_v_self->nobs = __pyx_v_nobs; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":470 */ + __pyx_v_self->npar = __pyx_v_npar; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":471 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; goto __pyx_L1;} + __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_v_self->activated = __pyx_2; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_loess.loess_outputs.setup"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + static PyObject *__pyx_f_6_loess_13loess_outputs_13fitted_values___get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6_loess_13loess_outputs_13fitted_values___get__(PyObject *__pyx_v_self) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":530 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->fitted_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":475 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->fitted_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2210,8 +2329,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":538 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->fitted_residuals); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":479 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->fitted_residuals); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2233,8 +2352,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":547 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->pseudovalues); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":483 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->pseudovalues); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2256,8 +2375,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":555 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->diagonal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":487 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->diagonal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2279,8 +2398,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":563 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->robust); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":491 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->nobs,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->robust); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2302,8 +2421,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":568 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->npar,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->divisor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":495 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->npar,1,((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->divisor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2325,8 +2444,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":576 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":499 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2348,8 +2467,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":584 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":503 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2371,8 +2490,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":592 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":507 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2394,8 +2513,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":600 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->two_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":511 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->two_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2417,8 +2536,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":608 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":515 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_outputs *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2442,23 +2561,23 @@ static PyObject *__pyx_n_two_delta; static PyObject *__pyx_n_divisor; -static PyObject *__pyx_k86p; -static PyObject *__pyx_k87p; -static PyObject *__pyx_k88p; -static PyObject *__pyx_k89p; -static PyObject *__pyx_k90p; -static PyObject *__pyx_k91p; -static PyObject *__pyx_k92p; -static PyObject *__pyx_k93p; +static PyObject *__pyx_k77p; +static PyObject *__pyx_k78p; +static PyObject *__pyx_k79p; +static PyObject *__pyx_k80p; +static PyObject *__pyx_k81p; +static PyObject *__pyx_k82p; +static PyObject *__pyx_k83p; +static PyObject *__pyx_k84p; -static char (__pyx_k86[]) = "Outputs................"; -static char (__pyx_k87[]) = "Fitted values : %s\n"; -static char (__pyx_k88[]) = "Fitted residuals : %s\n"; -static char (__pyx_k89[]) = "Eqv. nb of parameters : %s"; -static char (__pyx_k90[]) = "Residual error : %s"; -static char (__pyx_k91[]) = "Deltas : %s - %s"; -static char (__pyx_k92[]) = "Normalization factors : %s"; -static char (__pyx_k93[]) = "\n"; +static char (__pyx_k77[]) = "Outputs................"; +static char (__pyx_k78[]) = "Fitted values : %s\n"; +static char (__pyx_k79[]) = "Fitted residuals : %s\n"; +static char (__pyx_k80[]) = "Eqv. nb of parameters : %s"; +static char (__pyx_k81[]) = "Residual error : %s"; +static char (__pyx_k82[]) = "Deltas : %s - %s"; +static char (__pyx_k83[]) = "Normalization factors : %s"; +static char (__pyx_k84[]) = "\n"; static PyObject *__pyx_f_6_loess_13loess_outputs___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6_loess_13loess_outputs___str__(PyObject *__pyx_v_self) { @@ -2474,34 +2593,34 @@ Py_INCREF(__pyx_v_self); __pyx_v_strg = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":611 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k87p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":518 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k78p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_residuals); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;} - __pyx_3 = PyNumber_Remainder(__pyx_k88p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_residuals); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k79p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; goto __pyx_L1;} - __pyx_4 = PyNumber_Remainder(__pyx_k89p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k80p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; goto __pyx_L1;} - __pyx_5 = PyNumber_Remainder(__pyx_k90p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k81p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; goto __pyx_L1;} - __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_two_delta); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; goto __pyx_L1;} - __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_two_delta); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;} + __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1); PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6); __pyx_1 = 0; __pyx_6 = 0; - __pyx_1 = PyNumber_Remainder(__pyx_k91p, __pyx_7); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; goto __pyx_L1;} + __pyx_1 = PyNumber_Remainder(__pyx_k82p, __pyx_7); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; goto __pyx_L1;} Py_DECREF(__pyx_7); __pyx_7 = 0; - __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_divisor); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; goto __pyx_L1;} - __pyx_7 = PyNumber_Remainder(__pyx_k92p, __pyx_6); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_divisor); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; goto __pyx_L1;} + __pyx_7 = PyNumber_Remainder(__pyx_k83p, __pyx_6); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; - __pyx_6 = PyList_New(7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; goto __pyx_L1;} - Py_INCREF(__pyx_k86p); - PyList_SET_ITEM(__pyx_6, 0, __pyx_k86p); + __pyx_6 = PyList_New(7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; goto __pyx_L1;} + Py_INCREF(__pyx_k77p); + PyList_SET_ITEM(__pyx_6, 0, __pyx_k77p); PyList_SET_ITEM(__pyx_6, 1, __pyx_2); PyList_SET_ITEM(__pyx_6, 2, __pyx_3); PyList_SET_ITEM(__pyx_6, 3, __pyx_4); @@ -2518,12 +2637,12 @@ __pyx_v_strg = __pyx_6; __pyx_6 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":618 */ - __pyx_2 = PyObject_GetAttr(__pyx_k93p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":525 */ + __pyx_2 = PyObject_GetAttr(__pyx_k84p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;} Py_INCREF(__pyx_v_strg); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -2548,31 +2667,41 @@ return __pyx_r; } +static void __pyx_f_6_loess_14conf_intervals___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_f_6_loess_14conf_intervals___dealloc__(PyObject *__pyx_v_self) { + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":547 */ + pw_free_mem((&((struct __pyx_obj_6_loess_conf_intervals *)__pyx_v_self)->_base)); + + Py_DECREF(__pyx_v_self); +} + static PyObject *__pyx_f_6_loess_14conf_intervals_setup(struct __pyx_obj_6_loess_conf_intervals *__pyx_v_self,conf_inv __pyx_v_base,long __pyx_v_nest) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":633 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":550 */ __pyx_v_self->_base = __pyx_v_base; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":634 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":551 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_self->fit)); __pyx_v_self->fit = ((PyArrayObject *)__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":635 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.upper); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":552 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.upper); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_self->upper)); __pyx_v_self->upper = ((PyArrayObject *)__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":636 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":553 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_self->lower)); __pyx_v_self->lower = ((PyArrayObject *)__pyx_1); __pyx_1 = 0; @@ -2591,9 +2720,9 @@ static PyObject *__pyx_n_r_; static PyObject *__pyx_n_T; -static PyObject *__pyx_k94p; +static PyObject *__pyx_k85p; -static char (__pyx_k94[]) = "Confidence intervals....\nLower b./ fit / upper b.\n%s"; +static char (__pyx_k85[]) = "Confidence intervals....\nLower b./ fit / upper b.\n%s"; static PyObject *__pyx_f_6_loess_14conf_intervals___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6_loess_14conf_intervals___str__(PyObject *__pyx_v_self) { @@ -2605,29 +2734,29 @@ Py_INCREF(__pyx_v_self); __pyx_v_tmp_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":640 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_r_); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":557 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_r_); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyList_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + __pyx_1 = PyList_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;} Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_conf_intervals *)__pyx_v_self)->lower)); PyList_SET_ITEM(__pyx_1, 0, ((PyObject *)((struct __pyx_obj_6_loess_conf_intervals *)__pyx_v_self)->lower)); Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_conf_intervals *)__pyx_v_self)->fit)); PyList_SET_ITEM(__pyx_1, 1, ((PyObject *)((struct __pyx_obj_6_loess_conf_intervals *)__pyx_v_self)->fit)); Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_conf_intervals *)__pyx_v_self)->upper)); PyList_SET_ITEM(__pyx_1, 2, ((PyObject *)((struct __pyx_obj_6_loess_conf_intervals *)__pyx_v_self)->upper)); - __pyx_3 = PyObject_GetItem(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + __pyx_3 = PyObject_GetItem(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_T); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_T); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_tmp_ndr)); __pyx_v_tmp_ndr = ((PyArrayObject *)__pyx_2); __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":641 */ - __pyx_1 = PyNumber_Remainder(__pyx_k94p, ((PyObject *)__pyx_v_tmp_ndr)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":558 */ + __pyx_1 = PyNumber_Remainder(__pyx_k85p, ((PyObject *)__pyx_v_tmp_ndr)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2650,7 +2779,7 @@ static void __pyx_f_6_loess_15loess_predicted___dealloc__(PyObject *__pyx_v_self) { Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":655 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":587 */ pred_free_mem((&((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base)); Py_DECREF(__pyx_v_self); @@ -2660,10 +2789,10 @@ PyObject *__pyx_r; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":658 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":590 */ __pyx_v_self->_base = __pyx_v_base; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":659 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":591 */ __pyx_v_self->nest = __pyx_v_nest; __pyx_r = Py_None; Py_INCREF(Py_None); @@ -2677,8 +2806,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":693 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base.fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":595 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base.fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2700,8 +2829,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":702 */ - __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base.se_fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":599 */ + __pyx_1 = __pyx_f_6_loess_floatarray_from_data(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base.se_fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2723,8 +2852,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":710 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base.residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":603 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base.residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2746,8 +2875,8 @@ PyObject *__pyx_1 = 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":719 */ - __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base.df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":607 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base.df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; goto __pyx_L1;} __pyx_r = __pyx_1; __pyx_1 = 0; goto __pyx_L0; @@ -2763,12 +2892,12 @@ return __pyx_r; } -static PyObject *__pyx_k95p; +static PyObject *__pyx_k86p; -static char (__pyx_k95[]) = "The coverage precentage should be between 0 and 1!"; +static char (__pyx_k86[]) = "The coverage precentage should be between 0 and 1!"; static PyObject *__pyx_f_6_loess_15loess_predicted_confidence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6_loess_15loess_predicted_confidence[] = "Returns the pointwise confidence intervals for each predicted values,\nat the given confidence interval coverage.\n \n:Parameters:\n coverage : float\n Confidence level of the confidence intervals limits, as a fraction.\n "; +static char __pyx_doc_6_loess_15loess_predicted_confidence[] = "Returns the pointwise confidence intervals for each predicted values,\nat the given confidence interval coverage.\n \n:Parameters:\n coverage : float\n Confidence level of the confidence intervals limits, as a fraction.\n \n:Returns:\n A new conf_intervals object, consisting of:\n fit : ndarray\n Predicted values.\n lower : ndarray\n Lower bounds of the confidence intervals.\n upper : ndarray\n Upper bounds of the confidence intervals.\n "; static PyObject *__pyx_f_6_loess_15loess_predicted_confidence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_coverage = 0; conf_inv __pyx_v__confintv; @@ -2779,21 +2908,21 @@ PyObject *__pyx_4 = 0; double __pyx_5; static char *__pyx_argnames[] = {"coverage",0}; - __pyx_v_coverage = __pyx_k32; + __pyx_v_coverage = __pyx_k9; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_coverage)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_coverage); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":730 */ - __pyx_1 = PyFloat_FromDouble(0.5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":627 */ + __pyx_1 = PyFloat_FromDouble(0.5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;} __pyx_2 = __pyx_2 < 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":731 */ - __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;} - __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_v_coverage); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":628 */ + __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; goto __pyx_L1;} + __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_v_coverage); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_v_coverage); __pyx_v_coverage = __pyx_3; @@ -2802,44 +2931,44 @@ } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":732 */ - __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":629 */ + __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; goto __pyx_L1;} __pyx_2 = __pyx_2 > 0; Py_DECREF(__pyx_1); __pyx_1 = 0; if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":733 */ - __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} - Py_INCREF(__pyx_k95p); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k95p); - __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":630 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; goto __pyx_L1;} + Py_INCREF(__pyx_k86p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k86p); + __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; goto __pyx_L1;} goto __pyx_L3; } __pyx_L3:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":734 */ - __pyx_5 = PyFloat_AsDouble(__pyx_v_coverage); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":631 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_coverage); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; goto __pyx_L1;} pointwise((&((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->_base),((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->nest,__pyx_5,(&__pyx_v__confintv)); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":735 */ - __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_conf_intervals), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6_loess_conf_intervals)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":632 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_conf_intervals), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6_loess_conf_intervals)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals)); ((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals = ((struct __pyx_obj_6_loess_conf_intervals *)__pyx_3); __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":736 */ - __pyx_1 = ((struct __pyx_vtabstruct_6_loess_conf_intervals *)((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals->__pyx_vtab)->setup(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals,__pyx_v__confintv,((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":633 */ + __pyx_1 = ((struct __pyx_vtabstruct_6_loess_conf_intervals *)((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals->__pyx_vtab)->setup(((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals,__pyx_v__confintv,((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":737 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":634 */ Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals)); __pyx_r = ((PyObject *)((struct __pyx_obj_6_loess_loess_predicted *)__pyx_v_self)->confidence_intervals); goto __pyx_L0; @@ -2863,19 +2992,19 @@ static PyObject *__pyx_n_residual_scale; static PyObject *__pyx_n_df; -static PyObject *__pyx_k96p; -static PyObject *__pyx_k97p; -static PyObject *__pyx_k98p; -static PyObject *__pyx_k99p; -static PyObject *__pyx_k100p; -static PyObject *__pyx_k101p; +static PyObject *__pyx_k87p; +static PyObject *__pyx_k88p; +static PyObject *__pyx_k89p; +static PyObject *__pyx_k90p; +static PyObject *__pyx_k91p; +static PyObject *__pyx_k92p; -static char (__pyx_k96[]) = "Outputs................"; -static char (__pyx_k97[]) = "Predicted values : %s\n"; -static char (__pyx_k98[]) = "Predicted std error : %s\n"; -static char (__pyx_k99[]) = "Residual scale : %s"; -static char (__pyx_k100[]) = "Degrees of freedom : %s"; -static char (__pyx_k101[]) = "\n"; +static char (__pyx_k87[]) = "Outputs................"; +static char (__pyx_k88[]) = "Predicted values : %s\n"; +static char (__pyx_k89[]) = "Predicted std error : %s\n"; +static char (__pyx_k90[]) = "Residual scale : %s"; +static char (__pyx_k91[]) = "Degrees of freedom : %s"; +static char (__pyx_k92[]) = "\n"; static PyObject *__pyx_f_6_loess_15loess_predicted___str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_f_6_loess_15loess_predicted___str__(PyObject *__pyx_v_self) { @@ -2889,22 +3018,22 @@ Py_INCREF(__pyx_v_self); __pyx_v_strg = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":740 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k97p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":637 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k88p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_stderr); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;} - __pyx_3 = PyNumber_Remainder(__pyx_k98p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_stderr); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k89p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; goto __pyx_L1;} - __pyx_4 = PyNumber_Remainder(__pyx_k99p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k90p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; goto __pyx_L1;} - __pyx_5 = PyNumber_Remainder(__pyx_k100p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k91p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyList_New(5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; goto __pyx_L1;} - Py_INCREF(__pyx_k96p); - PyList_SET_ITEM(__pyx_1, 0, __pyx_k96p); + __pyx_1 = PyList_New(5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; goto __pyx_L1;} + Py_INCREF(__pyx_k87p); + PyList_SET_ITEM(__pyx_1, 0, __pyx_k87p); PyList_SET_ITEM(__pyx_1, 1, __pyx_2); PyList_SET_ITEM(__pyx_1, 2, __pyx_3); PyList_SET_ITEM(__pyx_1, 3, __pyx_4); @@ -2917,12 +3046,12 @@ __pyx_v_strg = __pyx_1; __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":747 */ - __pyx_2 = PyObject_GetAttr(__pyx_k101p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":644 */ + __pyx_2 = PyObject_GetAttr(__pyx_k92p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;} Py_INCREF(__pyx_v_strg); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_r = __pyx_4; @@ -2945,24 +3074,16 @@ return __pyx_r; } -static PyObject *__pyx_n_order; -static PyObject *__pyx_n_C; -static PyObject *__pyx_n_len; static PyObject *__pyx_n_iteritems; static PyObject *__pyx_n_update; -static PyObject *__pyx_k110p; -static char (__pyx_k110[]) = "Incompatible size between the response array (%i) and the predictor array (%i)"; - static int __pyx_f_6_loess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_f_6_loess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_x = 0; PyObject *__pyx_v_y = 0; PyObject *__pyx_v_weights = 0; PyObject *__pyx_v_options = 0; - PyArrayObject *__pyx_v_x_ndr; - PyArrayObject *__pyx_v_y_ndr; double (*__pyx_v_x_dat); double (*__pyx_v_y_dat); PyObject *__pyx_v_n; @@ -2974,13 +3095,12 @@ int __pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - long __pyx_5; + long __pyx_3; + long __pyx_4; + PyObject *__pyx_5 = 0; int __pyx_6; - long __pyx_7; static char *__pyx_argnames[] = {"x","y","weights",0}; - __pyx_v_weights = __pyx_k33; + __pyx_v_weights = __pyx_k10; if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 3, 0, &__pyx_v_options) < 0) return -1; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_weights)) { Py_XDECREF(__pyx_args); @@ -2992,8 +3112,6 @@ Py_INCREF(__pyx_v_x); Py_INCREF(__pyx_v_y); Py_INCREF(__pyx_v_weights); - __pyx_v_x_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); - __pyx_v_y_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_n = Py_None; Py_INCREF(Py_None); __pyx_v_p = Py_None; Py_INCREF(Py_None); __pyx_v_modelopt = Py_None; Py_INCREF(Py_None); @@ -3001,298 +3119,186 @@ __pyx_v_k = Py_None; Py_INCREF(Py_None); __pyx_v_v = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":769 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":764 */ + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;} Py_INCREF(__pyx_v_x); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x); - __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_x); + Py_INCREF(__pyx_v_y); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_y); + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_inputs), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_x_ndr)); - __pyx_v_x_ndr = ((PyArrayObject *)__pyx_4); - __pyx_4 = 0; + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6_loess_loess_inputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs)); + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs = ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_2); + __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":770 */ - __pyx_v_x_dat = ((double (*))__pyx_v_x_ndr->data); + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":765 */ + __pyx_v_x_dat = ((double (*))((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs->x_eff->data); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":771 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_x_ndr)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_x_ndr)); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":766 */ + __pyx_v_y_dat = ((double (*))((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs->y_eff->data); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":767 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; goto __pyx_L1;} Py_DECREF(__pyx_v_n); - __pyx_v_n = __pyx_3; - __pyx_3 = 0; + __pyx_v_n = __pyx_1; + __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":772 */ - __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_x_ndr), __pyx_n_size); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} - __pyx_1 = PyNumber_Divide(__pyx_4, __pyx_v_n); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":768 */ + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs->npar); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;} Py_DECREF(__pyx_v_p); - __pyx_v_p = __pyx_1; - __pyx_1 = 0; + __pyx_v_p = __pyx_2; + __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":773 */ - __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;} - ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->npar = __pyx_5; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":769 */ + __pyx_3 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + __pyx_4 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; goto __pyx_L1;} + loess_setup(__pyx_v_x_dat,__pyx_v_y_dat,__pyx_3,__pyx_4,(&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base)); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":774 */ - __pyx_5 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;} - ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->nobs = __pyx_5; - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":776 */ - __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_v_p, __pyx_2, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;} - __pyx_6 = __pyx_6 > 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__pyx_6) { - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":777 */ - __pyx_3 = PyNumber_Multiply(__pyx_v_n, __pyx_v_p); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); - __pyx_3 = 0; - if (PyObject_SetAttr(((PyObject *)__pyx_v_x_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - goto __pyx_L2; - } - __pyx_L2:; - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":779 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} - Py_INCREF(__pyx_v_y); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_y); - __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} - __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_y_ndr)); - __pyx_v_y_ndr = ((PyArrayObject *)__pyx_4); - __pyx_4 = 0; - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":780 */ - __pyx_v_y_dat = ((double (*))__pyx_v_y_ndr->data); - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":781 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_y_ndr), __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_v_n, &__pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; goto __pyx_L1;} - __pyx_6 = __pyx_6 != 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__pyx_6) { - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":782 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_y_ndr)); - PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_y_ndr)); - Py_INCREF(__pyx_v_n); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_n); - __pyx_4 = PyNumber_Remainder(__pyx_k110p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_4); - __pyx_4 = 0; - __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - __Pyx_Raise(__pyx_3, 0, 0); - Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} - goto __pyx_L3; - } - __pyx_L3:; - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":785 */ - __pyx_5 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;} - __pyx_7 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;} - loess_setup(__pyx_v_x_dat,__pyx_v_y_dat,__pyx_5,__pyx_7,(&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base)); - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":787 */ - __pyx_4 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_inputs), 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_6_loess_loess_inputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} - Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs)); - ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs = ((struct __pyx_obj_6_loess_loess_inputs *)__pyx_4); - __pyx_4 = 0; - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":788 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":771 */ ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs->_base = (&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.inputs); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":790 */ - __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_model), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6_loess_loess_model)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":773 */ + __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_model), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_6_loess_loess_model)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model)); - ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model = ((struct __pyx_obj_6_loess_loess_model *)__pyx_2); - __pyx_2 = 0; + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model = ((struct __pyx_obj_6_loess_loess_model *)__pyx_1); + __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":791 */ - __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;} - __pyx_1 = ((struct __pyx_vtabstruct_6_loess_loess_model *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model->__pyx_vtab)->setup(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model,(&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.model),__pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":774 */ + __pyx_3 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;} + __pyx_2 = ((struct __pyx_vtabstruct_6_loess_loess_model *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model->__pyx_vtab)->setup(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model,(&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.model),__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":795 */ - __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_control), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6_loess_loess_control)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":776 */ + __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_control), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_6_loess_loess_control)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->control)); - ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->control = ((struct __pyx_obj_6_loess_loess_control *)__pyx_3); - __pyx_3 = 0; + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->control = ((struct __pyx_obj_6_loess_loess_control *)__pyx_1); + __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":796 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":777 */ ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->control->_base = (&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.control); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":798 */ - __pyx_4 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_kd_tree), 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_6_loess_loess_kd_tree)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":779 */ + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_kd_tree), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6_loess_loess_kd_tree)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->kd_tree)); - ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->kd_tree = ((struct __pyx_obj_6_loess_loess_kd_tree *)__pyx_4); - __pyx_4 = 0; + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->kd_tree = ((struct __pyx_obj_6_loess_loess_kd_tree *)__pyx_2); + __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":799 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":780 */ ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->kd_tree->_base = (&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.kd_tree); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":801 */ - __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_outputs), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_6_loess_loess_outputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":782 */ + __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_outputs), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_6_loess_loess_outputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs)); - ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs = ((struct __pyx_obj_6_loess_loess_outputs *)__pyx_2); - __pyx_2 = 0; + ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs = ((struct __pyx_obj_6_loess_loess_outputs *)__pyx_1); + __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":802 */ - ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->_base = (&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.outputs); + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":783 */ + __pyx_4 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;} + __pyx_3 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;} + __pyx_2 = ((struct __pyx_vtabstruct_6_loess_loess_outputs *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->__pyx_vtab)->setup(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs,(&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.outputs),__pyx_4,__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":803 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;} - __pyx_6 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->activated = __pyx_6; - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":804 */ - __pyx_7 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; goto __pyx_L1;} - ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->nobs = __pyx_7; - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":805 */ - __pyx_5 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; goto __pyx_L1;} - ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->npar = __pyx_5; - - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":807 */ - __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":785 */ + __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;} Py_DECREF(__pyx_v_modelopt); - __pyx_v_modelopt = __pyx_3; - __pyx_3 = 0; + __pyx_v_modelopt = __pyx_1; + __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":808 */ - __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":786 */ + __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; goto __pyx_L1;} Py_DECREF(__pyx_v_controlopt); - __pyx_v_controlopt = __pyx_4; - __pyx_4 = 0; + __pyx_v_controlopt = __pyx_2; + __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":809 */ - __pyx_2 = PyObject_GetAttr(__pyx_v_options, __pyx_n_iteritems); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} - __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":787 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_options, __pyx_n_iteritems); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetIter(__pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_3 = PyObject_GetIter(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; for (;;) { - __pyx_4 = PyIter_Next(__pyx_3); - if (!__pyx_4) { - if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + __pyx_2 = PyIter_Next(__pyx_1); + if (!__pyx_2) { + if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} break; } - __pyx_2 = PyObject_GetIter(__pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_1 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + __pyx_5 = PyObject_GetIter(__pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_2 = __Pyx_UnpackItem(__pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} Py_DECREF(__pyx_v_k); - __pyx_v_k = __pyx_1; - __pyx_1 = 0; - __pyx_4 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + __pyx_v_k = __pyx_2; + __pyx_2 = 0; + __pyx_2 = __Pyx_UnpackItem(__pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} Py_DECREF(__pyx_v_v); - __pyx_v_v = __pyx_4; - __pyx_4 = 0; - if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_v_v = __pyx_2; + __pyx_2 = 0; + if (__Pyx_EndUnpack(__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":810 */ - __pyx_1 = PyTuple_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":788 */ + __pyx_2 = PyTuple_New(6); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; goto __pyx_L1;} Py_INCREF(__pyx_n_family); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_family); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_family); Py_INCREF(__pyx_n_span); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_span); + PyTuple_SET_ITEM(__pyx_2, 1, __pyx_n_span); Py_INCREF(__pyx_n_degree); - PyTuple_SET_ITEM(__pyx_1, 2, __pyx_n_degree); + PyTuple_SET_ITEM(__pyx_2, 2, __pyx_n_degree); Py_INCREF(__pyx_n_normalize); - PyTuple_SET_ITEM(__pyx_1, 3, __pyx_n_normalize); + PyTuple_SET_ITEM(__pyx_2, 3, __pyx_n_normalize); Py_INCREF(__pyx_n_parametric); - PyTuple_SET_ITEM(__pyx_1, 4, __pyx_n_parametric); + PyTuple_SET_ITEM(__pyx_2, 4, __pyx_n_parametric); Py_INCREF(__pyx_n_drop_square); - PyTuple_SET_ITEM(__pyx_1, 5, __pyx_n_drop_square); - __pyx_6 = PySequence_Contains(__pyx_1, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; + PyTuple_SET_ITEM(__pyx_2, 5, __pyx_n_drop_square); + __pyx_6 = PySequence_Contains(__pyx_2, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; if (__pyx_6) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":812 */ - if (PyObject_SetItem(__pyx_v_modelopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;} - goto __pyx_L6; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":790 */ + if (PyObject_SetItem(__pyx_v_modelopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; goto __pyx_L1;} + goto __pyx_L4; } - __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;} + __pyx_5 = PyTuple_New(5); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;} Py_INCREF(__pyx_n_surface); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_surface); + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_n_surface); Py_INCREF(__pyx_n_statistics); - PyTuple_SET_ITEM(__pyx_4, 1, __pyx_n_statistics); + PyTuple_SET_ITEM(__pyx_5, 1, __pyx_n_statistics); Py_INCREF(__pyx_n_trace_hat); - PyTuple_SET_ITEM(__pyx_4, 2, __pyx_n_trace_hat); + PyTuple_SET_ITEM(__pyx_5, 2, __pyx_n_trace_hat); Py_INCREF(__pyx_n_iterations); - PyTuple_SET_ITEM(__pyx_4, 3, __pyx_n_iterations); + PyTuple_SET_ITEM(__pyx_5, 3, __pyx_n_iterations); Py_INCREF(__pyx_n_cell); - PyTuple_SET_ITEM(__pyx_4, 4, __pyx_n_cell); - __pyx_6 = PySequence_Contains(__pyx_4, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; + PyTuple_SET_ITEM(__pyx_5, 4, __pyx_n_cell); + __pyx_6 = PySequence_Contains(__pyx_5, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_6) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":815 */ - if (PyObject_SetItem(__pyx_v_controlopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} - goto __pyx_L6; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":793 */ + if (PyObject_SetItem(__pyx_v_controlopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; goto __pyx_L1;} + goto __pyx_L4; } - __pyx_L6:; + __pyx_L4:; } - Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":816 */ - __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->control), __pyx_n_update); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} - __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} - __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_v_controlopt); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":794 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->control), __pyx_n_update); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; goto __pyx_L1;} + __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; goto __pyx_L1;} + __pyx_1 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_5, __pyx_v_controlopt); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":817 */ - __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model), __pyx_n_update); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} - __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} - __pyx_1 = PyEval_CallObjectWithKeywords(__pyx_3, __pyx_2, __pyx_v_modelopt); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":795 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model), __pyx_n_update); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; goto __pyx_L1;} + __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; goto __pyx_L1;} + __pyx_1 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_5, __pyx_v_modelopt); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; __pyx_r = 0; @@ -3300,14 +3306,11 @@ __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); __Pyx_AddTraceback("_loess.loess.__init__"); __pyx_r = -1; __pyx_L0:; Py_XDECREF(__pyx_v_options); - Py_DECREF(__pyx_v_x_ndr); - Py_DECREF(__pyx_v_y_ndr); Py_DECREF(__pyx_v_n); Py_DECREF(__pyx_v_p); Py_DECREF(__pyx_v_modelopt); @@ -3324,6 +3327,7 @@ } static PyObject *__pyx_f_6_loess_5loess_fit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6_loess_5loess_fit[] = "Computes the loess parameters on the current inputs and sets of parameters."; static PyObject *__pyx_f_6_loess_5loess_fit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_r; PyObject *__pyx_1 = 0; @@ -3334,36 +3338,36 @@ if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":820 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":799 */ loess_fit((&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base)); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":821 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;} - __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":800 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;} + __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->activated = __pyx_2; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":822 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":801 */ __pyx_2 = ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_status; if (__pyx_2) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":823 */ - __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} - __pyx_3 = PyString_FromString(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":802 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;} + __pyx_3 = PyString_FromString(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); __pyx_3 = 0; - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_3, 0, 0); Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":824 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":803 */ __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; @@ -3380,69 +3384,168 @@ return __pyx_r; } -static PyObject *__pyx_n_nobs; +static PyObject *__pyx_n_str; -static PyObject *__pyx_k122p; -static PyObject *__pyx_k123p; -static PyObject *__pyx_k125p; -static PyObject *__pyx_k126p; +static PyObject *__pyx_k104p; -static char (__pyx_k122[]) = "Number of Observations : %d"; -static char (__pyx_k123[]) = "Equivalent Number of Parameters: %.1f"; -static char (__pyx_k125[]) = "Residual Standard Error : %.4f"; -static char (__pyx_k126[]) = "Residual Scale Estimate : %.4f"; +static char (__pyx_k104[]) = "\n"; -static PyObject *__pyx_f_6_loess_5loess_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_6_loess_5loess_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_f_6_loess_5loess_input_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6_loess_5loess_input_summary[] = "Returns some generic information about the loess parameters.\n "; +static PyObject *__pyx_f_6_loess_5loess_input_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_toprint; PyObject *__pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; - int __pyx_3; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; Py_INCREF(__pyx_v_self); + __pyx_v_toprint = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":827 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs), __pyx_n_nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k122p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":808 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_str); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs)); + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs)); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;} + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_str); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model)); + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model)); + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_str); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->control)); + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->control)); + __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = PyList_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; goto __pyx_L1;} + PyList_SET_ITEM(__pyx_1, 0, __pyx_3); + PyList_SET_ITEM(__pyx_1, 1, __pyx_4); + PyList_SET_ITEM(__pyx_1, 2, __pyx_5); + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + Py_DECREF(__pyx_v_toprint); + __pyx_v_toprint = __pyx_1; + __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":828 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs), __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k123p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":809 */ + __pyx_2 = PyObject_GetAttr(__pyx_k104p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + Py_INCREF(__pyx_v_toprint); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_toprint); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("_loess.loess.input_summary"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_toprint); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k105p; +static PyObject *__pyx_k106p; +static PyObject *__pyx_k107p; +static PyObject *__pyx_k109p; +static PyObject *__pyx_k110p; + +static char (__pyx_k105[]) = "Number of Observations : %d"; +static char (__pyx_k106[]) = "Fit flag : %d"; +static char (__pyx_k107[]) = "Equivalent Number of Parameters: %.1f"; +static char (__pyx_k109[]) = "Residual Standard Error : %.4f"; +static char (__pyx_k110[]) = "Residual Scale Estimate : %.4f"; + +static PyObject *__pyx_f_6_loess_5loess_output_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_6_loess_5loess_output_summary[] = "Returns some generic information about the loess fit."; +static PyObject *__pyx_f_6_loess_5loess_output_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + int __pyx_4; + static char *__pyx_argnames[] = {0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":813 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k105p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;} - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":829 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model), __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_1, __pyx_n_gaussian, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; goto __pyx_L1;} - __pyx_3 = __pyx_3 == 0; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":814 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_bool); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->activated); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); + __pyx_2 = 0; + __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__pyx_3) { + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_1 = PyNumber_Remainder(__pyx_k106p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":830 */ - __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;} - __pyx_1 = PyNumber_Remainder(__pyx_k125p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":815 */ + __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs), __pyx_n_enp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k107p, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":816 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->model), __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_n_gaussian, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + __pyx_4 = __pyx_4 == 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":817 */ + __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k109p, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; goto __pyx_L1;} + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} goto __pyx_L2; } /*else*/ { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":832 */ - __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} - __pyx_1 = PyNumber_Remainder(__pyx_k126p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":819 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k110p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; - if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; goto __pyx_L1;} + if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;} } __pyx_L2:; @@ -3451,24 +3554,24 @@ __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("_loess.loess.summary"); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_loess.loess.output_summary"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } -static PyObject *__pyx_n_ravel; static PyObject *__pyx_n_divmod; -static PyObject *__pyx_k131p; -static PyObject *__pyx_k132p; +static PyObject *__pyx_k115p; +static PyObject *__pyx_k116p; -static char (__pyx_k131[]) = "Can't predict without input data !"; -static char (__pyx_k132[]) = "Incompatible data size: there should be as many rows as parameters"; +static char (__pyx_k115[]) = "Can't predict without input data !"; +static char (__pyx_k116[]) = "Incompatible data size: there should be as many rows as parameters"; static PyObject *__pyx_f_6_loess_5loess_predict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_6_loess_5loess_predict[] = "\n newdata: ndarray\n A (m,p) ndarray specifying the values of the predictors at which the \n evaluation is to be carried out.\n stderr: Boolean\n Logical flag for computing standard errors at newdata.\n "; +static char __pyx_doc_6_loess_5loess_predict[] = "Computes loess estimates at the given new data points newdata. Returns\na loess_predicted object, whose attributes are described below.\n \n:Parameters:\n newdata : ndarray\n The (m,p) array of independent variables where the surface must be estimated,\n with m the number of new data points, and p the number of independent\n variables.\n stderror : boolean\n Whether the standard error should be computed\n \n:Returns:\n A new loess_predicted object, consisting of:\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n residual_scale : float\n Estimate of the scale of the residuals\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n nest : integer\n Number of new observations.\n "; static PyObject *__pyx_f_6_loess_5loess_predict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_newdata = 0; PyObject *__pyx_v_stderror = 0; @@ -3484,7 +3587,7 @@ PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"newdata","stderror",0}; - __pyx_v_stderror = __pyx_k34; + __pyx_v_stderror = __pyx_k11; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_newdata, &__pyx_v_stderror)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_newdata); @@ -3492,35 +3595,35 @@ __pyx_v_p_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); __pyx_v_notOK = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":847 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":853 */ __pyx_1 = (((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->activated == 0); if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":848 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":854 */ loess_fit((&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base)); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":849 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;} - __pyx_1 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":855 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;} + __pyx_1 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->outputs->activated = __pyx_1; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":850 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":856 */ __pyx_1 = ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_status; if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":851 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} - __pyx_3 = PyString_FromString(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":857 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} + __pyx_3 = PyString_FromString(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); __pyx_3 = 0; - __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_3, 0, 0); Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} goto __pyx_L3; } __pyx_L3:; @@ -3528,147 +3631,147 @@ } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":853 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":859 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} Py_INCREF(__pyx_v_newdata); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_newdata); - __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} - __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} - if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} - __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_ravel); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_ravel); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} Py_DECREF(((PyObject *)__pyx_v_p_ndr)); __pyx_v_p_ndr = ((PyArrayObject *)__pyx_4); __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":854 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":860 */ __pyx_v_p_dat = ((double (*))__pyx_v_p_ndr->data); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":856 */ - __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; goto __pyx_L1;} - __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_3, __pyx_5, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":862 */ + __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;} + __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_3, __pyx_5, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;} __pyx_1 = __pyx_1 == 0; Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":857 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} - Py_INCREF(__pyx_k131p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k131p); - __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":863 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; goto __pyx_L1;} + Py_INCREF(__pyx_k115p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k115p); + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_3, 0, 0); Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; goto __pyx_L1;} goto __pyx_L4; } __pyx_L4:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":858 */ - __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_divmod); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":864 */ + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_divmod); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; goto __pyx_L1;} Py_INCREF(((PyObject *)__pyx_v_p_ndr)); PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_p_ndr)); - __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->npar); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} - __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->inputs->npar); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2); __pyx_3 = 0; __pyx_2 = 0; - __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_2 = PyObject_GetIter(__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_2 = PyObject_GetIter(__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} - __pyx_1 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_5 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; goto __pyx_L1;} + __pyx_1 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; goto __pyx_L1;} Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_v_m = __pyx_1; - __pyx_4 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + __pyx_4 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; goto __pyx_L1;} Py_DECREF(__pyx_v_notOK); __pyx_v_notOK = __pyx_4; __pyx_4 = 0; - if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; goto __pyx_L1;} + if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":859 */ - __pyx_1 = PyObject_IsTrue(__pyx_v_notOK); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":865 */ + __pyx_1 = PyObject_IsTrue(__pyx_v_notOK); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":860 */ - __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} - __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} - Py_INCREF(__pyx_k132p); - PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k132p); - __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":866 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; goto __pyx_L1;} + Py_INCREF(__pyx_k116p); + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k116p); + __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; goto __pyx_L1;} goto __pyx_L5; } __pyx_L5:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":863 */ - __pyx_1 = PyInt_AsLong(__pyx_v_stderror); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":869 */ + __pyx_1 = PyInt_AsLong(__pyx_v_stderror); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; goto __pyx_L1;} predict(__pyx_v_p_dat,__pyx_v_m,(&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base),(&__pyx_v__prediction),__pyx_1); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":864 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":870 */ __pyx_1 = ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_status; if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":865 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} - __pyx_3 = PyString_FromString(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} - __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":871 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; goto __pyx_L1;} + __pyx_3 = PyString_FromString(((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3); __pyx_3 = 0; - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; goto __pyx_L1;} goto __pyx_L6; } __pyx_L6:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":866 */ - __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_predicted), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6_loess_loess_predicted)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":872 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_6_loess_loess_predicted), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_6_loess_loess_predicted)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->predicted)); ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->predicted = ((struct __pyx_obj_6_loess_loess_predicted *)__pyx_3); __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":867 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":873 */ ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->predicted->_base = __pyx_v__prediction; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":868 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":874 */ ((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->predicted->nest = __pyx_v_m; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":870 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":876 */ Py_INCREF(((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->predicted)); __pyx_r = ((PyObject *)((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->predicted); goto __pyx_L0; @@ -3695,7 +3798,7 @@ static void __pyx_f_6_loess_5loess___dealloc__(PyObject *__pyx_v_self) { Py_INCREF(__pyx_v_self); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":873 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":879 */ loess_free_mem((&((struct __pyx_obj_6_loess_loess *)__pyx_v_self)->_base)); Py_DECREF(__pyx_v_self); @@ -3706,9 +3809,9 @@ static PyObject *__pyx_n_outputs; static PyObject *__pyx_n_abs; -static PyObject *__pyx_k133p; +static PyObject *__pyx_k117p; -static char (__pyx_k133[]) = "Arguments should be valid loess objects!got '%s' instead"; +static char (__pyx_k117[]) = "Arguments should be valid loess objects!got '%s' instead"; static int __pyx_f_6_loess_5anova___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_f_6_loess_5anova___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { @@ -3745,208 +3848,208 @@ __pyx_v_out_two = Py_None; Py_INCREF(Py_None); __pyx_v_F_value = Py_None; Py_INCREF(Py_None); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":887 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":893 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} Py_INCREF(__pyx_v_loess_one); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_loess_one); Py_INCREF(((PyObject*)__pyx_ptype_6_loess_loess)); PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_6_loess_loess)); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_1 = (!__pyx_5); if (!__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} Py_INCREF(__pyx_v_loess_two); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_loess_two); Py_INCREF(((PyObject*)__pyx_ptype_6_loess_loess)); PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_6_loess_loess)); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; goto __pyx_L1;} + __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_1 = (!__pyx_5); } if (__pyx_1) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":888 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} - __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":894 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} Py_INCREF(__pyx_v_loess_one); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_loess_one); - __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;} + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_3 = PyNumber_Remainder(__pyx_k133p, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k117p, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); __pyx_3 = 0; - __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_6, 0, 0); Py_DECREF(__pyx_6); __pyx_6 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":891 */ - __pyx_3 = PyObject_GetAttr(__pyx_v_loess_one, __pyx_n_outputs); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":897 */ + __pyx_3 = PyObject_GetAttr(__pyx_v_loess_one, __pyx_n_outputs); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; goto __pyx_L1;} Py_DECREF(__pyx_v_out_one); __pyx_v_out_one = __pyx_3; __pyx_3 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":892 */ - __pyx_2 = PyObject_GetAttr(__pyx_v_loess_two, __pyx_n_outputs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":898 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_loess_two, __pyx_n_outputs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; goto __pyx_L1;} Py_DECREF(__pyx_v_out_two); __pyx_v_out_two = __pyx_2; __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":894 */ - __pyx_4 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_one_delta); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;} - __pyx_7 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":900 */ + __pyx_4 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_one_delta); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_v_one_d1 = __pyx_7; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":895 */ - __pyx_6 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_two_delta); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} - __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":901 */ + __pyx_6 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_two_delta); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; __pyx_v_one_d2 = __pyx_7; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":896 */ - __pyx_3 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_s); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; goto __pyx_L1;} - __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":902 */ + __pyx_3 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_s); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_v_one_s = __pyx_7; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":898 */ - __pyx_2 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_one_delta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; goto __pyx_L1;} - __pyx_7 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":904 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_one_delta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_v_two_d1 = __pyx_7; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":899 */ - __pyx_4 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_two_delta); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; goto __pyx_L1;} - __pyx_7 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":905 */ + __pyx_4 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_two_delta); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_v_two_d2 = __pyx_7; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":900 */ - __pyx_6 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_s); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;} - __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":906 */ + __pyx_6 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_s); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; __pyx_v_two_s = __pyx_7; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":902 */ - __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} - __pyx_2 = PyFloat_FromDouble((((__pyx_v_one_s * __pyx_v_one_s) * __pyx_v_one_d1) - ((__pyx_v_two_s * __pyx_v_two_s) * __pyx_v_two_d1))); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":908 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;} + __pyx_2 = PyFloat_FromDouble((((__pyx_v_one_s * __pyx_v_one_s) * __pyx_v_one_d1) - ((__pyx_v_two_s * __pyx_v_two_s) * __pyx_v_two_d1))); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2); __pyx_2 = 0; - __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; __pyx_v_rssdiff = __pyx_7; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":903 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} - __pyx_3 = PyFloat_FromDouble((__pyx_v_one_d1 - __pyx_v_two_d1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":909 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;} + __pyx_3 = PyFloat_FromDouble((__pyx_v_one_d1 - __pyx_v_two_d1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); __pyx_3 = 0; - __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} + __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; __pyx_v_d1diff = __pyx_7; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":904 */ - __pyx_3 = PyFloat_FromDouble((__pyx_v_d1diff * __pyx_v_d1diff)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} - __pyx_4 = PyFloat_FromDouble((__pyx_v_one_d2 - __pyx_v_two_d2)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} - __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":910 */ + __pyx_3 = PyFloat_FromDouble((__pyx_v_d1diff * __pyx_v_d1diff)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;} + __pyx_4 = PyFloat_FromDouble((__pyx_v_one_d2 - __pyx_v_two_d2)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;} + __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_6, 0, __pyx_4); __pyx_4 = 0; - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_6); __pyx_6 = 0; - __pyx_2 = PyNumber_Divide(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + __pyx_2 = PyNumber_Divide(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_7 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->dfn = __pyx_7; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":905 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":911 */ __pyx_v_df1 = ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->dfn; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":907 */ - __pyx_6 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_enp); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;} - __pyx_3 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_enp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;} - if (PyObject_Cmp(__pyx_6, __pyx_3, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":913 */ + __pyx_6 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_enp); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_enp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_6, __pyx_3, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; goto __pyx_L1;} __pyx_5 = __pyx_5 > 0; Py_DECREF(__pyx_6); __pyx_6 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; if (__pyx_5) { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":908 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":914 */ ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->dfd = ((__pyx_v_one_d1 * __pyx_v_one_d1) / __pyx_v_one_d2); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":909 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":915 */ __pyx_v_tmp = __pyx_v_one_s; goto __pyx_L3; } /*else*/ { - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":911 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":917 */ ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->dfd = ((__pyx_v_two_d1 * __pyx_v_two_d1) / __pyx_v_two_d2); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":912 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":918 */ __pyx_v_tmp = __pyx_v_two_s; } __pyx_L3:; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":913 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":919 */ __pyx_v_df2 = ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->dfd; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":914 */ - __pyx_4 = PyFloat_FromDouble(((__pyx_v_rssdiff / __pyx_v_d1diff) / (__pyx_v_tmp * __pyx_v_tmp))); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":920 */ + __pyx_4 = PyFloat_FromDouble(((__pyx_v_rssdiff / __pyx_v_d1diff) / (__pyx_v_tmp * __pyx_v_tmp))); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;} Py_DECREF(__pyx_v_F_value); __pyx_v_F_value = __pyx_4; __pyx_4 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":916 */ - __pyx_2 = PyFloat_FromDouble(__pyx_v_df1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} - __pyx_6 = PyNumber_Multiply(__pyx_v_F_value, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":922 */ + __pyx_2 = PyFloat_FromDouble(__pyx_v_df1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} + __pyx_6 = PyNumber_Multiply(__pyx_v_F_value, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_3 = PyFloat_FromDouble(__pyx_v_df2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} - __pyx_4 = PyFloat_FromDouble(__pyx_v_df1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} - __pyx_2 = PyNumber_Multiply(__pyx_v_F_value, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + __pyx_3 = PyFloat_FromDouble(__pyx_v_df2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} + __pyx_4 = PyFloat_FromDouble(__pyx_v_df1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} + __pyx_2 = PyNumber_Multiply(__pyx_v_F_value, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_4 = PyNumber_Add(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + __pyx_4 = PyNumber_Add(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_3 = PyNumber_Divide(__pyx_6, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + __pyx_3 = PyNumber_Divide(__pyx_6, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} Py_DECREF(__pyx_6); __pyx_6 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->Pr_F = (1. - ibeta(__pyx_7,(__pyx_v_df1 / 2),(__pyx_v_df2 / 2))); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":917 */ - __pyx_7 = PyFloat_AsDouble(__pyx_v_F_value); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;} + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":923 */ + __pyx_7 = PyFloat_AsDouble(__pyx_v_F_value); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;} ((struct __pyx_obj_6_loess_anova *)__pyx_v_self)->F_value = __pyx_7; __pyx_r = 0; @@ -3998,9 +4101,9 @@ {&__pyx_n_family, "family"}, {&__pyx_n_fitted_residuals, "fitted_residuals"}, {&__pyx_n_fitted_values, "fitted_values"}, + {&__pyx_n_float_, "float_"}, {&__pyx_n_gaussian, "gaussian"}, {&__pyx_n_get, "get"}, - {&__pyx_n_id, "id"}, {&__pyx_n_interpolate, "interpolate"}, {&__pyx_n_isinstance, "isinstance"}, {&__pyx_n_iterations, "iterations"}, @@ -4011,10 +4114,10 @@ {&__pyx_n_min, "min"}, {&__pyx_n_narray, "narray"}, {&__pyx_n_ndim, "ndim"}, - {&__pyx_n_nobs, "nobs"}, {&__pyx_n_normalize, "normalize"}, {&__pyx_n_numpy, "numpy"}, {&__pyx_n_one_delta, "one_delta"}, + {&__pyx_n_ones, "ones"}, {&__pyx_n_order, "order"}, {&__pyx_n_outputs, "outputs"}, {&__pyx_n_parametric, "parametric"}, @@ -4028,6 +4131,7 @@ {&__pyx_n_span, "span"}, {&__pyx_n_statistics, "statistics"}, {&__pyx_n_stderr, "stderr"}, + {&__pyx_n_str, "str"}, {&__pyx_n_subok, "subok"}, {&__pyx_n_surface, "surface"}, {&__pyx_n_symmetric, "symmetric"}, @@ -4040,23 +4144,33 @@ }; static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_k35p, __pyx_k35, sizeof(__pyx_k35)}, + {&__pyx_k22p, __pyx_k22, sizeof(__pyx_k22)}, + {&__pyx_k26p, __pyx_k26, sizeof(__pyx_k26)}, + {&__pyx_k29p, __pyx_k29, sizeof(__pyx_k29)}, + {&__pyx_k30p, __pyx_k30, sizeof(__pyx_k30)}, + {&__pyx_k33p, __pyx_k33, sizeof(__pyx_k33)}, + {&__pyx_k36p, __pyx_k36, sizeof(__pyx_k36)}, + {&__pyx_k37p, __pyx_k37, sizeof(__pyx_k37)}, {&__pyx_k38p, __pyx_k38, sizeof(__pyx_k38)}, - {&__pyx_k39p, __pyx_k39, sizeof(__pyx_k39)}, - {&__pyx_k42p, __pyx_k42, sizeof(__pyx_k42)}, + {&__pyx_k44p, __pyx_k44, sizeof(__pyx_k44)}, {&__pyx_k45p, __pyx_k45, sizeof(__pyx_k45)}, {&__pyx_k46p, __pyx_k46, sizeof(__pyx_k46)}, {&__pyx_k47p, __pyx_k47, sizeof(__pyx_k47)}, - {&__pyx_k53p, __pyx_k53, sizeof(__pyx_k53)}, - {&__pyx_k54p, __pyx_k54, sizeof(__pyx_k54)}, + {&__pyx_k48p, __pyx_k48, sizeof(__pyx_k48)}, + {&__pyx_k49p, __pyx_k49, sizeof(__pyx_k49)}, + {&__pyx_k50p, __pyx_k50, sizeof(__pyx_k50)}, + {&__pyx_k51p, __pyx_k51, sizeof(__pyx_k51)}, + {&__pyx_k52p, __pyx_k52, sizeof(__pyx_k52)}, {&__pyx_k55p, __pyx_k55, sizeof(__pyx_k55)}, - {&__pyx_k56p, __pyx_k56, sizeof(__pyx_k56)}, - {&__pyx_k57p, __pyx_k57, sizeof(__pyx_k57)}, - {&__pyx_k58p, __pyx_k58, sizeof(__pyx_k58)}, - {&__pyx_k59p, __pyx_k59, sizeof(__pyx_k59)}, - {&__pyx_k60p, __pyx_k60, sizeof(__pyx_k60)}, - {&__pyx_k61p, __pyx_k61, sizeof(__pyx_k61)}, - {&__pyx_k64p, __pyx_k64, sizeof(__pyx_k64)}, + {&__pyx_k68p, __pyx_k68, sizeof(__pyx_k68)}, + {&__pyx_k69p, __pyx_k69, sizeof(__pyx_k69)}, + {&__pyx_k70p, __pyx_k70, sizeof(__pyx_k70)}, + {&__pyx_k71p, __pyx_k71, sizeof(__pyx_k71)}, + {&__pyx_k72p, __pyx_k72, sizeof(__pyx_k72)}, + {&__pyx_k73p, __pyx_k73, sizeof(__pyx_k73)}, + {&__pyx_k74p, __pyx_k74, sizeof(__pyx_k74)}, + {&__pyx_k75p, __pyx_k75, sizeof(__pyx_k75)}, + {&__pyx_k76p, __pyx_k76, sizeof(__pyx_k76)}, {&__pyx_k77p, __pyx_k77, sizeof(__pyx_k77)}, {&__pyx_k78p, __pyx_k78, sizeof(__pyx_k78)}, {&__pyx_k79p, __pyx_k79, sizeof(__pyx_k79)}, @@ -4073,51 +4187,82 @@ {&__pyx_k90p, __pyx_k90, sizeof(__pyx_k90)}, {&__pyx_k91p, __pyx_k91, sizeof(__pyx_k91)}, {&__pyx_k92p, __pyx_k92, sizeof(__pyx_k92)}, - {&__pyx_k93p, __pyx_k93, sizeof(__pyx_k93)}, - {&__pyx_k94p, __pyx_k94, sizeof(__pyx_k94)}, - {&__pyx_k95p, __pyx_k95, sizeof(__pyx_k95)}, - {&__pyx_k96p, __pyx_k96, sizeof(__pyx_k96)}, - {&__pyx_k97p, __pyx_k97, sizeof(__pyx_k97)}, - {&__pyx_k98p, __pyx_k98, sizeof(__pyx_k98)}, - {&__pyx_k99p, __pyx_k99, sizeof(__pyx_k99)}, - {&__pyx_k100p, __pyx_k100, sizeof(__pyx_k100)}, - {&__pyx_k101p, __pyx_k101, sizeof(__pyx_k101)}, + {&__pyx_k104p, __pyx_k104, sizeof(__pyx_k104)}, + {&__pyx_k105p, __pyx_k105, sizeof(__pyx_k105)}, + {&__pyx_k106p, __pyx_k106, sizeof(__pyx_k106)}, + {&__pyx_k107p, __pyx_k107, sizeof(__pyx_k107)}, + {&__pyx_k109p, __pyx_k109, sizeof(__pyx_k109)}, {&__pyx_k110p, __pyx_k110, sizeof(__pyx_k110)}, - {&__pyx_k122p, __pyx_k122, sizeof(__pyx_k122)}, - {&__pyx_k123p, __pyx_k123, sizeof(__pyx_k123)}, - {&__pyx_k125p, __pyx_k125, sizeof(__pyx_k125)}, - {&__pyx_k126p, __pyx_k126, sizeof(__pyx_k126)}, - {&__pyx_k131p, __pyx_k131, sizeof(__pyx_k131)}, - {&__pyx_k132p, __pyx_k132, sizeof(__pyx_k132)}, - {&__pyx_k133p, __pyx_k133, sizeof(__pyx_k133)}, + {&__pyx_k115p, __pyx_k115, sizeof(__pyx_k115)}, + {&__pyx_k116p, __pyx_k116, sizeof(__pyx_k116)}, + {&__pyx_k117p, __pyx_k117, sizeof(__pyx_k117)}, {0, 0, 0} }; static PyObject *__pyx_tp_new_6_loess_loess_inputs(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_6_loess_loess_inputs *p = (struct __pyx_obj_6_loess_loess_inputs *)o; + p->w_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->x = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->y = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->masked = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->x_eff = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->y_eff = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); return o; } static void __pyx_tp_dealloc_6_loess_loess_inputs(PyObject *o) { + struct __pyx_obj_6_loess_loess_inputs *p = (struct __pyx_obj_6_loess_loess_inputs *)o; + Py_XDECREF(((PyObject *)p->w_ndr)); + Py_XDECREF(((PyObject *)p->x)); + Py_XDECREF(((PyObject *)p->y)); + Py_XDECREF(((PyObject *)p->masked)); + Py_XDECREF(((PyObject *)p->x_eff)); + Py_XDECREF(((PyObject *)p->y_eff)); (*o->ob_type->tp_free)(o); } static int __pyx_tp_traverse_6_loess_loess_inputs(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_6_loess_loess_inputs *p = (struct __pyx_obj_6_loess_loess_inputs *)o; + if (p->w_ndr) { + e = (*v)(((PyObject*)p->w_ndr), a); if (e) return e; + } + if (p->x) { + e = (*v)(((PyObject*)p->x), a); if (e) return e; + } + if (p->y) { + e = (*v)(((PyObject*)p->y), a); if (e) return e; + } + if (p->masked) { + e = (*v)(((PyObject*)p->masked), a); if (e) return e; + } + if (p->x_eff) { + e = (*v)(((PyObject*)p->x_eff), a); if (e) return e; + } + if (p->y_eff) { + e = (*v)(((PyObject*)p->y_eff), a); if (e) return e; + } return 0; } static int __pyx_tp_clear_6_loess_loess_inputs(PyObject *o) { + struct __pyx_obj_6_loess_loess_inputs *p = (struct __pyx_obj_6_loess_loess_inputs *)o; + Py_XDECREF(((PyObject *)p->w_ndr)); + p->w_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->x)); + p->x = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->y)); + p->y = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->masked)); + p->masked = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->x_eff)); + p->x_eff = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->y_eff)); + p->y_eff = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); return 0; } -static PyObject *__pyx_getprop_6_loess_12loess_inputs_x(PyObject *o, void *x) { - return __pyx_f_6_loess_12loess_inputs_1x___get__(o); -} - -static PyObject *__pyx_getprop_6_loess_12loess_inputs_y(PyObject *o, void *x) { - return __pyx_f_6_loess_12loess_inputs_1y___get__(o); -} - static PyObject *__pyx_getprop_6_loess_12loess_inputs_weights(PyObject *o, void *x) { return __pyx_f_6_loess_12loess_inputs_7weights___get__(o); } @@ -4132,24 +4277,23 @@ } } -static PyObject *__pyx_getprop_6_loess_12loess_inputs_nobs(PyObject *o, void *x) { - return __pyx_f_6_loess_12loess_inputs_4nobs___get__(o); -} - -static PyObject *__pyx_getprop_6_loess_12loess_inputs_npar(PyObject *o, void *x) { - return __pyx_f_6_loess_12loess_inputs_4npar___get__(o); -} - static struct PyMethodDef __pyx_methods_6_loess_loess_inputs[] = { {0, 0, 0, 0} }; +static struct PyMemberDef __pyx_members_6_loess_loess_inputs[] = { + {"x", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess_inputs, x), READONLY, 0}, + {"y", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess_inputs, y), READONLY, 0}, + {"masked", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess_inputs, masked), READONLY, 0}, + {"x_eff", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess_inputs, x_eff), READONLY, 0}, + {"y_eff", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess_inputs, y_eff), READONLY, 0}, + {"nobs", T_INT, offsetof(struct __pyx_obj_6_loess_loess_inputs, nobs), READONLY, 0}, + {"npar", T_INT, offsetof(struct __pyx_obj_6_loess_loess_inputs, npar), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + static struct PyGetSetDef __pyx_getsets_6_loess_loess_inputs[] = { - {"x", __pyx_getprop_6_loess_12loess_inputs_x, 0, 0, 0}, - {"y", __pyx_getprop_6_loess_12loess_inputs_y, 0, 0, 0}, {"weights", __pyx_getprop_6_loess_12loess_inputs_weights, __pyx_setprop_6_loess_12loess_inputs_weights, __pyx_k1, 0}, - {"nobs", __pyx_getprop_6_loess_12loess_inputs_nobs, 0, __pyx_k2, 0}, - {"npar", __pyx_getprop_6_loess_12loess_inputs_npar, 0, __pyx_k3, 0}, {0, 0, 0, 0, 0} }; @@ -4242,7 +4386,7 @@ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_loess_inputs, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ + "Loess inputs\n \n:IVariables:\n x : ndarray\n A (n,p) ndarray of independent variables, with n the number of observations\n and p the number of variables.\n y : ndarray\n A (n,) ndarray of observations\n nobs : integer\n Number of observations: nobs=n.\n npar : integer\n Number of independent variables: npar=p.\n weights : ndarray\n A (n,) ndarray of weights to be given to individual observations in the \n sum of squared residuals that forms the local fitting criterion. If not\n None, the weights should be non negative. If the different observations\n have non-equal variances, the weights should be inversely proportional \n to the variances.\n By default, an unweighted fit is carried out (all the weights are one).\n ", /*tp_doc*/ __pyx_tp_traverse_6_loess_loess_inputs, /*tp_traverse*/ __pyx_tp_clear_6_loess_loess_inputs, /*tp_clear*/ 0, /*tp_richcompare*/ @@ -4250,14 +4394,14 @@ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_6_loess_loess_inputs, /*tp_methods*/ - 0, /*tp_members*/ + __pyx_members_6_loess_loess_inputs, /*tp_members*/ __pyx_getsets_6_loess_loess_inputs, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - 0, /*tp_init*/ + __pyx_f_6_loess_12loess_inputs___init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_6_loess_loess_inputs, /*tp_new*/ 0, /*tp_free*/ @@ -4362,11 +4506,11 @@ }; static struct PyGetSetDef __pyx_getsets_6_loess_loess_control[] = { - {"surface", __pyx_getprop_6_loess_13loess_control_surface, __pyx_setprop_6_loess_13loess_control_surface, __pyx_k4, 0}, - {"statistics", __pyx_getprop_6_loess_13loess_control_statistics, __pyx_setprop_6_loess_13loess_control_statistics, __pyx_k5, 0}, - {"trace_hat", __pyx_getprop_6_loess_13loess_control_trace_hat, __pyx_setprop_6_loess_13loess_control_trace_hat, __pyx_k6, 0}, - {"iterations", __pyx_getprop_6_loess_13loess_control_iterations, __pyx_setprop_6_loess_13loess_control_iterations, __pyx_k7, 0}, - {"cell", __pyx_getprop_6_loess_13loess_control_cell, __pyx_setprop_6_loess_13loess_control_cell, __pyx_k8, 0}, + {"surface", __pyx_getprop_6_loess_13loess_control_surface, __pyx_setprop_6_loess_13loess_control_surface, __pyx_k2, 0}, + {"statistics", __pyx_getprop_6_loess_13loess_control_statistics, __pyx_setprop_6_loess_13loess_control_statistics, __pyx_k3, 0}, + {"trace_hat", __pyx_getprop_6_loess_13loess_control_trace_hat, __pyx_setprop_6_loess_13loess_control_trace_hat, __pyx_k4, 0}, + {"iterations", __pyx_getprop_6_loess_13loess_control_iterations, __pyx_setprop_6_loess_13loess_control_iterations, __pyx_k5, 0}, + {"cell", __pyx_getprop_6_loess_13loess_control_cell, __pyx_setprop_6_loess_13loess_control_cell, __pyx_k6, 0}, {0, 0, 0, 0, 0} }; @@ -4459,7 +4603,7 @@ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_loess_control, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ + "Loess control parameters.\n \n:IVariables:\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n \n ", /*tp_doc*/ __pyx_tp_traverse_6_loess_loess_control, /*tp_traverse*/ __pyx_tp_clear_6_loess_loess_control, /*tp_clear*/ 0, /*tp_richcompare*/ @@ -4733,12 +4877,12 @@ }; static struct PyGetSetDef __pyx_getsets_6_loess_loess_model[] = { - {"normalize", __pyx_getprop_6_loess_11loess_model_normalize, __pyx_setprop_6_loess_11loess_model_normalize, __pyx_k9, 0}, - {"span", __pyx_getprop_6_loess_11loess_model_span, __pyx_setprop_6_loess_11loess_model_span, __pyx_k10, 0}, - {"degree", __pyx_getprop_6_loess_11loess_model_degree, __pyx_setprop_6_loess_11loess_model_degree, __pyx_k11, 0}, - {"family", __pyx_getprop_6_loess_11loess_model_family, __pyx_setprop_6_loess_11loess_model_family, __pyx_k12, 0}, - {"parametric_flags", __pyx_getprop_6_loess_11loess_model_parametric_flags, __pyx_setprop_6_loess_11loess_model_parametric_flags, __pyx_k13, 0}, - {"drop_square_flags", __pyx_getprop_6_loess_11loess_model_drop_square_flags, __pyx_setprop_6_loess_11loess_model_drop_square_flags, __pyx_k14, 0}, + {"normalize", __pyx_getprop_6_loess_11loess_model_normalize, __pyx_setprop_6_loess_11loess_model_normalize, 0, 0}, + {"span", __pyx_getprop_6_loess_11loess_model_span, __pyx_setprop_6_loess_11loess_model_span, 0, 0}, + {"degree", __pyx_getprop_6_loess_11loess_model_degree, __pyx_setprop_6_loess_11loess_model_degree, 0, 0}, + {"family", __pyx_getprop_6_loess_11loess_model_family, __pyx_setprop_6_loess_11loess_model_family, 0, 0}, + {"parametric_flags", __pyx_getprop_6_loess_11loess_model_parametric_flags, __pyx_setprop_6_loess_11loess_model_parametric_flags, 0, 0}, + {"drop_square_flags", __pyx_getprop_6_loess_11loess_model_drop_square_flags, __pyx_setprop_6_loess_11loess_model_drop_square_flags, 0, 0}, {0, 0, 0, 0, 0} }; @@ -4831,7 +4975,7 @@ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_loess_model, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ + "loess_model contains parameters required for a loess fit.\n \n:IVariables:\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n span : float [0.75]\n Smoothing factor, as a fraction of the number of points to take into\n account. \n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n family : string [\"gaussian\"]\n Determines the assumed distribution of the errors. The values are \n \"gaussian\" or \"symmetric\". If \"gaussian\" is selected, the fit is \n performed with least-squares. If \"symmetric\" is selected, the fit\n is performed robustly by redescending M-estimators.\n parametric_flags : sequence [ [False]*p ]\n Indicates which independent variables should be conditionally-parametric\n (if there are two or more independent variables). The argument should be\n a sequence of booleans, with the same size as the number of independent \n variables, specified in the order of the predictor group ordered in x. \n Note: elements of the sequence cannot be modified individually: the whole\n sequence must be given.\n drop_square : sequence [ [False]* p]\n When there are two or more independent variables and when a 2nd order\n polynomial is used, \"drop_square_flags\" specifies those numeric predictors \n whose squares should be dropped from the set of fitting variables. \n The method of specification is the same as for parametric. \n Note: elements of the sequence cannot be modified individually: the whole\n sequence must be given.\n\n ", /*tp_doc*/ __pyx_tp_traverse_6_loess_loess_model, /*tp_traverse*/ __pyx_tp_clear_6_loess_loess_model, /*tp_clear*/ 0, /*tp_richcompare*/ @@ -4857,9 +5001,12 @@ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ }; +static struct __pyx_vtabstruct_6_loess_loess_outputs __pyx_vtable_6_loess_loess_outputs; static PyObject *__pyx_tp_new_6_loess_loess_outputs(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_6_loess_loess_outputs *p = (struct __pyx_obj_6_loess_loess_outputs *)o; + *(struct __pyx_vtabstruct_6_loess_loess_outputs **)&p->__pyx_vtab = __pyx_vtabptr_6_loess_loess_outputs; return o; } @@ -4929,17 +5076,17 @@ }; static struct PyGetSetDef __pyx_getsets_6_loess_loess_outputs[] = { - {"fitted_values", __pyx_getprop_6_loess_13loess_outputs_fitted_values, 0, __pyx_k15, 0}, - {"fitted_residuals", __pyx_getprop_6_loess_13loess_outputs_fitted_residuals, 0, __pyx_k16, 0}, - {"pseudovalues", __pyx_getprop_6_loess_13loess_outputs_pseudovalues, 0, __pyx_k17, 0}, - {"diagonal", __pyx_getprop_6_loess_13loess_outputs_diagonal, 0, __pyx_k18, 0}, - {"robust", __pyx_getprop_6_loess_13loess_outputs_robust, 0, __pyx_k19, 0}, - {"divisor", __pyx_getprop_6_loess_13loess_outputs_divisor, 0, __pyx_k20, 0}, - {"enp", __pyx_getprop_6_loess_13loess_outputs_enp, 0, __pyx_k21, 0}, - {"s", __pyx_getprop_6_loess_13loess_outputs_s, 0, __pyx_k22, 0}, - {"one_delta", __pyx_getprop_6_loess_13loess_outputs_one_delta, 0, __pyx_k23, 0}, - {"two_delta", __pyx_getprop_6_loess_13loess_outputs_two_delta, 0, __pyx_k24, 0}, - {"trace_hat", __pyx_getprop_6_loess_13loess_outputs_trace_hat, 0, __pyx_k25, 0}, + {"fitted_values", __pyx_getprop_6_loess_13loess_outputs_fitted_values, 0, 0, 0}, + {"fitted_residuals", __pyx_getprop_6_loess_13loess_outputs_fitted_residuals, 0, 0, 0}, + {"pseudovalues", __pyx_getprop_6_loess_13loess_outputs_pseudovalues, 0, 0, 0}, + {"diagonal", __pyx_getprop_6_loess_13loess_outputs_diagonal, 0, 0, 0}, + {"robust", __pyx_getprop_6_loess_13loess_outputs_robust, 0, 0, 0}, + {"divisor", __pyx_getprop_6_loess_13loess_outputs_divisor, 0, 0, 0}, + {"enp", __pyx_getprop_6_loess_13loess_outputs_enp, 0, 0, 0}, + {"s", __pyx_getprop_6_loess_13loess_outputs_s, 0, 0, 0}, + {"one_delta", __pyx_getprop_6_loess_13loess_outputs_one_delta, 0, 0, 0}, + {"two_delta", __pyx_getprop_6_loess_13loess_outputs_two_delta, 0, 0, 0}, + {"trace_hat", __pyx_getprop_6_loess_13loess_outputs_trace_hat, 0, 0, 0}, {0, 0, 0, 0, 0} }; @@ -5032,7 +5179,7 @@ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_loess_outputs, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ + "Outputs of a loess fit. This object is automatically created with empty\nvalues when a new loess object is instantiated. The object gets filled when the \nloess.fit() method is called.\n \n:IVariables:\n fitted_values : ndarray\n The (n,) ndarray of fitted values.\n fitted_residuals : ndarray\n The (n,) ndarray of fitted residuals (observations - fitted values).\n enp : float\n Equivalent number of parameters.\n s : float\n Estimate of the scale of residuals.\n one_delta: float\n Statistical parameter used in the computation of standard errors.\n two_delta : float\n Statistical parameter used in the computation of standard errors.\n pseudovalues : ndarray\n The (n,) ndarray of adjusted values of the response when robust estimation \n is used.\n trace_hat : float \n Trace of the operator hat matrix.\n diagonal : ndarray\n Diagonal of the operator hat matrix.\n robust : ndarray\n The (n,) ndarray of robustness weights for robust fitting.\n divisor : ndarray\n The (p,) array of normalization divisors for numeric predictors.\n ", /*tp_doc*/ __pyx_tp_traverse_6_loess_loess_outputs, /*tp_traverse*/ __pyx_tp_clear_6_loess_loess_outputs, /*tp_clear*/ 0, /*tp_richcompare*/ @@ -5072,6 +5219,15 @@ static void __pyx_tp_dealloc_6_loess_conf_intervals(PyObject *o) { struct __pyx_obj_6_loess_conf_intervals *p = (struct __pyx_obj_6_loess_conf_intervals *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++o->ob_refcnt; + __pyx_f_6_loess_14conf_intervals___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --o->ob_refcnt; + PyErr_Restore(etype, eval, etb); + } Py_XDECREF(((PyObject *)p->lower)); Py_XDECREF(((PyObject *)p->fit)); Py_XDECREF(((PyObject *)p->upper)); @@ -5204,7 +5360,7 @@ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_conf_intervals, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ + "Pointwise confidence intervals of a loess-predicted object:\n \n:IVariables:\n fit : ndarray\n Predicted values.\n lower : ndarray\n Lower bounds of the confidence intervals.\n upper : ndarray\n Upper bounds of the confidence intervals.\n ", /*tp_doc*/ __pyx_tp_traverse_6_loess_conf_intervals, /*tp_traverse*/ __pyx_tp_clear_6_loess_conf_intervals, /*tp_clear*/ 0, /*tp_richcompare*/ @@ -5299,10 +5455,10 @@ }; static struct PyGetSetDef __pyx_getsets_6_loess_loess_predicted[] = { - {"values", __pyx_getprop_6_loess_15loess_predicted_values, 0, __pyx_k26, 0}, - {"stderr", __pyx_getprop_6_loess_15loess_predicted_stderr, 0, __pyx_k27, 0}, - {"residual_scale", __pyx_getprop_6_loess_15loess_predicted_residual_scale, 0, __pyx_k28, 0}, - {"df", __pyx_getprop_6_loess_15loess_predicted_df, 0, __pyx_k29, 0}, + {"values", __pyx_getprop_6_loess_15loess_predicted_values, 0, 0, 0}, + {"stderr", __pyx_getprop_6_loess_15loess_predicted_stderr, 0, 0, 0}, + {"residual_scale", __pyx_getprop_6_loess_15loess_predicted_residual_scale, 0, 0, 0}, + {"df", __pyx_getprop_6_loess_15loess_predicted_df, 0, 0, 0}, {0, 0, 0, 0, 0} }; @@ -5395,7 +5551,7 @@ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_loess_predicted, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ + "Predicted values and standard errors of a loess object\n\n:IVariables:\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n residual_scale : float\n Estimate of the scale of the residuals\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n nest : integer\n Number of new observations.\n ", /*tp_doc*/ __pyx_tp_traverse_6_loess_loess_predicted, /*tp_traverse*/ __pyx_tp_clear_6_loess_loess_predicted, /*tp_clear*/ 0, /*tp_richcompare*/ @@ -5496,8 +5652,9 @@ } static struct PyMethodDef __pyx_methods_6_loess_loess[] = { - {"fit", (PyCFunction)__pyx_f_6_loess_5loess_fit, METH_VARARGS|METH_KEYWORDS, 0}, - {"summary", (PyCFunction)__pyx_f_6_loess_5loess_summary, METH_VARARGS|METH_KEYWORDS, 0}, + {"fit", (PyCFunction)__pyx_f_6_loess_5loess_fit, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6_loess_5loess_fit}, + {"input_summary", (PyCFunction)__pyx_f_6_loess_5loess_input_summary, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6_loess_5loess_input_summary}, + {"output_summary", (PyCFunction)__pyx_f_6_loess_5loess_output_summary, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6_loess_5loess_output_summary}, {"predict", (PyCFunction)__pyx_f_6_loess_5loess_predict, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6_loess_5loess_predict}, {0, 0, 0, 0} }; @@ -5509,8 +5666,6 @@ {"kd_tree", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess, kd_tree), READONLY, 0}, {"outputs", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess, outputs), READONLY, 0}, {"predicted", T_OBJECT, offsetof(struct __pyx_obj_6_loess_loess, predicted), READONLY, 0}, - {"nobs", T_LONG, offsetof(struct __pyx_obj_6_loess_loess, nobs), 0, 0}, - {"npar", T_LONG, offsetof(struct __pyx_obj_6_loess_loess, npar), 0, 0}, {0, 0, 0, 0, 0} }; @@ -5603,7 +5758,7 @@ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_loess, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ + "\n \n:Keywords:\n x : ndarray\n A (n,p) ndarray of independent variables, with n the number of observations\n and p the number of variables.\n y : ndarray\n A (n,) ndarray of observations\n weights : ndarray\n A (n,) ndarray of weights to be given to individual observations in the \n sum of squared residuals that forms the local fitting criterion. If not\n None, the weights should be non negative. If the different observations\n have non-equal variances, the weights should be inversely proportional \n to the variances.\n By default, an unweighted fit is carried out (all the weights are one).\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n span : float [0.75]\n Smoothing factor, as a fraction of the number of points to take into\n account. \n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n family : string [\"gaussian\"]\n Determines the assumed distribution of the errors. The values are \n \"gaussian\" or \"symmetric\". If \"gaussian\" is selected, the fit is \n performed with least-squares. If \"symmetric\" is selected, the fit\n is performed robustly by redescending M-estimators.\n parametric_flags : sequence [ [False]*p ]\n Indicates which independent variables should be conditionally-parametric\n (if there are two or more independent variables). The argument should \n be a sequence of booleans, with the same size as the number of independent \n variables, specified in the order of the predictor group ordered in x. \n drop_square : sequence [ [False]* p]\n When there are two or more independent variables and when a 2nd order\n polynomial is used, \"drop_square_flags\" specifies those numeric predictors \n whose squares should be dropped from the set of fitting variables. \n The method of specification is the same as for parametric. \n \n:Outputs:\n fitted_values : ndarray\n The (n,) ndarray of fitted values.\n fitted_residuals : ndarray\n The (n,) ndarray of fitted residuals (observations - fitted values).\n enp : float\n Equivalent number of parameters.\n s : float\n Estimate of the scale of residuals.\n one_delta: float\n Statistical parameter used in the computation of standard errors.\n two_delta : float\n Statistical parameter used in the computation of standard errors.\n pseudovalues : ndarray\n The (n,) ndarray of adjusted values of the response when robust estimation \n is used.\n trace_hat : float \n Trace of the operator hat matrix.\n diagonal :\n Diagonal of the operator hat matrix.\n robust : ndarray\n The (n,) ndarray of robustness weights for robust fitting.\n divisor : ndarray\n The (p,) array of normalization divisors for numeric predictors.\n\n ", /*tp_doc*/ __pyx_tp_traverse_6_loess_loess, /*tp_traverse*/ __pyx_tp_clear_6_loess_loess, /*tp_clear*/ 0, /*tp_richcompare*/ @@ -5793,44 +5948,48 @@ if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; - if (PyType_Ready(&__pyx_type_6_loess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_inputs", (PyObject *)&__pyx_type_6_loess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;} + __pyx_type_6_loess_loess_inputs.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_6_loess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_inputs", (PyObject *)&__pyx_type_6_loess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;} __pyx_ptype_6_loess_loess_inputs = &__pyx_type_6_loess_loess_inputs; - if (PyType_Ready(&__pyx_type_6_loess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_control", (PyObject *)&__pyx_type_6_loess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6_loess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_control", (PyObject *)&__pyx_type_6_loess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; goto __pyx_L1;} __pyx_ptype_6_loess_loess_control = &__pyx_type_6_loess_loess_control; - if (PyType_Ready(&__pyx_type_6_loess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_kd_tree", (PyObject *)&__pyx_type_6_loess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6_loess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_kd_tree", (PyObject *)&__pyx_type_6_loess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;} __pyx_ptype_6_loess_loess_kd_tree = &__pyx_type_6_loess_loess_kd_tree; __pyx_vtabptr_6_loess_loess_model = &__pyx_vtable_6_loess_loess_model; *(void(**)())&__pyx_vtable_6_loess_loess_model.setup = (void(*)())__pyx_f_6_loess_11loess_model_setup; - if (PyType_Ready(&__pyx_type_6_loess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} - if (__Pyx_SetVtable(__pyx_type_6_loess_loess_model.tp_dict, __pyx_vtabptr_6_loess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_model", (PyObject *)&__pyx_type_6_loess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6_loess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_6_loess_loess_model.tp_dict, __pyx_vtabptr_6_loess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_model", (PyObject *)&__pyx_type_6_loess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;} __pyx_ptype_6_loess_loess_model = &__pyx_type_6_loess_loess_model; - if (PyType_Ready(&__pyx_type_6_loess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_outputs", (PyObject *)&__pyx_type_6_loess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;} + __pyx_vtabptr_6_loess_loess_outputs = &__pyx_vtable_6_loess_loess_outputs; + *(void(**)())&__pyx_vtable_6_loess_loess_outputs.setup = (void(*)())__pyx_f_6_loess_13loess_outputs_setup; + if (PyType_Ready(&__pyx_type_6_loess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_6_loess_loess_outputs.tp_dict, __pyx_vtabptr_6_loess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_outputs", (PyObject *)&__pyx_type_6_loess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; goto __pyx_L1;} __pyx_ptype_6_loess_loess_outputs = &__pyx_type_6_loess_loess_outputs; __pyx_vtabptr_6_loess_conf_intervals = &__pyx_vtable_6_loess_conf_intervals; *(void(**)())&__pyx_vtable_6_loess_conf_intervals.setup = (void(*)())__pyx_f_6_loess_14conf_intervals_setup; __pyx_type_6_loess_conf_intervals.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6_loess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; goto __pyx_L1;} - if (__Pyx_SetVtable(__pyx_type_6_loess_conf_intervals.tp_dict, __pyx_vtabptr_6_loess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "conf_intervals", (PyObject *)&__pyx_type_6_loess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6_loess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_6_loess_conf_intervals.tp_dict, __pyx_vtabptr_6_loess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "conf_intervals", (PyObject *)&__pyx_type_6_loess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; goto __pyx_L1;} __pyx_ptype_6_loess_conf_intervals = &__pyx_type_6_loess_conf_intervals; __pyx_vtabptr_6_loess_loess_predicted = &__pyx_vtable_6_loess_loess_predicted; *(void(**)())&__pyx_vtable_6_loess_loess_predicted.setup = (void(*)())__pyx_f_6_loess_15loess_predicted_setup; __pyx_type_6_loess_loess_predicted.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6_loess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;} - if (__Pyx_SetVtable(__pyx_type_6_loess_loess_predicted.tp_dict, __pyx_vtabptr_6_loess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess_predicted", (PyObject *)&__pyx_type_6_loess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6_loess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_6_loess_loess_predicted.tp_dict, __pyx_vtabptr_6_loess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_predicted", (PyObject *)&__pyx_type_6_loess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;} __pyx_ptype_6_loess_loess_predicted = &__pyx_type_6_loess_loess_predicted; __pyx_type_6_loess_loess.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_6_loess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "loess", (PyObject *)&__pyx_type_6_loess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6_loess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess", (PyObject *)&__pyx_type_6_loess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; goto __pyx_L1;} __pyx_ptype_6_loess_loess = &__pyx_type_6_loess_loess; - if (PyType_Ready(&__pyx_type_6_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "anova", (PyObject *)&__pyx_type_6_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; goto __pyx_L1;} + if (PyType_Ready(&__pyx_type_6_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "anova", (PyObject *)&__pyx_type_6_loess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; goto __pyx_L1;} __pyx_ptype_6_loess_anova = &__pyx_type_6_loess_anova; __pyx_ptype_7c_numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (!__pyx_ptype_7c_numpy_dtype) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; goto __pyx_L1;} __pyx_ptype_7c_numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (!__pyx_ptype_7c_numpy_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 81; goto __pyx_L1;} @@ -5849,27 +6008,34 @@ if (PyObject_SetAttr(__pyx_m, __pyx_n_narray, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":12 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":10 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_float_); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (PyObject_SetAttr(__pyx_m, __pyx_n_float_, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":13 */ import_array(); - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":73 */ - __pyx_k31; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":36 */ + __pyx_k8; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":721 */ - __pyx_1 = PyFloat_FromDouble(0.95); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;} - __pyx_k32 = __pyx_1; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":609 */ + __pyx_1 = PyFloat_FromDouble(0.95); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;} + __pyx_k9 = __pyx_1; __pyx_1 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":763 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":758 */ Py_INCREF(Py_None); - __pyx_k33 = Py_None; + __pyx_k10 = Py_None; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":834 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; goto __pyx_L1;} - __pyx_k34 = __pyx_2; + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":821 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;} + __pyx_k11 = __pyx_2; __pyx_2 = 0; - /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":883 */ + /* "/home/backtopop/workspace/pyloess/src/_loess.pyx":889 */ return; __pyx_L1:; Py_XDECREF(__pyx_1); Modified: trunk/Lib/sandbox/pyloess/src/_loess.pyx =================================================================== --- trunk/Lib/sandbox/pyloess/src/_loess.pyx 2007-03-26 19:37:12 UTC (rev 2873) +++ trunk/Lib/sandbox/pyloess/src/_loess.pyx 2007-03-27 06:38:36 UTC (rev 2874) @@ -7,6 +7,7 @@ PyArray_SimpleNewFromData import numpy narray = numpy.array +float_ = numpy.float_ # NumPy must be initialized c_numpy.import_array() @@ -31,142 +32,9 @@ a_ndr.shape = (rows, cols) return a_ndr.astype(numpy.bool) -##cimport modelflags -##import modelflags -# -#cdef list_to_clist(object p_list): -# cdef int i, imax -# p_list = list(p_list) -# imax = min(8, len(p_list)) -# for i from 0 <= i < imax: -# c_list[i] = p_list[i] -# return c_list[0] -#cdef object clist_to_list(int c_list[8]): -# cdef int i, imax -# p_list = [False] * 8 -# imax = min(8, len(p_list)) -# for i from 0 <= i < imax: -# p_list[i] = c_list[i] -# return p_list -# -# -#class modelflags: -# def __init__(self): -# self.str_list = [False] * 8 -# self.c_list = list_to_clist(self.str_list) -# def __getitem__(self, idx): -# return self.str_list[idx] -# def __setitem__(self, idx, val): -# cdef int tmpval -# tmpval = val -# self.c_list[idx] = tmpval -# self.str_list[idx] = bool(val) -# def __str__(self): -# return str(self.str_list) -# -##class modelflags(c_modelflags): -## def __init__(self): -## c_modelflags.__init__(self) -## - """ -:Keywords: - x : ndarray - A (n,p) ndarray of independent variables, with n the number of observations - and p the number of variables. - y : ndarray - A (n,) ndarray of observations - weights : ndarray - A (n,) ndarray of weights to be given to individual observations in the - sum of squared residuals that forms the local fitting criterion. If not - None, the weights should be non negative. If the different observations - have non-equal variances, the weights should be inversely proportional - to the variances. - By default, an unweighted fit is carried out (all the weights are one). - surface : string ["interpolate"] - Determines whether the fitted surface is computed directly at all points - ("direct") or whether an interpolation method is used ("interpolate"). - The default ("interpolate") is what most users should use unless special - circumstances warrant. - statistics : string ["approximate"] - Determines whether the statistical quantities are computed exactly - ("exact") or approximately ("approximate"). "exact" should only be used - for testing the approximation in statistical development and is not meant - for routine usage because computation time can be horrendous. - trace_hat : string ["wait.to.decide"] - Determines how the trace of the hat matrix should be computed. The hat - matrix is used in the computation of the statistical quantities. - If "exact", an exact computation is done; this could be slow when the - number of observations n becomes large. If "wait.to.decide" is selected, - then a default is "exact" for n < 500 and "approximate" otherwise. - This option is only useful when the fitted surface is interpolated. If - surface is "exact", an exact computation is always done for the trace. - Setting trace_hat to "approximate" for large dataset will substantially - reduce the computation time. - iterations : integer - Number of iterations of the robust fitting method. If the family is - "gaussian", the number of iterations is set to 0. - cell : integer - Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span), - where n is the number of observations, and span the smoothing parameter. - Then, a cell is further divided if the number of observations within it - is greater than or equal to k. This option is only used if the surface - is interpolated. - span : float [0.75] - Smoothing factor, as a fraction of the number of points to take into - account. - degree : integer [2] - Overall degree of locally-fitted polynomial. 1 is locally-linear - fitting and 2 is locally-quadratic fitting. Degree should be 2 at most. - normalize : boolean [True] - Determines whether the independent variables should be normalized. - If True, the normalization is performed by setting the 10% trimmed - standard deviation to one. If False, no normalization is carried out. - This option is only useful for more than one variable. For spatial - coordinates predictors or variables with a common scale, it should be - set to False. - family : string ["gaussian"] - Determines the assumed distribution of the errors. The values are - "gaussian" or "symmetric". If "gaussian" is selected, the fit is - performed with least-squares. If "symmetric" is selected, the fit - is performed robustly by redescending M-estimators. - parametric_flags : sequence [ [False]*p ] - Indicates which independent variables should be conditionally-parametric - (if there are two or more independent variables). The argument should - be a sequence of booleans, with the same size as the number of independent - variables, specified in the order of the predictor group ordered in x. - drop_square : sequence [ [False]* p] - When there are two or more independent variables and when a 2nd order - polynomial is used, "drop_square_flags" specifies those numeric predictors - whose squares should be dropped from the set of fitting variables. - The method of specification is the same as for parametric. -:Outputs: - fitted_values : ndarray - The (n,) ndarray of fitted values. - fitted_residuals : ndarray - The (n,) ndarray of fitted residuals (observations - fitted values). - enp : float - Equivalent number of parameters. - s : float - Estimate of the scale of residuals. - one_delta: float - Statistical parameter used in the computation of standard errors. - two_delta : float - Statistical parameter used in the computation of standard errors. - pseudovalues : ndarray - The (n,) ndarray of adjusted values of the response when robust estimation - is used. - trace_hat : float - Trace of the operator hat matrix. - diagonal : - Diagonal of the operator hat matrix. - robust : ndarray - The (n,) ndarray of robustness weights for robust fitting. - divisor : ndarray - The (p,) array of normalization divisors for numeric predictors. - newdata : ndarray The (m,p) array of independent variables where the surface must be estimated. @@ -191,16 +59,49 @@ #---- ---- loess model --- #####--------------------------------------------------------------------------- cdef class loess_inputs: + """Loess inputs + +:IVariables: + x : ndarray + A (n,p) ndarray of independent variables, with n the number of observations + and p the number of variables. + y : ndarray + A (n,) ndarray of observations + nobs : integer + Number of observations: nobs=n. + npar : integer + Number of independent variables: npar=p. + weights : ndarray + A (n,) ndarray of weights to be given to individual observations in the + sum of squared residuals that forms the local fitting criterion. If not + None, the weights should be non negative. If the different observations + have non-equal variances, the weights should be inversely proportional + to the variances. + By default, an unweighted fit is carried out (all the weights are one). + """ cdef c_loess.c_loess_inputs *_base + cdef ndarray w_ndr + cdef readonly ndarray x, y, masked, x_eff, y_eff + cdef readonly int nobs, npar #......... - property x: - def __get__(self): - return floatarray_from_data(self._base.n, self._base.p, self._base.x) + def __init__(self, x_data, y_data): + cdef ndarray unmasked + self.x = narray(x_data, copy=False, subok=True, dtype=float_, order='C') + self.y = narray(y_data, copy=False, subok=True, dtype=float_, order='C') + # Check the dimensions ........ + if self.x.ndim == 1: + self.npar = 1 + elif self.x.ndim == 2: + self.npar = self.x.shape[-1] + else: + raise ValueError("The array of indepedent varibales should be 2D at most!") + self.nobs = len(self.x) + # Get the effective data ...... + self.x_eff = self.x.ravel() + self.y_eff = self.y + self.w_ndr = numpy.ones((self.nobs,), dtype=float_) + #......... - property y: - def __get__(self): - return floatarray_from_data(self._base.n, 1, self._base.y) - #......... property weights: """A (n,) ndarray of weights to be given to individual observations in the sum of squared residuals that forms the local fitting criterion. If not @@ -210,30 +111,55 @@ By default, an unweighted fit is carried out (all the weights are one). """ def __get__(self): - return floatarray_from_data(self._base.n, 1, self._base.weights) + return self.w_ndr def __set__(self, w): cdef npy_intp *dims cdef ndarray w_ndr - w_ndr = PyArray_FROMANY(w, NPY_DOUBLE, 1, 1, NPY_OWNDATA) - if w_ndr.ndim > 1 or w_ndr.size != self._base.n: + w_ndr = narray(w, copy=False, subok=False) + if w_ndr.ndim > 1 or w_ndr.size != self.nobs: raise ValueError, "Invalid size of the 'weights' vector!" + self.w_ndr = w_ndr self._base.weights = w_ndr.data - #......... - property nobs: - "Number of observations." - def __get__(self): - return self._base.n - #......... - property npar: - "Number of independent variables." - def __get__(self): - return self._base.p # ######--------------------------------------------------------------------------- ##---- ---- loess control --- ######--------------------------------------------------------------------------- cdef class loess_control: + """Loess control parameters. + +:IVariables: + surface : string ["interpolate"] + Determines whether the fitted surface is computed directly at all points + ("direct") or whether an interpolation method is used ("interpolate"). + The default ("interpolate") is what most users should use unless special + circumstances warrant. + statistics : string ["approximate"] + Determines whether the statistical quantities are computed exactly + ("exact") or approximately ("approximate"). "exact" should only be used + for testing the approximation in statistical development and is not meant + for routine usage because computation time can be horrendous. + trace_hat : string ["wait.to.decide"] + Determines how the trace of the hat matrix should be computed. The hat + matrix is used in the computation of the statistical quantities. + If "exact", an exact computation is done; this could be slow when the + number of observations n becomes large. If "wait.to.decide" is selected, + then a default is "exact" for n < 500 and "approximate" otherwise. + This option is only useful when the fitted surface is interpolated. If + surface is "exact", an exact computation is always done for the trace. + Setting trace_hat to "approximate" for large dataset will substantially + reduce the computation time. + iterations : integer + Number of iterations of the robust fitting method. If the family is + "gaussian", the number of iterations is set to 0. + cell : integer + Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span), + where n is the number of observations, and span the smoothing parameter. + Then, a cell is further divided if the number of observations within it + is greater than or equal to k. This option is only used if the surface + is interpolated. + + """ cdef c_loess.c_loess_control *_base #......... property surface: @@ -364,45 +290,59 @@ ##---- ---- loess model --- ######--------------------------------------------------------------------------- cdef class loess_model: + """loess_model contains parameters required for a loess fit. + +:IVariables: + normalize : boolean [True] + Determines whether the independent variables should be normalized. + If True, the normalization is performed by setting the 10% trimmed + standard deviation to one. If False, no normalization is carried out. + This option is only useful for more than one variable. For spatial + coordinates predictors or variables with a common scale, it should be + set to False. + span : float [0.75] + Smoothing factor, as a fraction of the number of points to take into + account. + degree : integer [2] + Overall degree of locally-fitted polynomial. 1 is locally-linear + fitting and 2 is locally-quadratic fitting. Degree should be 2 at most. + family : string ["gaussian"] + Determines the assumed distribution of the errors. The values are + "gaussian" or "symmetric". If "gaussian" is selected, the fit is + performed with least-squares. If "symmetric" is selected, the fit + is performed robustly by redescending M-estimators. + parametric_flags : sequence [ [False]*p ] + Indicates which independent variables should be conditionally-parametric + (if there are two or more independent variables). The argument should be + a sequence of booleans, with the same size as the number of independent + variables, specified in the order of the predictor group ordered in x. + Note: elements of the sequence cannot be modified individually: the whole + sequence must be given. + drop_square : sequence [ [False]* p] + When there are two or more independent variables and when a 2nd order + polynomial is used, "drop_square_flags" specifies those numeric predictors + whose squares should be dropped from the set of fitting variables. + The method of specification is the same as for parametric. + Note: elements of the sequence cannot be modified individually: the whole + sequence must be given. + + """ + cdef c_loess.c_loess_model *_base cdef long npar -# cdef public double span -# cdef public int degree -# cdef public char *family -# cdef public parametric_mflags, drop_square_mflags #......... cdef setup(self, c_loess.c_loess_model *base, long npar): self._base = base self.npar = npar -# self.parametric_flags = modelflags() -# self.parametric_flags.c_list[0] = base.parametric[0] -# self.drop_square_flags = modelflags() -# self.drop_square_flags.c_list[0] = base.drop_square[0] -# self.span = self._base.span -# self.degree = self._base.degree -# self.family = self._base.family -# self.parametric_flags = boolarray_from_data(self.npar, 1, self._base.parametric) -# self.drop_square_flags = boolarray_from_data(self.npar, 1, self._base.drop_square) return self #......... property normalize: - """ - normalize : boolean [True] - Determines whether the independent variables should be normalized. - If True, the normalization is performed by setting the 10% trimmed - standard deviation to one. If False, no normalization is carried out. - This option is only useful for more than one variable. For spatial - coordinates predictors or variables with a common scale, it should be - set to False. - """ def __get__(self): return bool(self._base.normalize) def __set__(self, normalize): self._base.normalize = normalize #......... property span: - """Smoothing factor, as a fraction of the number of points to take into - account. By default, span=0.75.""" def __get__(self): return self._base.span def __set__(self, span): @@ -411,25 +351,14 @@ self._base.span = span #......... property degree: - """ - degree : integer [2] - Overall degree of locally-fitted polynomial. 1 is locally-linear - fitting and 2 is locally-quadratic fitting. Degree should be 2 at most. - """ def __get__(self): return self._base.degree def __set__(self, degree): if degree < 0 or degree > 2: raise ValueError("Degree should be between 0 and 2!") + self._base.degree = degree #......... property family: - """ - family : string ["gaussian"] - Determines the assumed distribution of the errors. The values are - "gaussian" or "symmetric". If "gaussian" is selected, the fit is - performed with least-squares. If "symmetric" is selected, the fit - is performed robustly by redescending M-estimators. - """ def __get__(self): return self._base.family def __set__(self, family): @@ -439,13 +368,6 @@ self._base.family = family #......... property parametric_flags: - """ - parametric_flags : sequence [ [False]*p ] - Indicates which independent variables should be conditionally-parametric - (if there are two or more independent variables). The argument should - be a sequence of booleans, with the same size as the number of independent - variables, specified in the order of the predictor group ordered in x. - """ def __get__(self): return boolarray_from_data(self.npar, 1, self._base.parametric) def __set__(self, paramf): @@ -457,13 +379,6 @@ self._base.parametric[i] = p_ndr[i] #......... property drop_square_flags: - """ - drop_square : sequence [ [False]* p] - When there are two or more independent variables and when a 2nd order - polynomial is used, "drop_square_flags" specifies those numeric predictors - whose squares should be dropped from the set of fitting variables. - The method of specification is the same as for parametric. - """ def __get__(self): return boolarray_from_data(self.npar, 1, self._base.drop_square) def __set__(self, drop_sq): @@ -500,16 +415,16 @@ self.drop_square_flags = drop_square #......... def __repr__(self): - return "loess model parameters @%s" % id(self) + return "" #......... def __str__(self): strg = ["Model parameters.....", - "family : %s" % self.family, - "span : %s" % self.span, - "degree : %s" % self.degree, - "normalized : %s" % self.normalize, - "parametric : %s" % self.parametric_flags[:self.npar], - "drop_square : %s" % self.drop_square_flags[:self.npar] + "Family : %s" % self.family, + "Span : %s" % self.span, + "Degree : %s" % self.degree, + "Normalized : %s" % self.normalize, + "Parametric : %s" % self.parametric_flags[:self.npar], + "Drop_square : %s" % self.drop_square_flags[:self.npar] ] return '\n'.join(strg) @@ -517,93 +432,85 @@ #---- ---- loess outputs --- #####--------------------------------------------------------------------------- cdef class loess_outputs: + """Outputs of a loess fit. This object is automatically created with empty +values when a new loess object is instantiated. The object gets filled when the +loess.fit() method is called. + +:IVariables: + fitted_values : ndarray + The (n,) ndarray of fitted values. + fitted_residuals : ndarray + The (n,) ndarray of fitted residuals (observations - fitted values). + enp : float + Equivalent number of parameters. + s : float + Estimate of the scale of residuals. + one_delta: float + Statistical parameter used in the computation of standard errors. + two_delta : float + Statistical parameter used in the computation of standard errors. + pseudovalues : ndarray + The (n,) ndarray of adjusted values of the response when robust estimation + is used. + trace_hat : float + Trace of the operator hat matrix. + diagonal : ndarray + Diagonal of the operator hat matrix. + robust : ndarray + The (n,) ndarray of robustness weights for robust fitting. + divisor : ndarray + The (p,) array of normalization divisors for numeric predictors. + """ cdef c_loess.c_loess_outputs *_base cdef long nobs, npar cdef readonly int activated + cdef setup(self,c_loess.c_loess_outputs *base, long nobs, long npar): + self._base = base + self.nobs = nobs + self.npar = npar + self.activated = False #........ property fitted_values: - """ - fitted_values : ndarray - The (n,) ndarray of fitted values. - """ def __get__(self): return floatarray_from_data(self.nobs, 1, self._base.fitted_values) #......... property fitted_residuals: - """ - fitted_residuals : ndarray - The (n,) ndarray of fitted residuals (observations - fitted values). - """ def __get__(self): return floatarray_from_data(self.nobs, 1, self._base.fitted_residuals) #......... property pseudovalues: - """ - pseudovalues : ndarray - The (n,) ndarray of adjusted values of the response when robust estimation - is used. - """ def __get__(self): return floatarray_from_data(self.nobs, 1, self._base.pseudovalues) #......... property diagonal: - """ - diagonal : - Diagonal of the operator hat matrix. - """ def __get__(self): return floatarray_from_data(self.nobs, 1, self._base.diagonal) #......... property robust: - """ - robust : ndarray - The (n,) ndarray of robustness weights for robust fitting. - """ def __get__(self): return floatarray_from_data(self.nobs, 1, self._base.robust) #......... property divisor: - "Equivalent number of parameters." def __get__(self): return floatarray_from_data(self.npar, 1, self._base.divisor) #......... property enp: - """ - enp : float - Equivalent number of parameters. - """ def __get__(self): return self._base.enp #......... property s: - """ - s : float - Estimate of the scale of residuals. - """ def __get__(self): return self._base.s #......... property one_delta: - """ - one_delta: float - Statistical parameter used in the computation of standard errors. - """ def __get__(self): return self._base.one_delta #......... property two_delta: - """ - two_delta : float - Statistical parameter used in the computation of standard errors. - """ def __get__(self): return self._base.two_delta #......... property trace_hat: - """ - trace_hat : float - Trace of the operator hat matrix. - """ def __get__(self): return self._base.trace_hat #......... @@ -623,11 +530,21 @@ #---- ---- loess confidence --- #####--------------------------------------------------------------------------- cdef class conf_intervals: + """Pointwise confidence intervals of a loess-predicted object: + +:IVariables: + fit : ndarray + Predicted values. + lower : ndarray + Lower bounds of the confidence intervals. + upper : ndarray + Upper bounds of the confidence intervals. + """ cdef c_loess.c_conf_inv _base cdef readonly ndarray lower, fit, upper #......... -# def __dealloc__(self): -# c_loess.pw_free_mem(self._base) + def __dealloc__(self): + c_loess.pw_free_mem(&self._base) #......... cdef setup(self, c_loess.c_conf_inv base, long nest): self._base = base @@ -645,11 +562,26 @@ #---- ---- loess predictions --- #####--------------------------------------------------------------------------- cdef class loess_predicted: + """Predicted values and standard errors of a loess object + +:IVariables: + values : ndarray + The (m,) ndarray of loess values evaluated at newdata + stderr : ndarray + The (m,) ndarray of the estimates of the standard error on the estimated + values. + residual_scale : float + Estimate of the scale of the residuals + df : integer + Degrees of freedom of the t-distribution used to compute pointwise + confidence intervals for the evaluated surface. + nest : integer + Number of new observations. + """ + cdef c_loess.c_prediction _base cdef readonly long nest cdef readonly conf_intervals confidence_intervals -# cdef readonly ndarray values, stderr -# cdef readonly double residual_scale, df #......... def __dealloc__(self): c_loess.pred_free_mem(&self._base) @@ -657,64 +589,20 @@ cdef setup(self, c_loess.c_prediction base, long nest): self._base = base self.nest = nest -# cdef setup(self, c_loess.c_loess loess_base, object newdata, stderror): -# cdef ndarray p_ndr -# cdef double *p_dat -# cdef c_loess.c_prediction _prediction -# cdef int i, m -# # -# # Note : we need a copy as we may have to normalize -# p_ndr = narray(newdata, copy=True, subok=True, order='C').ravel() -# p_dat = p_ndr.data -# # Test the compatibility of sizes ....... -# if p_ndr.size == 0: -# raise ValueError("Can't predict without input data !") -# (m, notOK) = divmod(len(p_ndr), loess_base.inputs.p) -# if notOK: -# raise ValueError( -# "Incompatible data size: there should be as many rows as parameters") -# #..... -# c_loess.c_predict(p_dat, m, &loess_base, &_prediction, stderror) -# if loess_base.status.err_status: -# raise ValueError(loess_base.status.err_msg) -# self._base = _prediction -# self.nest = m -## self.values = floatarray_from_data(m, 1, _prediction.fit) -## self.stderr = floatarray_from_data(m, 1, _prediction.se_fit) -## self.residual_scale = _prediction.residual_scale -## self.df = _prediction.df #......... property values: - """ - values : ndarray - The (m,) ndarray of loess values evaluated at newdata - """ def __get__(self): return floatarray_from_data(self.nest, 1, self._base.fit) #......... property stderr: - """ - stderr : ndarray - The (m,) ndarray of the estimates of the standard error on the estimated - values. - """ def __get__(self): return floatarray_from_data(self.nest, 1, self._base.se_fit) #......... property residual_scale: - """ - residual_scale : float - Estimate of the scale of the residuals - """ def __get__(self): return self._base.residual_scale #......... property df: - """ - df : integer - Degrees of freedom of the t-distribution used to compute pointwise - confidence intervals for the evaluated surface. - """ def __get__(self): return self._base.df #......... @@ -725,6 +613,15 @@ :Parameters: coverage : float Confidence level of the confidence intervals limits, as a fraction. + +:Returns: + A new conf_intervals object, consisting of: + fit : ndarray + Predicted values. + lower : ndarray + Lower bounds of the confidence intervals. + upper : ndarray + Upper bounds of the confidence intervals. """ cdef c_loess.c_conf_inv _confintv if coverage < 0.5: @@ -751,6 +648,105 @@ #---- ---- loess base class --- #####--------------------------------------------------------------------------- cdef class loess: + """ + +:Keywords: + x : ndarray + A (n,p) ndarray of independent variables, with n the number of observations + and p the number of variables. + y : ndarray + A (n,) ndarray of observations + weights : ndarray + A (n,) ndarray of weights to be given to individual observations in the + sum of squared residuals that forms the local fitting criterion. If not + None, the weights should be non negative. If the different observations + have non-equal variances, the weights should be inversely proportional + to the variances. + By default, an unweighted fit is carried out (all the weights are one). + surface : string ["interpolate"] + Determines whether the fitted surface is computed directly at all points + ("direct") or whether an interpolation method is used ("interpolate"). + The default ("interpolate") is what most users should use unless special + circumstances warrant. + statistics : string ["approximate"] + Determines whether the statistical quantities are computed exactly + ("exact") or approximately ("approximate"). "exact" should only be used + for testing the approximation in statistical development and is not meant + for routine usage because computation time can be horrendous. + trace_hat : string ["wait.to.decide"] + Determines how the trace of the hat matrix should be computed. The hat + matrix is used in the computation of the statistical quantities. + If "exact", an exact computation is done; this could be slow when the + number of observations n becomes large. If "wait.to.decide" is selected, + then a default is "exact" for n < 500 and "approximate" otherwise. + This option is only useful when the fitted surface is interpolated. If + surface is "exact", an exact computation is always done for the trace. + Setting trace_hat to "approximate" for large dataset will substantially + reduce the computation time. + iterations : integer + Number of iterations of the robust fitting method. If the family is + "gaussian", the number of iterations is set to 0. + cell : integer + Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span), + where n is the number of observations, and span the smoothing parameter. + Then, a cell is further divided if the number of observations within it + is greater than or equal to k. This option is only used if the surface + is interpolated. + span : float [0.75] + Smoothing factor, as a fraction of the number of points to take into + account. + degree : integer [2] + Overall degree of locally-fitted polynomial. 1 is locally-linear + fitting and 2 is locally-quadratic fitting. Degree should be 2 at most. + normalize : boolean [True] + Determines whether the independent variables should be normalized. + If True, the normalization is performed by setting the 10% trimmed + standard deviation to one. If False, no normalization is carried out. + This option is only useful for more than one variable. For spatial + coordinates predictors or variables with a common scale, it should be + set to False. + family : string ["gaussian"] + Determines the assumed distribution of the errors. The values are + "gaussian" or "symmetric". If "gaussian" is selected, the fit is + performed with least-squares. If "symmetric" is selected, the fit + is performed robustly by redescending M-estimators. + parametric_flags : sequence [ [False]*p ] + Indicates which independent variables should be conditionally-parametric + (if there are two or more independent variables). The argument should + be a sequence of booleans, with the same size as the number of independent + variables, specified in the order of the predictor group ordered in x. + drop_square : sequence [ [False]* p] + When there are two or more independent variables and when a 2nd order + polynomial is used, "drop_square_flags" specifies those numeric predictors + whose squares should be dropped from the set of fitting variables. + The method of specification is the same as for parametric. + +:Outputs: + fitted_values : ndarray + The (n,) ndarray of fitted values. + fitted_residuals : ndarray + The (n,) ndarray of fitted residuals (observations - fitted values). + enp : float + Equivalent number of parameters. + s : float + Estimate of the scale of residuals. + one_delta: float + Statistical parameter used in the computation of standard errors. + two_delta : float + Statistical parameter used in the computation of standard errors. + pseudovalues : ndarray + The (n,) ndarray of adjusted values of the response when robust estimation + is used. + trace_hat : float + Trace of the operator hat matrix. + diagonal : + Diagonal of the operator hat matrix. + robust : ndarray + The (n,) ndarray of robustness weights for robust fitting. + divisor : ndarray + The (p,) array of normalization divisors for numeric predictors. + + """ cdef c_loess.c_loess _base cdef readonly loess_inputs inputs cdef readonly loess_model model @@ -758,51 +754,33 @@ cdef readonly loess_kd_tree kd_tree cdef readonly loess_outputs outputs cdef readonly loess_predicted predicted - cdef public long nobs, npar def __init__(self, object x, object y, object weights=None, **options): # cdef ndarray x_ndr, y_ndr cdef double *x_dat, *y_dat cdef int i - # Get the predictor array - x_ndr = narray(x, copy=True, subok=True, order='C') - x_dat = x_ndr.data - n = len(x_ndr) - p = x_ndr.size / n - self.npar = p - self.nobs = n - # Ravel the predictor array ... - if p > 1: - x_ndr.shape = (n*p,) - # Get the response array ...... - y_ndr = narray(y, copy=False, subok=True, order='C') - y_dat = y_ndr.data - if y_ndr.size != n: - raise ValueError("Incompatible size between the response array (%i)"\ - " and the predictor array (%i)" % (y_ndr,n)) - # Initialization .............. + # Initialize the inputs ....... + self.inputs = loess_inputs(x, y) + x_dat = self.inputs.x_eff.data + y_dat = self.inputs.y_eff.data + n = self.inputs.nobs + p = self.inputs.npar c_loess.loess_setup(x_dat, y_dat, n, p, &self._base) - # - self.inputs = loess_inputs() + # Sets the _base input ......... self.inputs._base = &self._base.inputs - # + # Initialize the model parameters self.model = loess_model() self.model.setup(&self._base.model, p) -# self.model._base = &self._base.model -# self.model.npar = p - # + # Initialize the control parameters self.control = loess_control() self.control._base = &self._base.control - # + # Initialize the kd tree ...... self.kd_tree = loess_kd_tree() self.kd_tree._base = &self._base.kd_tree - # + # Initialize the outputs ...... self.outputs = loess_outputs() - self.outputs._base = &self._base.outputs - self.outputs.activated = False - self.outputs.nobs = n - self.outputs.npar = p + self.outputs.setup(&self._base.outputs, n, p,) # Process options ............. modelopt = {} controlopt = {} @@ -817,14 +795,23 @@ self.model.update(**modelopt) #...................................................... def fit(self): + """Computes the loess parameters on the current inputs and sets of parameters.""" c_loess.loess_fit(&self._base) self.outputs.activated = True if self._base.status.err_status: raise ValueError(self._base.status.err_msg) return #...................................................... - def summary(self): + def input_summary(self): + """Returns some generic information about the loess parameters. + """ + toprint = [str(self.inputs), str(self.model), str(self.control)] + return "\n".join(toprint) + + def output_summary(self): + """Returns some generic information about the loess fit.""" print "Number of Observations : %d" % self.inputs.nobs + print "Fit flag : %d" % bool(self.outputs.activated) print "Equivalent Number of Parameters: %.1f" % self.outputs.enp if self.model.family == "gaussian": print "Residual Standard Error : %.4f" % self.outputs.s @@ -832,13 +819,32 @@ print "Residual Scale Estimate : %.4f" % self.outputs.s #...................................................... def predict(self, newdata, stderror=False): + """Computes loess estimates at the given new data points newdata. Returns +a loess_predicted object, whose attributes are described below. + +:Parameters: + newdata : ndarray + The (m,p) array of independent variables where the surface must be estimated, + with m the number of new data points, and p the number of independent + variables. + stderror : boolean + Whether the standard error should be computed + +:Returns: + A new loess_predicted object, consisting of: + values : ndarray + The (m,) ndarray of loess values evaluated at newdata + stderr : ndarray + The (m,) ndarray of the estimates of the standard error on the estimated + values. + residual_scale : float + Estimate of the scale of the residuals + df : integer + Degrees of freedom of the t-distribution used to compute pointwise + confidence intervals for the evaluated surface. + nest : integer + Number of new observations. """ - newdata: ndarray - A (m,p) ndarray specifying the values of the predictors at which the - evaluation is to be carried out. - stderr: Boolean - Logical flag for computing standard errors at newdata. - """ cdef ndarray p_ndr cdef double *p_dat cdef c_loess.c_prediction _prediction @@ -855,7 +861,7 @@ # Test the compatibility of sizes ....... if p_ndr.size == 0: raise ValueError("Can't predict without input data !") - (m, notOK) = divmod(len(p_ndr), self.npar) + (m, notOK) = divmod(len(p_ndr), self.inputs.npar) if notOK: raise ValueError( "Incompatible data size: there should be as many rows as parameters") Added: trunk/Lib/sandbox/pyloess/src/_mloess.c =================================================================== --- trunk/Lib/sandbox/pyloess/src/_mloess.c 2007-03-26 19:37:12 UTC (rev 2873) +++ trunk/Lib/sandbox/pyloess/src/_mloess.c 2007-03-27 06:38:36 UTC (rev 2874) @@ -0,0 +1,6807 @@ +/* Generated by Pyrex 0.9.5.1a on Sun Mar 25 18:15:14 2007 */ + +#include "Python.h" +#include "structmember.h" +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifdef __cplusplus +#define __PYX_EXTERN_C extern "C" +#else +#define __PYX_EXTERN_C extern +#endif +__PYX_EXTERN_C double pow(double, double); +#include "stdlib.h" +#include "numpy/arrayobject.h" +#include "loess.h" +#include "cloess.h" + + +typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ +typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ + +static PyObject *__pyx_m; +static PyObject *__pyx_b; +static int __pyx_lineno; +static char *__pyx_filename; +static char **__pyx_f; + +static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/ + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ + +static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ + +static PyObject *__Pyx_UnpackItem(PyObject *); /*proto*/ +static int __Pyx_EndUnpack(PyObject *); /*proto*/ + +static int __Pyx_PrintItem(PyObject *); /*proto*/ +static int __Pyx_PrintNewline(void); /*proto*/ + +static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ + +static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ + +static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/ + +static void __Pyx_AddTraceback(char *funcname); /*proto*/ + +/* Declarations from c_python */ + + +/* Declarations from c_numpy */ + +static PyTypeObject *__pyx_ptype_7c_numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_7c_numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_7c_numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_7c_numpy_broadcast = 0; + +/* Declarations from c_loess */ + + +/* Declarations from _mloess */ + + +struct __pyx_obj_7_mloess_loess_inputs { + PyObject_HEAD + loess_inputs (*_base); + PyArrayObject *w_ndr; + PyArrayObject *x; + PyArrayObject *y; + PyArrayObject *masked; + PyArrayObject *x_eff; + PyArrayObject *y_eff; + int nobs; + int nobs_eff; + int npar; +}; + + +struct __pyx_obj_7_mloess_loess_control { + PyObject_HEAD + loess_control (*_base); +}; + + +struct __pyx_obj_7_mloess_loess_kd_tree { + PyObject_HEAD + loess_kd_tree (*_base); +}; + + +struct __pyx_obj_7_mloess_loess_model { + PyObject_HEAD + struct __pyx_vtabstruct_7_mloess_loess_model *__pyx_vtab; + loess_model (*_base); + long npar; +}; + +struct __pyx_vtabstruct_7_mloess_loess_model { + PyObject *((*setup)(struct __pyx_obj_7_mloess_loess_model *,loess_model (*),long )); +}; +static struct __pyx_vtabstruct_7_mloess_loess_model *__pyx_vtabptr_7_mloess_loess_model; + + +struct __pyx_obj_7_mloess_loess_outputs { + PyObject_HEAD + struct __pyx_vtabstruct_7_mloess_loess_outputs *__pyx_vtab; + loess_outputs (*_base); + long nobs; + long nobs_eff; + long npar; + PyArrayObject *masked; + PyArrayObject *unmasked; + int activated; + int ismasked; +}; + +struct __pyx_vtabstruct_7_mloess_loess_outputs { + PyObject *((*setup)(struct __pyx_obj_7_mloess_loess_outputs *,loess_outputs (*),long ,long ,long ,PyArrayObject *)); + PyArrayObject *((*getoutput)(struct __pyx_obj_7_mloess_loess_outputs *,double (*))); +}; +static struct __pyx_vtabstruct_7_mloess_loess_outputs *__pyx_vtabptr_7_mloess_loess_outputs; + + +struct __pyx_obj_7_mloess_conf_intervals { + PyObject_HEAD + struct __pyx_vtabstruct_7_mloess_conf_intervals *__pyx_vtab; + conf_inv _base; + PyArrayObject *lower; + PyArrayObject *fit; + PyArrayObject *upper; +}; + +struct __pyx_vtabstruct_7_mloess_conf_intervals { + PyObject *((*setup)(struct __pyx_obj_7_mloess_conf_intervals *,conf_inv ,long )); +}; +static struct __pyx_vtabstruct_7_mloess_conf_intervals *__pyx_vtabptr_7_mloess_conf_intervals; + + +struct __pyx_obj_7_mloess_loess_predicted { + PyObject_HEAD + struct __pyx_vtabstruct_7_mloess_loess_predicted *__pyx_vtab; + prediction _base; + long nest; + struct __pyx_obj_7_mloess_conf_intervals *confidence_intervals; +}; + +struct __pyx_vtabstruct_7_mloess_loess_predicted { + PyObject *((*setup)(struct __pyx_obj_7_mloess_loess_predicted *,prediction ,long )); +}; +static struct __pyx_vtabstruct_7_mloess_loess_predicted *__pyx_vtabptr_7_mloess_loess_predicted; + + +struct __pyx_obj_7_mloess_loess { + PyObject_HEAD + loess _base; + struct __pyx_obj_7_mloess_loess_inputs *inputs; + struct __pyx_obj_7_mloess_loess_model *model; + struct __pyx_obj_7_mloess_loess_control *control; + struct __pyx_obj_7_mloess_loess_kd_tree *kd_tree; + struct __pyx_obj_7_mloess_loess_outputs *outputs; + struct __pyx_obj_7_mloess_loess_predicted *predicted; + long nobs; + long npar; +}; + + +struct __pyx_obj_7_mloess_anova { + PyObject_HEAD + double dfn; + double dfd; + double F_value; + double Pr_F; +}; + +static PyTypeObject *__pyx_ptype_7_mloess_loess_inputs = 0; +static PyTypeObject *__pyx_ptype_7_mloess_loess_control = 0; +static PyTypeObject *__pyx_ptype_7_mloess_loess_kd_tree = 0; +static PyTypeObject *__pyx_ptype_7_mloess_loess_model = 0; +static PyTypeObject *__pyx_ptype_7_mloess_loess_outputs = 0; +static PyTypeObject *__pyx_ptype_7_mloess_conf_intervals = 0; +static PyTypeObject *__pyx_ptype_7_mloess_loess_predicted = 0; +static PyTypeObject *__pyx_ptype_7_mloess_loess = 0; +static PyTypeObject *__pyx_ptype_7_mloess_anova = 0; +static PyObject *__pyx_k10; +static PyObject *__pyx_k11; +static PyObject *__pyx_k12; +static PyObject *(__pyx_f_7_mloess_floatarray_from_data(int ,int ,double (*))); /*proto*/ +static PyObject *(__pyx_f_7_mloess_boolarray_from_data(int ,int ,int (*))); /*proto*/ + + +/* Implementation of _mloess */ + +static char (__pyx_k1[]) = "A (n,) ndarray of weights to be given to individual observations in the \n sum of squared residuals that forms the local fitting criterion. If not\n None, the weights should be non negative. If the different observations\n have non-equal variances, the weights should be inversely proportional \n to the variances.\n By default, an unweighted fit is carried out (all the weights are one).\n "; +static char (__pyx_k2[]) = "\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n "; +static char (__pyx_k3[]) = "\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n "; +static char (__pyx_k4[]) = "\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n "; +static char (__pyx_k5[]) = "\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n "; +static char (__pyx_k6[]) = "\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n "; +static char (__pyx_k9[]) = "\n \n\n newdata : ndarray\n The (m,p) array of independent variables where the surface must be estimated.\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n residual_scale : float\n Estimate of the scale of the residuals\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n nest : integer\n Number of new observations.\n \n \n"; + +static PyObject *__pyx_n_c_python; +static PyObject *__pyx_n_c_numpy; +static PyObject *__pyx_n_numpy; +static PyObject *__pyx_n_narray; +static PyObject *__pyx_n_float_; +static PyObject *__pyx_n_maskedarray; +static PyObject *__pyx_n_marray; +static PyObject *__pyx_n_getmaskarray; +static PyObject *__pyx_n_c_loess; +static PyObject *__pyx_n_array; +static PyObject *__pyx_n_masked_array; +static PyObject *__pyx_n_False; + +static PyObject *__pyx_n_shape; + +static PyObject *__pyx_f_7_mloess_floatarray_from_data(int __pyx_v_rows,int __pyx_v_cols,double (*__pyx_v_data)) { + PyArrayObject *__pyx_v_a_ndr; + npy_intp __pyx_v_size; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + __pyx_v_a_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":23 */ + __pyx_v_size = (__pyx_v_rows * __pyx_v_cols); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":24 */ + __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_1)); + Py_DECREF(((PyObject *)__pyx_v_a_ndr)); + __pyx_v_a_ndr = ((PyArrayObject *)((PyObject *)__pyx_1)); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":25 */ + __pyx_2 = (__pyx_v_cols > 1); + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":26 */ + __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); + PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3); + __pyx_1 = 0; + __pyx_3 = 0; + if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":27 */ + Py_INCREF(((PyObject *)__pyx_v_a_ndr)); + __pyx_r = ((PyObject *)__pyx_v_a_ndr); + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_mloess.floatarray_from_data"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_a_ndr); + return __pyx_r; +} + +static PyObject *__pyx_n_astype; +static PyObject *__pyx_n_bool; + +static PyObject *__pyx_f_7_mloess_boolarray_from_data(int __pyx_v_rows,int __pyx_v_cols,int (*__pyx_v_data)) { + PyArrayObject *__pyx_v_a_ndr; + npy_intp __pyx_v_size; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + __pyx_v_a_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":32 */ + __pyx_v_size = (__pyx_v_rows * __pyx_v_cols); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":33 */ + __pyx_1 = PyArray_SimpleNewFromData(1,(&__pyx_v_size),NPY_DOUBLE,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_1)); + Py_DECREF(((PyObject *)__pyx_v_a_ndr)); + __pyx_v_a_ndr = ((PyArrayObject *)((PyObject *)__pyx_1)); + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":34 */ + __pyx_2 = (__pyx_v_cols > 1); + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":35 */ + __pyx_1 = PyInt_FromLong(__pyx_v_rows); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + __pyx_3 = PyInt_FromLong(__pyx_v_cols); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); + PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3); + __pyx_1 = 0; + __pyx_3 = 0; + if (PyObject_SetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_shape, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":36 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_a_ndr), __pyx_n_astype); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_bool); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4); + __pyx_4 = 0; + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_mloess.boolarray_from_data"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_a_ndr); + return __pyx_r; +} + +static PyObject *__pyx_n_copy; +static PyObject *__pyx_n_True; +static PyObject *__pyx_n_subok; +static PyObject *__pyx_n_dtype; +static PyObject *__pyx_n_order; +static PyObject *__pyx_n_C; +static PyObject *__pyx_n_ndim; +static PyObject *__pyx_n_mask_or; +static PyObject *__pyx_n_small_mask; +static PyObject *__pyx_n_any; +static PyObject *__pyx_n_axis; +static PyObject *__pyx_n_ValueError; +static PyObject *__pyx_n_len; +static PyObject *__pyx_n_sum; +static PyObject *__pyx_n_logical_not; +static PyObject *__pyx_n_ravel; +static PyObject *__pyx_n_ones; + +static PyObject *__pyx_k26p; + +static char (__pyx_k26[]) = "The array of indepedent varibales should be 2D at most!"; + +static int __pyx_f_7_mloess_12loess_inputs___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_7_mloess_12loess_inputs___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_x_data = 0; + PyObject *__pyx_v_y_data = 0; + PyArrayObject *__pyx_v_unmasked; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + int __pyx_5; + PyObject *__pyx_6 = 0; + static char *__pyx_argnames[] = {"x_data","y_data",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_x_data, &__pyx_v_y_data)) return -1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_x_data); + Py_INCREF(__pyx_v_y_data); + __pyx_v_unmasked = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":92 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_marray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_INCREF(__pyx_v_x_data); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x_data); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_float_); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_dtype, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x)); + ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":93 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_marray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + Py_INCREF(__pyx_v_y_data); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_y_data); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_float_); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_dtype, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->y)); + ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->y = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":95 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x), __pyx_n_ndim); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_2, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;} + __pyx_5 = __pyx_5 == 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__pyx_5) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":96 */ + ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->npar = 1; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":97 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_maskedarray); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_mask_or); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_getmaskarray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x)); + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x)); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_getmaskarray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->y)); + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->y)); + __pyx_6 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_6); + __pyx_3 = 0; + __pyx_6 = 0; + __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_2, __pyx_n_small_mask, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_6 = PyEval_CallObjectWithKeywords(__pyx_4, __pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (!__Pyx_TypeTest(__pyx_6, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->masked)); + ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->masked = ((PyArrayObject *)__pyx_6); + __pyx_6 = 0; + goto __pyx_L2; + } + __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x), __pyx_n_ndim); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L1;} + __pyx_4 = PyInt_FromLong(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_3, __pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L1;} + __pyx_5 = __pyx_5 == 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (__pyx_5) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":101 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x), __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong((-1)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; goto __pyx_L1;} + __pyx_6 = PyObject_GetItem(__pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_5 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->npar = __pyx_5; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":102 */ + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_maskedarray); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_mask_or); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_getmaskarray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x)); + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x)); + __pyx_6 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = PyObject_GetAttr(__pyx_6, __pyx_n_any); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + __pyx_6 = PyInt_FromLong(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_2, __pyx_n_axis, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_6 = PyEval_CallObjectWithKeywords(__pyx_3, __pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_getmaskarray); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->y)); + PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->y)); + __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_6); + PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); + __pyx_6 = 0; + __pyx_2 = 0; + __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + __pyx_6 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_1, __pyx_n_small_mask, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_2 = PyEval_CallObjectWithKeywords(__pyx_4, __pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->masked)); + ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->masked = ((PyArrayObject *)__pyx_2); + __pyx_2 = 0; + goto __pyx_L2; + } + /*else*/ { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":106 */ + __pyx_6 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;} + Py_INCREF(__pyx_k26p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k26p); + __pyx_3 = PyObject_CallObject(__pyx_6, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;} + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":107 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x)); + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x)); + __pyx_6 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_5 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->nobs = __pyx_5; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":108 */ + __pyx_4 = PyInt_FromLong(((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->nobs); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->masked), __pyx_n_sum); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_2 = PyNumber_Subtract(__pyx_4, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_5 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->nobs_eff = __pyx_5; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":110 */ + __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_6, __pyx_n_logical_not); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->masked)); + PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->masked)); + __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_unmasked)); + __pyx_v_unmasked = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":111 */ + __pyx_2 = PyObject_GetItem(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x), ((PyObject *)__pyx_v_unmasked)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_2, __pyx_n_ravel); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = PyObject_CallObject(__pyx_6, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x_eff)); + ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->x_eff = ((PyArrayObject *)__pyx_3); + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":112 */ + __pyx_4 = PyObject_GetItem(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->y), ((PyObject *)__pyx_v_unmasked)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->y_eff)); + ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->y_eff = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":113 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_ones); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_6 = PyInt_FromLong(((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->nobs); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_6); + __pyx_6 = 0; + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} + __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n_float_); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_1, __pyx_n_dtype, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_3 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_4, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->w_ndr)); + ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->w_ndr = ((PyArrayObject *)__pyx_3); + __pyx_3 = 0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_6); + __Pyx_AddTraceback("_mloess.loess_inputs.__init__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_unmasked); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_x_data); + Py_DECREF(__pyx_v_y_data); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_12loess_inputs_7weights___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_12loess_inputs_7weights___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":124 */ + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->w_ndr)); + __pyx_r = ((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->w_ndr); + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_size; +static PyObject *__pyx_n_data; + +static PyObject *__pyx_k31p; + +static char (__pyx_k31[]) = "Invalid size of the 'weights' vector!"; + +static int __pyx_f_7_mloess_12loess_inputs_7weights___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_w); /*proto*/ +static int __pyx_f_7_mloess_12loess_inputs_7weights___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_w) { + PyArrayObject *__pyx_v_w_ndr; + PyArrayObject *__pyx_v_unmasked; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + int __pyx_5; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_w); + __pyx_v_w_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + __pyx_v_unmasked = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":129 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_logical_not); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->masked)); + PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->masked)); + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_unmasked)); + __pyx_v_unmasked = ((PyArrayObject *)__pyx_3); + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":130 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;} + Py_INCREF(__pyx_v_w); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_w); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;} + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_float_); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_dtype, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_w_ndr)); + __pyx_v_w_ndr = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":131 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_ndim); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;} + __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;} + __pyx_5 = __pyx_5 > 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (!__pyx_5) { + __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_w_ndr), __pyx_n_size); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;} + __pyx_4 = PyInt_FromLong(((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->nobs); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_3, __pyx_4, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;} + __pyx_5 = __pyx_5 != 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + } + if (__pyx_5) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":132 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;} + __Pyx_Raise(__pyx_2, __pyx_k31p, 0); + Py_DECREF(__pyx_2); __pyx_2 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":133 */ + Py_INCREF(((PyObject *)__pyx_v_w_ndr)); + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->w_ndr)); + ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->w_ndr = __pyx_v_w_ndr; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":134 */ + __pyx_1 = PyObject_GetItem(((PyObject *)__pyx_v_w_ndr), ((PyObject *)__pyx_v_unmasked)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_data); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_v_self)->_base->weights = ((double (*))__pyx_3); + Py_DECREF(__pyx_3); __pyx_3 = 0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_mloess.loess_inputs.weights.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_w_ndr); + Py_DECREF(__pyx_v_unmasked); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_w); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_control_7surface___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_control_7surface___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":185 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_7_mloess_loess_control *)__pyx_v_self)->_base->surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_control.surface.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_lower; +static PyObject *__pyx_n_interpolate; +static PyObject *__pyx_n_direct; + +static PyObject *__pyx_k34p; +static PyObject *__pyx_k35p; + +static char (__pyx_k34[]) = "Invalid value for the 'surface' argument: "; +static char (__pyx_k35[]) = "should be in ('interpolate', 'direct')."; + +static int __pyx_f_7_mloess_13loess_control_7surface___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_surface); /*proto*/ +static int __pyx_f_7_mloess_13loess_control_7surface___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_surface) { + PyObject *__pyx_v_tmpx; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + PyObject *__pyx_4 = 0; + char (*__pyx_5); + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_surface); + __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":187 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;} + Py_INCREF(__pyx_n_interpolate); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_interpolate); + Py_INCREF(__pyx_n_direct); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_direct); + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;} + __pyx_3 = !__pyx_3; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":188 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;} + __pyx_1 = PyNumber_Add(__pyx_k34p, __pyx_k35p); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1); + __pyx_1 = 0; + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_1, 0, 0); + Py_DECREF(__pyx_1); __pyx_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":190 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_surface, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; goto __pyx_L1;} + __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_tmpx); + __pyx_v_tmpx = __pyx_4; + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":191 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;} + ((struct __pyx_obj_7_mloess_loess_control *)__pyx_v_self)->_base->surface = __pyx_5; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_mloess.loess_control.surface.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_tmpx); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_surface); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_control_10statistics___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_control_10statistics___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":202 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_7_mloess_loess_control *)__pyx_v_self)->_base->statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_control.statistics.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_approximate; +static PyObject *__pyx_n_exact; + +static PyObject *__pyx_k38p; + +static char (__pyx_k38[]) = "Invalid value for the 'statistics' argument: should be in ('approximate', 'exact')."; + +static int __pyx_f_7_mloess_13loess_control_10statistics___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_statistics); /*proto*/ +static int __pyx_f_7_mloess_13loess_control_10statistics___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_statistics) { + PyObject *__pyx_v_tmpx; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + PyObject *__pyx_4 = 0; + char (*__pyx_5); + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_statistics); + __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":204 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;} + Py_INCREF(__pyx_n_approximate); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_approximate); + Py_INCREF(__pyx_n_exact); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_exact); + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; goto __pyx_L1;} + __pyx_3 = !__pyx_3; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":205 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;} + Py_INCREF(__pyx_k38p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k38p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":207 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_statistics, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_tmpx); + __pyx_v_tmpx = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":208 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; goto __pyx_L1;} + ((struct __pyx_obj_7_mloess_loess_control *)__pyx_v_self)->_base->statistics = __pyx_5; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_mloess.loess_control.statistics.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_tmpx); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_statistics); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_control_9trace_hat___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_control_9trace_hat___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":224 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_7_mloess_loess_control *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_control.trace_hat.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k41p; + +static char (__pyx_k41[]) = "Invalid value for the 'trace_hat' argument: should be in ('approximate', 'exact')."; + +static int __pyx_f_7_mloess_13loess_control_9trace_hat___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_trace_hat); /*proto*/ +static int __pyx_f_7_mloess_13loess_control_9trace_hat___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_trace_hat) { + PyObject *__pyx_v_tmpx; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + PyObject *__pyx_4 = 0; + char (*__pyx_5); + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_trace_hat); + __pyx_v_tmpx = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":226 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + Py_INCREF(__pyx_n_approximate); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_approximate); + Py_INCREF(__pyx_n_exact); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_exact); + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} + __pyx_3 = !__pyx_3; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":227 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} + Py_INCREF(__pyx_k41p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k41p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":229 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_trace_hat, __pyx_n_lower); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;} + __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_tmpx); + __pyx_v_tmpx = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":230 */ + __pyx_5 = PyString_AsString(__pyx_v_tmpx); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; goto __pyx_L1;} + ((struct __pyx_obj_7_mloess_loess_control *)__pyx_v_self)->_base->trace_hat = __pyx_5; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_mloess.loess_control.trace_hat.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_tmpx); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_trace_hat); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_control_10iterations___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_control_10iterations___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":239 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_7_mloess_loess_control *)__pyx_v_self)->_base->iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_control.iterations.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k42p; + +static char (__pyx_k42[]) = "Invalid number of iterations: should be positive"; + +static int __pyx_f_7_mloess_13loess_control_10iterations___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_iterations); /*proto*/ +static int __pyx_f_7_mloess_13loess_control_10iterations___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_iterations) { + int __pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_iterations); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":241 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_iterations, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; goto __pyx_L1;} + __pyx_2 = __pyx_2 < 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":242 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;} + Py_INCREF(__pyx_k42p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k42p); + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":243 */ + __pyx_2 = PyInt_AsLong(__pyx_v_iterations); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; goto __pyx_L1;} + ((struct __pyx_obj_7_mloess_loess_control *)__pyx_v_self)->_base->iterations = __pyx_2; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_mloess.loess_control.iterations.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_iterations); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_control_4cell___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_control_4cell___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":255 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_7_mloess_loess_control *)__pyx_v_self)->_base->cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_control.cell.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k43p; + +static char (__pyx_k43[]) = "Invalid value for the cell argument: should be positive"; + +static int __pyx_f_7_mloess_13loess_control_4cell___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_cell); /*proto*/ +static int __pyx_f_7_mloess_13loess_control_4cell___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_cell) { + int __pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + double __pyx_5; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_cell); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":257 */ + __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_cell, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;} + __pyx_2 = __pyx_2 <= 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":258 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} + Py_INCREF(__pyx_k43p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k43p); + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":259 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_cell); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; goto __pyx_L1;} + ((struct __pyx_obj_7_mloess_loess_control *)__pyx_v_self)->_base->cell = __pyx_5; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_mloess.loess_control.cell.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_cell); + return __pyx_r; +} + +static PyObject *__pyx_n_get; +static PyObject *__pyx_n_surface; +static PyObject *__pyx_n_statistics; +static PyObject *__pyx_n_trace_hat; +static PyObject *__pyx_n_iterations; +static PyObject *__pyx_n_cell; +static PyObject *__pyx_n_parametric_flags; + + +static PyObject *__pyx_f_7_mloess_13loess_control_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7_mloess_13loess_control_update[] = "Updates several parameters at once."; +static PyObject *__pyx_f_7_mloess_13loess_control_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_cellargs = 0; + PyObject *__pyx_v_surface; + PyObject *__pyx_v_statistics; + PyObject *__pyx_v_trace_hat; + PyObject *__pyx_v_iterations; + PyObject *__pyx_v_cell; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + int __pyx_4; + static char *__pyx_argnames[] = {0}; + if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, 0, &__pyx_v_cellargs) < 0) return 0; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) { + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + Py_XDECREF(__pyx_v_cellargs); + return 0; + } + Py_INCREF(__pyx_v_self); + __pyx_v_surface = Py_None; Py_INCREF(Py_None); + __pyx_v_statistics = Py_None; Py_INCREF(Py_None); + __pyx_v_trace_hat = Py_None; Py_INCREF(Py_None); + __pyx_v_iterations = Py_None; Py_INCREF(Py_None); + __pyx_v_cell = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":263 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; goto __pyx_L1;} + Py_INCREF(__pyx_n_surface); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_surface); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_surface); + __pyx_v_surface = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":264 */ + __pyx_4 = __pyx_v_surface != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":265 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_surface, __pyx_v_surface) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":267 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + Py_INCREF(__pyx_n_statistics); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_statistics); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_statistics); + __pyx_v_statistics = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":268 */ + __pyx_4 = __pyx_v_statistics != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":269 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_statistics, __pyx_v_statistics) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":271 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; goto __pyx_L1;} + Py_INCREF(__pyx_n_trace_hat); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_trace_hat); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_trace_hat); + __pyx_v_trace_hat = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":272 */ + __pyx_4 = __pyx_v_trace_hat != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":273 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_trace_hat, __pyx_v_trace_hat) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; goto __pyx_L1;} + goto __pyx_L4; + } + __pyx_L4:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":275 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;} + Py_INCREF(__pyx_n_iterations); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_iterations); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_iterations); + __pyx_v_iterations = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":276 */ + __pyx_4 = __pyx_v_iterations != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":277 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_iterations, __pyx_v_iterations) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; goto __pyx_L1;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":279 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_cellargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} + Py_INCREF(__pyx_n_cell); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_cell); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_cell); + __pyx_v_cell = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":280 */ + __pyx_4 = __pyx_v_cell != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":281 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; goto __pyx_L1;} + goto __pyx_L6; + } + __pyx_L6:; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_mloess.loess_control.update"); + __pyx_r = 0; + __pyx_L0:; + Py_XDECREF(__pyx_v_cellargs); + Py_DECREF(__pyx_v_surface); + Py_DECREF(__pyx_v_statistics); + Py_DECREF(__pyx_v_trace_hat); + Py_DECREF(__pyx_v_iterations); + Py_DECREF(__pyx_v_cell); + Py_DECREF(__pyx_v_self); + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + return __pyx_r; +} + +static PyObject *__pyx_n_join; + +static PyObject *__pyx_k49p; +static PyObject *__pyx_k50p; +static PyObject *__pyx_k51p; +static PyObject *__pyx_k52p; +static PyObject *__pyx_k53p; +static PyObject *__pyx_k54p; +static PyObject *__pyx_k55p; + +static char (__pyx_k49[]) = "Control :"; +static char (__pyx_k50[]) = "Surface type : %s"; +static char (__pyx_k51[]) = "Statistics : %s"; +static char (__pyx_k52[]) = "Trace estimation : %s"; +static char (__pyx_k53[]) = "Cell size : %s"; +static char (__pyx_k54[]) = "Nb iterations : %s"; +static char (__pyx_k55[]) = "\n"; + +static PyObject *__pyx_f_7_mloess_13loess_control___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_control___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_strg; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_strg = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":285 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_surface); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k50p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_statistics); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k51p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k52p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_cell); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k53p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_iterations); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + __pyx_6 = PyNumber_Remainder(__pyx_k54p, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyList_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; goto __pyx_L1;} + Py_INCREF(__pyx_k49p); + PyList_SET_ITEM(__pyx_1, 0, __pyx_k49p); + PyList_SET_ITEM(__pyx_1, 1, __pyx_2); + PyList_SET_ITEM(__pyx_1, 2, __pyx_3); + PyList_SET_ITEM(__pyx_1, 3, __pyx_4); + PyList_SET_ITEM(__pyx_1, 4, __pyx_5); + PyList_SET_ITEM(__pyx_1, 5, __pyx_6); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_6 = 0; + Py_DECREF(__pyx_v_strg); + __pyx_v_strg = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":291 */ + __pyx_2 = PyObject_GetAttr(__pyx_k55p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;} + Py_INCREF(__pyx_v_strg); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + __Pyx_AddTraceback("_mloess.loess_control.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_strg); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_11loess_model_setup(struct __pyx_obj_7_mloess_loess_model *__pyx_v_self,loess_model (*__pyx_v_base),long __pyx_v_npar) { + PyObject *__pyx_r; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":346 */ + __pyx_v_self->_base = __pyx_v_base; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":347 */ + __pyx_v_self->npar = __pyx_v_npar; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":348 */ + Py_INCREF(((PyObject *)__pyx_v_self)); + __pyx_r = ((PyObject *)__pyx_v_self); + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_11loess_model_9normalize___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_11loess_model_9normalize___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":352 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_bool); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->_base->normalize); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); + __pyx_2 = 0; + __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_2; + __pyx_2 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_mloess.loess_model.normalize.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static int __pyx_f_7_mloess_11loess_model_9normalize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_normalize); /*proto*/ +static int __pyx_f_7_mloess_11loess_model_9normalize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_normalize) { + int __pyx_r; + int __pyx_1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_normalize); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":354 */ + __pyx_1 = PyInt_AsLong(__pyx_v_normalize); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; goto __pyx_L1;} + ((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->_base->normalize = __pyx_1; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + __Pyx_AddTraceback("_mloess.loess_model.normalize.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_normalize); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_11loess_model_4span___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_11loess_model_4span___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":358 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->_base->span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_model.span.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k56p; + +static char (__pyx_k56[]) = "Span should be between 0 and 1!"; + +static int __pyx_f_7_mloess_11loess_model_4span___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_span); /*proto*/ +static int __pyx_f_7_mloess_11loess_model_4span___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_span) { + int __pyx_r; + int __pyx_1; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + double __pyx_5; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_span); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":360 */ + __pyx_2 = PyFloat_FromDouble(0.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; goto __pyx_L1;} + __pyx_1 = __pyx_1 <= 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (!__pyx_1) { + __pyx_2 = PyFloat_FromDouble(1.); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_span, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; goto __pyx_L1;} + __pyx_1 = __pyx_1 > 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + } + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":361 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;} + Py_INCREF(__pyx_k56p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k56p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":362 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_span); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; goto __pyx_L1;} + ((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->_base->span = __pyx_5; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_mloess.loess_model.span.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_span); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_11loess_model_6degree___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_11loess_model_6degree___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":366 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->_base->degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_model.degree.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k57p; + +static char (__pyx_k57[]) = "Degree should be between 0 and 2!"; + +static int __pyx_f_7_mloess_11loess_model_6degree___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_degree); /*proto*/ +static int __pyx_f_7_mloess_11loess_model_6degree___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_degree) { + int __pyx_r; + int __pyx_1; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_degree); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":368 */ + __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;} + __pyx_1 = __pyx_1 < 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (!__pyx_1) { + __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_degree, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;} + __pyx_1 = __pyx_1 > 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + } + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":369 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;} + Py_INCREF(__pyx_k57p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k57p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":370 */ + __pyx_1 = PyInt_AsLong(__pyx_v_degree); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; goto __pyx_L1;} + ((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->_base->degree = __pyx_1; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_mloess.loess_model.degree.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_degree); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_11loess_model_6family___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_11loess_model_6family___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":374 */ + __pyx_1 = PyString_FromString(((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->_base->family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_model.family.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_symmetric; +static PyObject *__pyx_n_gaussian; + +static PyObject *__pyx_k60p; + +static char (__pyx_k60[]) = "Invalid value for the 'family' argument: should be in ('symmetric', 'gaussian')."; + +static int __pyx_f_7_mloess_11loess_model_6family___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_family); /*proto*/ +static int __pyx_f_7_mloess_11loess_model_6family___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_family) { + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + int __pyx_3; + PyObject *__pyx_4 = 0; + char (*__pyx_5); + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_family); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":376 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_family, __pyx_n_lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} + Py_INCREF(__pyx_n_symmetric); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_symmetric); + Py_INCREF(__pyx_n_gaussian); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_n_gaussian); + __pyx_3 = PySequence_Contains(__pyx_1, __pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;} + __pyx_3 = !__pyx_3; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_3) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":377 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; goto __pyx_L1;} + Py_INCREF(__pyx_k60p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k60p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":379 */ + __pyx_5 = PyString_AsString(__pyx_v_family); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; goto __pyx_L1;} + ((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->_base->family = __pyx_5; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_mloess.loess_model.family.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_family); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_11loess_model_16parametric_flags___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_11loess_model_16parametric_flags___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":383 */ + __pyx_1 = __pyx_f_7_mloess_boolarray_from_data(((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->_base->parametric); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_model.parametric_flags.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_atleast_1d; +static PyObject *__pyx_n_min; + + +static int __pyx_f_7_mloess_11loess_model_16parametric_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_paramf); /*proto*/ +static int __pyx_f_7_mloess_11loess_model_16parametric_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_paramf) { + PyArrayObject *__pyx_v_p_ndr; + int __pyx_v_i; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + long __pyx_7; + int __pyx_8; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_paramf); + __pyx_v_p_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":387 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_atleast_1d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + Py_INCREF(__pyx_v_paramf); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_paramf); + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_bool); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (PyDict_SetItem(__pyx_4, __pyx_n_dtype, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5); + __pyx_5 = 0; + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_6); __pyx_6 = 0; + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_p_ndr)); + __pyx_v_p_ndr = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":389 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;} + __pyx_4 = PyInt_FromLong(((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); + PyTuple_SET_ITEM(__pyx_2, 1, __pyx_5); + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_7 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_7; ++__pyx_v_i) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":390 */ + __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;} + __pyx_4 = PyObject_GetItem(((PyObject *)__pyx_v_p_ndr), __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_8 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + (((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->_base->parametric[__pyx_v_i]) = __pyx_8; + } + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + __Pyx_AddTraceback("_mloess.loess_model.parametric_flags.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_p_ndr); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_paramf); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_11loess_model_17drop_square_flags___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_11loess_model_17drop_square_flags___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":394 */ + __pyx_1 = __pyx_f_7_mloess_boolarray_from_data(((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->npar,1,((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->_base->drop_square); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_model.drop_square_flags.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + + +static int __pyx_f_7_mloess_11loess_model_17drop_square_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_drop_sq); /*proto*/ +static int __pyx_f_7_mloess_11loess_model_17drop_square_flags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_drop_sq) { + PyArrayObject *__pyx_v_d_ndr; + int __pyx_v_i; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + long __pyx_7; + int __pyx_8; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_drop_sq); + __pyx_v_d_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":398 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_atleast_1d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + Py_INCREF(__pyx_v_drop_sq); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_drop_sq); + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_bool); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (PyDict_SetItem(__pyx_4, __pyx_n_dtype, __pyx_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5); + __pyx_5 = 0; + __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_6); __pyx_6 = 0; + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_d_ndr)); + __pyx_v_d_ndr = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":400 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;} + __pyx_4 = PyInt_FromLong(((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;} + __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_d_ndr), __pyx_n_size); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); + PyTuple_SET_ITEM(__pyx_2, 1, __pyx_5); + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_7 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_7; ++__pyx_v_i) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":401 */ + __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;} + __pyx_4 = PyObject_GetItem(((PyObject *)__pyx_v_d_ndr), __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_8 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + (((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->_base->drop_square[__pyx_v_i]) = __pyx_8; + } + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + __Pyx_AddTraceback("_mloess.loess_model.drop_square_flags.__set__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_d_ndr); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_drop_sq); + return __pyx_r; +} + +static PyObject *__pyx_n_family; +static PyObject *__pyx_n_span; +static PyObject *__pyx_n_degree; +static PyObject *__pyx_n_normalize; +static PyObject *__pyx_n_parametric; +static PyObject *__pyx_n_drop_square; +static PyObject *__pyx_n_drop_square_flags; + + +static PyObject *__pyx_f_7_mloess_11loess_model_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_7_mloess_11loess_model_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_modelargs = 0; + PyObject *__pyx_v_family; + PyObject *__pyx_v_span; + PyObject *__pyx_v_degree; + PyObject *__pyx_v_normalize; + PyObject *__pyx_v_parametric; + PyObject *__pyx_v_drop_square; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + int __pyx_4; + static char *__pyx_argnames[] = {0}; + if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, 0, &__pyx_v_modelargs) < 0) return 0; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) { + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + Py_XDECREF(__pyx_v_modelargs); + return 0; + } + Py_INCREF(__pyx_v_self); + __pyx_v_family = Py_None; Py_INCREF(Py_None); + __pyx_v_span = Py_None; Py_INCREF(Py_None); + __pyx_v_degree = Py_None; Py_INCREF(Py_None); + __pyx_v_normalize = Py_None; Py_INCREF(Py_None); + __pyx_v_parametric = Py_None; Py_INCREF(Py_None); + __pyx_v_drop_square = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":404 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; goto __pyx_L1;} + Py_INCREF(__pyx_n_family); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_family); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_family); + __pyx_v_family = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":405 */ + __pyx_4 = __pyx_v_family != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":406 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_family, __pyx_v_family) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":408 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;} + Py_INCREF(__pyx_n_span); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_span); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_span); + __pyx_v_span = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":409 */ + __pyx_4 = __pyx_v_span != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":410 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_span, __pyx_v_span) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":412 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; goto __pyx_L1;} + Py_INCREF(__pyx_n_degree); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_degree); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_degree); + __pyx_v_degree = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":413 */ + __pyx_4 = __pyx_v_degree != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":414 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_degree, __pyx_v_degree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; goto __pyx_L1;} + goto __pyx_L4; + } + __pyx_L4:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":416 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; goto __pyx_L1;} + Py_INCREF(__pyx_n_normalize); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_normalize); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_normalize); + __pyx_v_normalize = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":417 */ + __pyx_4 = __pyx_v_normalize != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":418 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_normalize, __pyx_v_normalize) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; goto __pyx_L1;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":420 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; goto __pyx_L1;} + Py_INCREF(__pyx_n_parametric); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_parametric); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_parametric); + __pyx_v_parametric = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":421 */ + __pyx_4 = __pyx_v_parametric != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":422 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_parametric_flags, __pyx_v_parametric) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":424 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_modelargs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; goto __pyx_L1;} + __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; goto __pyx_L1;} + Py_INCREF(__pyx_n_drop_square); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_drop_square); + Py_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_2, 1, Py_None); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_v_drop_square); + __pyx_v_drop_square = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":425 */ + __pyx_4 = __pyx_v_drop_square != Py_None; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":426 */ + if (PyObject_SetAttr(__pyx_v_self, __pyx_n_drop_square_flags, __pyx_v_drop_square) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; goto __pyx_L1;} + goto __pyx_L7; + } + __pyx_L7:; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_mloess.loess_model.update"); + __pyx_r = 0; + __pyx_L0:; + Py_XDECREF(__pyx_v_modelargs); + Py_DECREF(__pyx_v_family); + Py_DECREF(__pyx_v_span); + Py_DECREF(__pyx_v_degree); + Py_DECREF(__pyx_v_normalize); + Py_DECREF(__pyx_v_parametric); + Py_DECREF(__pyx_v_drop_square); + Py_DECREF(__pyx_v_self); + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + return __pyx_r; +} + +static PyObject *__pyx_k73p; + +static char (__pyx_k73[]) = ""; + +static PyObject *__pyx_f_7_mloess_11loess_model___repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_11loess_model___repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":429 */ + Py_INCREF(__pyx_k73p); + __pyx_r = __pyx_k73p; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k74p; +static PyObject *__pyx_k75p; +static PyObject *__pyx_k76p; +static PyObject *__pyx_k77p; +static PyObject *__pyx_k78p; +static PyObject *__pyx_k79p; +static PyObject *__pyx_k80p; +static PyObject *__pyx_k81p; + +static char (__pyx_k74[]) = "Model parameters....."; +static char (__pyx_k75[]) = "Family : %s"; +static char (__pyx_k76[]) = "Span : %s"; +static char (__pyx_k77[]) = "Degree : %s"; +static char (__pyx_k78[]) = "Normalized : %s"; +static char (__pyx_k79[]) = "Parametric : %s"; +static char (__pyx_k80[]) = "Drop_square : %s"; +static char (__pyx_k81[]) = "\n"; + +static PyObject *__pyx_f_7_mloess_11loess_model___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_11loess_model___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_strg; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + PyObject *__pyx_7 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_strg = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":432 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k75p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_span); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k76p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_degree); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k77p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_normalize); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k78p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_parametric_flags); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + __pyx_6 = PySequence_GetSlice(__pyx_1, 0, ((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyNumber_Remainder(__pyx_k79p, __pyx_6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_drop_square_flags); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;} + __pyx_7 = PySequence_GetSlice(__pyx_6, 0, ((struct __pyx_obj_7_mloess_loess_model *)__pyx_v_self)->npar); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_6 = PyNumber_Remainder(__pyx_k80p, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;} + Py_DECREF(__pyx_7); __pyx_7 = 0; + __pyx_7 = PyList_New(7); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; goto __pyx_L1;} + Py_INCREF(__pyx_k74p); + PyList_SET_ITEM(__pyx_7, 0, __pyx_k74p); + PyList_SET_ITEM(__pyx_7, 1, __pyx_2); + PyList_SET_ITEM(__pyx_7, 2, __pyx_3); + PyList_SET_ITEM(__pyx_7, 3, __pyx_4); + PyList_SET_ITEM(__pyx_7, 4, __pyx_5); + PyList_SET_ITEM(__pyx_7, 5, __pyx_1); + PyList_SET_ITEM(__pyx_7, 6, __pyx_6); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_1 = 0; + __pyx_6 = 0; + Py_DECREF(__pyx_v_strg); + __pyx_v_strg = __pyx_7; + __pyx_7 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":440 */ + __pyx_2 = PyObject_GetAttr(__pyx_k81p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; goto __pyx_L1;} + Py_INCREF(__pyx_v_strg); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + Py_XDECREF(__pyx_7); + __Pyx_AddTraceback("_mloess.loess_model.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_strg); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_outputs_setup(struct __pyx_obj_7_mloess_loess_outputs *__pyx_v_self,loess_outputs (*__pyx_v_base),long __pyx_v_nobs,long __pyx_v_nobs_eff,long __pyx_v_npar,PyArrayObject *__pyx_v_mask) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + int __pyx_4; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_mask); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":482 */ + __pyx_v_self->_base = __pyx_v_base; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":483 */ + __pyx_v_self->nobs = __pyx_v_nobs; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":484 */ + __pyx_v_self->nobs_eff = __pyx_v_nobs_eff; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":485 */ + __pyx_v_self->npar = __pyx_v_npar; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":486 */ + Py_INCREF(((PyObject *)__pyx_v_mask)); + Py_DECREF(((PyObject *)__pyx_v_self->masked)); + __pyx_v_self->masked = __pyx_v_mask; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":487 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_logical_not); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_v_mask)); + PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_mask)); + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_self->unmasked)); + __pyx_v_self->unmasked = ((PyArrayObject *)__pyx_3); + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":488 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; goto __pyx_L1;} + __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_v_self->activated = __pyx_4; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":489 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_mask), __pyx_n_any); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; goto __pyx_L1;} + __pyx_3 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_v_self->ismasked = __pyx_4; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_mloess.loess_outputs.setup"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_mask); + return __pyx_r; +} + +static PyObject *__pyx_n_empty; +static PyObject *__pyx_n_mask; +static PyObject *__pyx_n_flat; + + +static PyArrayObject *__pyx_f_7_mloess_13loess_outputs_getoutput(struct __pyx_obj_7_mloess_loess_outputs *__pyx_v_self,double (*__pyx_v_data)) { + PyArrayObject *__pyx_v_out_ndr; + PyArrayObject *__pyx_v_tmp_ndr; + PyArrayObject *__pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_out_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + __pyx_v_tmp_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":493 */ + __pyx_1 = __pyx_f_7_mloess_floatarray_from_data(__pyx_v_self->nobs_eff,1,__pyx_v_data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_tmp_ndr)); + __pyx_v_tmp_ndr = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":494 */ + __pyx_2 = (!__pyx_v_self->ismasked); + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":495 */ + Py_INCREF(((PyObject *)__pyx_v_tmp_ndr)); + __pyx_r = __pyx_v_tmp_ndr; + goto __pyx_L0; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":496 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_marray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_empty); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_3 = PyInt_FromLong(__pyx_v_self->nobs); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3); + __pyx_3 = 0; + __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_float_); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5); + PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3); + __pyx_5 = 0; + __pyx_3 = 0; + __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5); + __pyx_5 = 0; + __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_4, __pyx_n_mask, ((PyObject *)__pyx_v_self->masked)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + __pyx_6 = PyEval_CallObjectWithKeywords(__pyx_1, __pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + if (!__Pyx_TypeTest(__pyx_6, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_out_ndr)); + __pyx_v_out_ndr = ((PyArrayObject *)__pyx_6); + __pyx_6 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":497 */ + __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_tmp_ndr), __pyx_n_flat); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; goto __pyx_L1;} + if (PyObject_SetItem(((PyObject *)__pyx_v_out_ndr), ((PyObject *)__pyx_v_self->unmasked), __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":498 */ + Py_INCREF(((PyObject *)__pyx_v_out_ndr)); + __pyx_r = __pyx_v_out_ndr; + goto __pyx_L0; + + __pyx_r = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + __Pyx_AddTraceback("_mloess.loess_outputs.getoutput"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_out_ndr); + Py_DECREF(__pyx_v_tmp_ndr); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_outputs_13fitted_values___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_outputs_13fitted_values___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":502 */ + __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_7_mloess_loess_outputs *)((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->__pyx_vtab)->getoutput(((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self),((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->_base->fitted_values)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_outputs.fitted_values.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_outputs_16fitted_residuals___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_outputs_16fitted_residuals___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":506 */ + __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_7_mloess_loess_outputs *)((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->__pyx_vtab)->getoutput(((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self),((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->_base->fitted_residuals)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_outputs.fitted_residuals.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_outputs_12pseudovalues___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_outputs_12pseudovalues___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":510 */ + __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_7_mloess_loess_outputs *)((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->__pyx_vtab)->getoutput(((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self),((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->_base->pseudovalues)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_outputs.pseudovalues.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_outputs_8diagonal___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_outputs_8diagonal___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":514 */ + __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_7_mloess_loess_outputs *)((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->__pyx_vtab)->getoutput(((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self),((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->_base->diagonal)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_outputs.diagonal.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_outputs_6robust___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_outputs_6robust___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":518 */ + __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_7_mloess_loess_outputs *)((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->__pyx_vtab)->getoutput(((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self),((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->_base->robust)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_outputs.robust.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_outputs_7divisor___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_outputs_7divisor___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":522 */ + __pyx_1 = __pyx_f_7_mloess_floatarray_from_data(((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->npar,1,((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->_base->divisor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_outputs.divisor.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_outputs_3enp___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_outputs_3enp___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":526 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->_base->enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_outputs.enp.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_outputs_1s___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_outputs_1s___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":530 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->_base->s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_outputs.s.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_outputs_9one_delta___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_outputs_9one_delta___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":534 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->_base->one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_outputs.one_delta.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_outputs_9two_delta___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_outputs_9two_delta___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":538 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->_base->two_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_outputs.two_delta.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_13loess_outputs_9trace_hat___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_outputs_9trace_hat___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":542 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_v_self)->_base->trace_hat); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_outputs.trace_hat.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_fitted_values; +static PyObject *__pyx_n_fitted_residuals; +static PyObject *__pyx_n_enp; +static PyObject *__pyx_n_s; +static PyObject *__pyx_n_one_delta; +static PyObject *__pyx_n_two_delta; +static PyObject *__pyx_n_divisor; + +static PyObject *__pyx_k83p; +static PyObject *__pyx_k84p; +static PyObject *__pyx_k85p; +static PyObject *__pyx_k86p; +static PyObject *__pyx_k87p; +static PyObject *__pyx_k88p; +static PyObject *__pyx_k89p; +static PyObject *__pyx_k90p; + +static char (__pyx_k83[]) = "Outputs................"; +static char (__pyx_k84[]) = "Fitted values : %s\n"; +static char (__pyx_k85[]) = "Fitted residuals : %s\n"; +static char (__pyx_k86[]) = "Eqv. nb of parameters : %s"; +static char (__pyx_k87[]) = "Residual error : %s"; +static char (__pyx_k88[]) = "Deltas : %s - %s"; +static char (__pyx_k89[]) = "Normalization factors : %s"; +static char (__pyx_k90[]) = "\n"; + +static PyObject *__pyx_f_7_mloess_13loess_outputs___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_13loess_outputs___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_strg; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + PyObject *__pyx_6 = 0; + PyObject *__pyx_7 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_strg = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":545 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k84p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_fitted_residuals); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k85p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_enp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k86p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k87p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_one_delta); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; goto __pyx_L1;} + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_two_delta); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; goto __pyx_L1;} + __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1); + PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6); + __pyx_1 = 0; + __pyx_6 = 0; + __pyx_1 = PyNumber_Remainder(__pyx_k88p, __pyx_7); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; goto __pyx_L1;} + Py_DECREF(__pyx_7); __pyx_7 = 0; + __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_divisor); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; goto __pyx_L1;} + __pyx_7 = PyNumber_Remainder(__pyx_k89p, __pyx_6); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_6 = PyList_New(7); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; goto __pyx_L1;} + Py_INCREF(__pyx_k83p); + PyList_SET_ITEM(__pyx_6, 0, __pyx_k83p); + PyList_SET_ITEM(__pyx_6, 1, __pyx_2); + PyList_SET_ITEM(__pyx_6, 2, __pyx_3); + PyList_SET_ITEM(__pyx_6, 3, __pyx_4); + PyList_SET_ITEM(__pyx_6, 4, __pyx_5); + PyList_SET_ITEM(__pyx_6, 5, __pyx_1); + PyList_SET_ITEM(__pyx_6, 6, __pyx_7); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + __pyx_1 = 0; + __pyx_7 = 0; + Py_DECREF(__pyx_v_strg); + __pyx_v_strg = __pyx_6; + __pyx_6 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":552 */ + __pyx_2 = PyObject_GetAttr(__pyx_k90p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;} + Py_INCREF(__pyx_v_strg); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + Py_XDECREF(__pyx_6); + Py_XDECREF(__pyx_7); + __Pyx_AddTraceback("_mloess.loess_outputs.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_strg); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static void __pyx_f_7_mloess_14conf_intervals___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_f_7_mloess_14conf_intervals___dealloc__(PyObject *__pyx_v_self) { + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":574 */ + pw_free_mem((&((struct __pyx_obj_7_mloess_conf_intervals *)__pyx_v_self)->_base)); + + Py_DECREF(__pyx_v_self); +} + +static PyObject *__pyx_f_7_mloess_14conf_intervals_setup(struct __pyx_obj_7_mloess_conf_intervals *__pyx_v_self,conf_inv __pyx_v_base,long __pyx_v_nest) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":577 */ + __pyx_v_self->_base = __pyx_v_base; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":578 */ + __pyx_1 = __pyx_f_7_mloess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_self->fit)); + __pyx_v_self->fit = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":579 */ + __pyx_1 = __pyx_f_7_mloess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.upper); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_self->upper)); + __pyx_v_self->upper = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":580 */ + __pyx_1 = __pyx_f_7_mloess_floatarray_from_data(__pyx_v_nest,1,__pyx_v_base.lower); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_self->lower)); + __pyx_v_self->lower = ((PyArrayObject *)__pyx_1); + __pyx_1 = 0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.conf_intervals.setup"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_r_; +static PyObject *__pyx_n_T; + +static PyObject *__pyx_k91p; + +static char (__pyx_k91[]) = "Confidence intervals....\nLower b./ fit / upper b.\n%s"; + +static PyObject *__pyx_f_7_mloess_14conf_intervals___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_14conf_intervals___str__(PyObject *__pyx_v_self) { + PyArrayObject *__pyx_v_tmp_ndr; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_tmp_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":584 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_r_); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyList_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_conf_intervals *)__pyx_v_self)->lower)); + PyList_SET_ITEM(__pyx_1, 0, ((PyObject *)((struct __pyx_obj_7_mloess_conf_intervals *)__pyx_v_self)->lower)); + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_conf_intervals *)__pyx_v_self)->fit)); + PyList_SET_ITEM(__pyx_1, 1, ((PyObject *)((struct __pyx_obj_7_mloess_conf_intervals *)__pyx_v_self)->fit)); + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_conf_intervals *)__pyx_v_self)->upper)); + PyList_SET_ITEM(__pyx_1, 2, ((PyObject *)((struct __pyx_obj_7_mloess_conf_intervals *)__pyx_v_self)->upper)); + __pyx_3 = PyObject_GetItem(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_T); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_tmp_ndr)); + __pyx_v_tmp_ndr = ((PyArrayObject *)__pyx_2); + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":585 */ + __pyx_1 = PyNumber_Remainder(__pyx_k91p, ((PyObject *)__pyx_v_tmp_ndr)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_mloess.conf_intervals.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_tmp_ndr); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static void __pyx_f_7_mloess_15loess_predicted___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_f_7_mloess_15loess_predicted___dealloc__(PyObject *__pyx_v_self) { + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":614 */ + pred_free_mem((&((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->_base)); + + Py_DECREF(__pyx_v_self); +} + +static PyObject *__pyx_f_7_mloess_15loess_predicted_setup(struct __pyx_obj_7_mloess_loess_predicted *__pyx_v_self,prediction __pyx_v_base,long __pyx_v_nest) { + PyObject *__pyx_r; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":617 */ + __pyx_v_self->_base = __pyx_v_base; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":618 */ + __pyx_v_self->nest = __pyx_v_nest; + + __pyx_r = Py_None; Py_INCREF(Py_None); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_15loess_predicted_6values___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_15loess_predicted_6values___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":622 */ + __pyx_1 = __pyx_f_7_mloess_floatarray_from_data(((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->_base.fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_predicted.values.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_15loess_predicted_6stderr___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_15loess_predicted_6stderr___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":626 */ + __pyx_1 = __pyx_f_7_mloess_floatarray_from_data(((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->nest,1,((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->_base.se_fit); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_predicted.stderr.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_15loess_predicted_14residual_scale___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_15loess_predicted_14residual_scale___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":630 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->_base.residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_predicted.residual_scale.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_15loess_predicted_2df___get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_15loess_predicted_2df___get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":634 */ + __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->_base.df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_mloess.loess_predicted.df.__get__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k92p; + +static char (__pyx_k92[]) = "The coverage precentage should be between 0 and 1!"; + +static PyObject *__pyx_f_7_mloess_15loess_predicted_confidence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7_mloess_15loess_predicted_confidence[] = "Returns the pointwise confidence intervals for each predicted values,\nat the given confidence interval coverage.\n \n:Parameters:\n coverage : float\n Confidence level of the confidence intervals limits, as a fraction.\n \n:Returns:\n A new conf_intervals object, consisting of:\n fit : ndarray\n Predicted values.\n lower : ndarray\n Lower bounds of the confidence intervals.\n upper : ndarray\n Upper bounds of the confidence intervals.\n "; +static PyObject *__pyx_f_7_mloess_15loess_predicted_confidence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_coverage = 0; + conf_inv __pyx_v__confintv; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + double __pyx_5; + static char *__pyx_argnames[] = {"coverage",0}; + __pyx_v_coverage = __pyx_k10; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_coverage)) return 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_coverage); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":654 */ + __pyx_1 = PyFloat_FromDouble(0.5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; goto __pyx_L1;} + __pyx_2 = __pyx_2 < 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":655 */ + __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; goto __pyx_L1;} + __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_v_coverage); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_v_coverage); + __pyx_v_coverage = __pyx_3; + __pyx_3 = 0; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":656 */ + __pyx_1 = PyFloat_FromDouble(1.); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_v_coverage, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; goto __pyx_L1;} + __pyx_2 = __pyx_2 > 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":657 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; goto __pyx_L1;} + __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; goto __pyx_L1;} + Py_INCREF(__pyx_k92p); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k92p); + __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":658 */ + __pyx_5 = PyFloat_AsDouble(__pyx_v_coverage); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; goto __pyx_L1;} + pointwise((&((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->_base),((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->nest,__pyx_5,(&__pyx_v__confintv)); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":659 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_7_mloess_conf_intervals), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_7_mloess_conf_intervals)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->confidence_intervals)); + ((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->confidence_intervals = ((struct __pyx_obj_7_mloess_conf_intervals *)__pyx_3); + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":660 */ + __pyx_1 = ((struct __pyx_vtabstruct_7_mloess_conf_intervals *)((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->confidence_intervals->__pyx_vtab)->setup(((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->confidence_intervals,__pyx_v__confintv,((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->nest); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":661 */ + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->confidence_intervals)); + __pyx_r = ((PyObject *)((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_v_self)->confidence_intervals); + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_mloess.loess_predicted.confidence"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_coverage); + return __pyx_r; +} + +static PyObject *__pyx_n_values; +static PyObject *__pyx_n_stderr; +static PyObject *__pyx_n_residual_scale; +static PyObject *__pyx_n_df; + +static PyObject *__pyx_k93p; +static PyObject *__pyx_k94p; +static PyObject *__pyx_k95p; +static PyObject *__pyx_k96p; +static PyObject *__pyx_k97p; +static PyObject *__pyx_k98p; + +static char (__pyx_k93[]) = "Outputs................"; +static char (__pyx_k94[]) = "Predicted values : %s\n"; +static char (__pyx_k95[]) = "Predicted std error : %s\n"; +static char (__pyx_k96[]) = "Residual scale : %s"; +static char (__pyx_k97[]) = "Degrees of freedom : %s"; +static char (__pyx_k98[]) = "\n"; + +static PyObject *__pyx_f_7_mloess_15loess_predicted___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_f_7_mloess_15loess_predicted___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_v_strg; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + Py_INCREF(__pyx_v_self); + __pyx_v_strg = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":664 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_values); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k94p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_stderr); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k95p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_residual_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; goto __pyx_L1;} + __pyx_4 = PyNumber_Remainder(__pyx_k96p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_df); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; goto __pyx_L1;} + __pyx_5 = PyNumber_Remainder(__pyx_k97p, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyList_New(5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; goto __pyx_L1;} + Py_INCREF(__pyx_k93p); + PyList_SET_ITEM(__pyx_1, 0, __pyx_k93p); + PyList_SET_ITEM(__pyx_1, 1, __pyx_2); + PyList_SET_ITEM(__pyx_1, 2, __pyx_3); + PyList_SET_ITEM(__pyx_1, 3, __pyx_4); + PyList_SET_ITEM(__pyx_1, 4, __pyx_5); + __pyx_2 = 0; + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + Py_DECREF(__pyx_v_strg); + __pyx_v_strg = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":671 */ + __pyx_2 = PyObject_GetAttr(__pyx_k98p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; goto __pyx_L1;} + Py_INCREF(__pyx_v_strg); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_strg); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("_mloess.loess_predicted.__str__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_strg); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_iteritems; +static PyObject *__pyx_n_update; + + +static int __pyx_f_7_mloess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_7_mloess_5loess___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_x = 0; + PyObject *__pyx_v_y = 0; + PyObject *__pyx_v_weights = 0; + PyObject *__pyx_v_options = 0; + double (*__pyx_v_x_dat); + double (*__pyx_v_y_dat); + PyObject *__pyx_v_n; + PyObject *__pyx_v_p; + PyObject *__pyx_v_modelopt; + PyObject *__pyx_v_controlopt; + PyObject *__pyx_v_k; + PyObject *__pyx_v_v; + int __pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + long __pyx_3; + long __pyx_4; + PyObject *__pyx_5 = 0; + int __pyx_6; + static char *__pyx_argnames[] = {"x","y","weights",0}; + __pyx_v_weights = __pyx_k11; + if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 3, 0, &__pyx_v_options) < 0) return -1; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_weights)) { + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + Py_XDECREF(__pyx_v_options); + return -1; + } + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_x); + Py_INCREF(__pyx_v_y); + Py_INCREF(__pyx_v_weights); + __pyx_v_n = Py_None; Py_INCREF(Py_None); + __pyx_v_p = Py_None; Py_INCREF(Py_None); + __pyx_v_modelopt = Py_None; Py_INCREF(Py_None); + __pyx_v_controlopt = Py_None; Py_INCREF(Py_None); + __pyx_v_k = Py_None; Py_INCREF(Py_None); + __pyx_v_v = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":792 */ + __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; goto __pyx_L1;} + Py_INCREF(__pyx_v_x); + PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_x); + Py_INCREF(__pyx_v_y); + PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_y); + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_7_mloess_loess_inputs), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_7_mloess_loess_inputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->inputs)); + ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->inputs = ((struct __pyx_obj_7_mloess_loess_inputs *)__pyx_2); + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":793 */ + __pyx_v_x_dat = ((double (*))((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->inputs->x_eff->data); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":794 */ + __pyx_v_y_dat = ((double (*))((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->inputs->y_eff->data); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":795 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->inputs->nobs_eff); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; goto __pyx_L1;} + Py_DECREF(__pyx_v_n); + __pyx_v_n = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":796 */ + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->inputs->npar); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; goto __pyx_L1;} + Py_DECREF(__pyx_v_p); + __pyx_v_p = __pyx_2; + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":797 */ + __pyx_3 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;} + __pyx_4 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; goto __pyx_L1;} + loess_setup(__pyx_v_x_dat,__pyx_v_y_dat,__pyx_3,__pyx_4,(&((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base)); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":799 */ + ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->inputs->_base = (&((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base.inputs); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":801 */ + __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_7_mloess_loess_model), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7_mloess_loess_model)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->model)); + ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->model = ((struct __pyx_obj_7_mloess_loess_model *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":802 */ + __pyx_3 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;} + __pyx_2 = ((struct __pyx_vtabstruct_7_mloess_loess_model *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->model->__pyx_vtab)->setup(((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->model,(&((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base.model),__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":804 */ + __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_7_mloess_loess_control), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7_mloess_loess_control)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->control)); + ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->control = ((struct __pyx_obj_7_mloess_loess_control *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":805 */ + ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->control->_base = (&((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base.control); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":807 */ + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_7_mloess_loess_kd_tree), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_7_mloess_loess_kd_tree)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->kd_tree)); + ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->kd_tree = ((struct __pyx_obj_7_mloess_loess_kd_tree *)__pyx_2); + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":808 */ + ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->kd_tree->_base = (&((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base.kd_tree); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":810 */ + __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_7_mloess_loess_outputs), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7_mloess_loess_outputs)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->outputs)); + ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->outputs = ((struct __pyx_obj_7_mloess_loess_outputs *)__pyx_1); + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":811 */ + __pyx_4 = PyInt_AsLong(__pyx_v_n); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;} + __pyx_3 = PyInt_AsLong(__pyx_v_p); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;} + __pyx_2 = ((struct __pyx_vtabstruct_7_mloess_loess_outputs *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->outputs->__pyx_vtab)->setup(((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->outputs,(&((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base.outputs),((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->inputs->nobs,__pyx_4,__pyx_3,((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->inputs->masked); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":814 */ + __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;} + Py_DECREF(__pyx_v_modelopt); + __pyx_v_modelopt = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":815 */ + __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;} + Py_DECREF(__pyx_v_controlopt); + __pyx_v_controlopt = __pyx_2; + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":816 */ + __pyx_1 = PyObject_GetAttr(__pyx_v_options, __pyx_n_iteritems); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetIter(__pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + for (;;) { + __pyx_2 = PyIter_Next(__pyx_1); + if (!__pyx_2) { + if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + break; + } + __pyx_5 = PyObject_GetIter(__pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_2 = __Pyx_UnpackItem(__pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + Py_DECREF(__pyx_v_k); + __pyx_v_k = __pyx_2; + __pyx_2 = 0; + __pyx_2 = __Pyx_UnpackItem(__pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + Py_DECREF(__pyx_v_v); + __pyx_v_v = __pyx_2; + __pyx_2 = 0; + if (__Pyx_EndUnpack(__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":817 */ + __pyx_2 = PyTuple_New(6); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + Py_INCREF(__pyx_n_family); + PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_family); + Py_INCREF(__pyx_n_span); + PyTuple_SET_ITEM(__pyx_2, 1, __pyx_n_span); + Py_INCREF(__pyx_n_degree); + PyTuple_SET_ITEM(__pyx_2, 2, __pyx_n_degree); + Py_INCREF(__pyx_n_normalize); + PyTuple_SET_ITEM(__pyx_2, 3, __pyx_n_normalize); + Py_INCREF(__pyx_n_parametric); + PyTuple_SET_ITEM(__pyx_2, 4, __pyx_n_parametric); + Py_INCREF(__pyx_n_drop_square); + PyTuple_SET_ITEM(__pyx_2, 5, __pyx_n_drop_square); + __pyx_6 = PySequence_Contains(__pyx_2, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__pyx_6) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":819 */ + if (PyObject_SetItem(__pyx_v_modelopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;} + goto __pyx_L4; + } + __pyx_5 = PyTuple_New(5); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; goto __pyx_L1;} + Py_INCREF(__pyx_n_surface); + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_n_surface); + Py_INCREF(__pyx_n_statistics); + PyTuple_SET_ITEM(__pyx_5, 1, __pyx_n_statistics); + Py_INCREF(__pyx_n_trace_hat); + PyTuple_SET_ITEM(__pyx_5, 2, __pyx_n_trace_hat); + Py_INCREF(__pyx_n_iterations); + PyTuple_SET_ITEM(__pyx_5, 3, __pyx_n_iterations); + Py_INCREF(__pyx_n_cell); + PyTuple_SET_ITEM(__pyx_5, 4, __pyx_n_cell); + __pyx_6 = PySequence_Contains(__pyx_5, __pyx_v_k); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (__pyx_6) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":822 */ + if (PyObject_SetItem(__pyx_v_controlopt, __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;} + goto __pyx_L4; + } + __pyx_L4:; + } + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":823 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->control), __pyx_n_update); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + __pyx_1 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_5, __pyx_v_controlopt); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":824 */ + __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->model), __pyx_n_update); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; goto __pyx_L1;} + __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; goto __pyx_L1;} + __pyx_1 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_5, __pyx_v_modelopt); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("_mloess.loess.__init__"); + __pyx_r = -1; + __pyx_L0:; + Py_XDECREF(__pyx_v_options); + Py_DECREF(__pyx_v_n); + Py_DECREF(__pyx_v_p); + Py_DECREF(__pyx_v_modelopt); + Py_DECREF(__pyx_v_controlopt); + Py_DECREF(__pyx_v_k); + Py_DECREF(__pyx_v_v); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_x); + Py_DECREF(__pyx_v_y); + Py_DECREF(__pyx_v_weights); + Py_XDECREF(__pyx_args); + Py_XDECREF(__pyx_kwds); + return __pyx_r; +} + +static PyObject *__pyx_f_7_mloess_5loess_fit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7_mloess_5loess_fit[] = "Computes the loess parameters on the current inputs and sets of parameters."; +static PyObject *__pyx_f_7_mloess_5loess_fit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + int __pyx_2; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + static char *__pyx_argnames[] = {0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":828 */ + loess_fit((&((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base)); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":829 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; goto __pyx_L1;} + __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->outputs->activated = __pyx_2; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":830 */ + __pyx_2 = ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base.status.err_status; + if (__pyx_2) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":831 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;} + __pyx_3 = PyString_FromString(((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":832 */ + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_mloess.loess.fit"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_str; + +static PyObject *__pyx_k110p; + +static char (__pyx_k110[]) = "\n"; + +static PyObject *__pyx_f_7_mloess_5loess_inputs_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7_mloess_5loess_inputs_summary[] = "Returns some generic information about the loess parameters.\n "; +static PyObject *__pyx_f_7_mloess_5loess_inputs_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_toprint; + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + static char *__pyx_argnames[] = {0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; + Py_INCREF(__pyx_v_self); + __pyx_v_toprint = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":837 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_str); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->inputs)); + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->inputs)); + __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_str); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->model)); + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->model)); + __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_str); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; goto __pyx_L1;} + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->control)); + PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->control)); + __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_1 = PyList_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; goto __pyx_L1;} + PyList_SET_ITEM(__pyx_1, 0, __pyx_3); + PyList_SET_ITEM(__pyx_1, 1, __pyx_4); + PyList_SET_ITEM(__pyx_1, 2, __pyx_5); + __pyx_3 = 0; + __pyx_4 = 0; + __pyx_5 = 0; + Py_DECREF(__pyx_v_toprint); + __pyx_v_toprint = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":838 */ + __pyx_2 = PyObject_GetAttr(__pyx_k110p, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + Py_INCREF(__pyx_v_toprint); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_toprint); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_r = __pyx_4; + __pyx_4 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("_mloess.loess.inputs_summary"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_toprint); + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_k111p; +static PyObject *__pyx_k112p; +static PyObject *__pyx_k113p; +static PyObject *__pyx_k115p; +static PyObject *__pyx_k116p; + +static char (__pyx_k111[]) = "Number of Observations : %d"; +static char (__pyx_k112[]) = "Fit flag : %d"; +static char (__pyx_k113[]) = "Equivalent Number of Parameters: %.1f"; +static char (__pyx_k115[]) = "Residual Standard Error : %.4f"; +static char (__pyx_k116[]) = "Residual Scale Estimate : %.4f"; + +static PyObject *__pyx_f_7_mloess_5loess_outputs_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7_mloess_5loess_outputs_summary[] = "Returns some generic information about the loess fit."; +static PyObject *__pyx_f_7_mloess_5loess_outputs_summary(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + int __pyx_4; + static char *__pyx_argnames[] = {0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":842 */ + __pyx_1 = PyInt_FromLong(((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->inputs->nobs); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k111p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":843 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_bool); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->outputs->activated); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); + __pyx_2 = 0; + __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_1 = PyNumber_Remainder(__pyx_k112p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":844 */ + __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->outputs), __pyx_n_enp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k113p, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":845 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->model), __pyx_n_family); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_1, __pyx_n_gaussian, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; goto __pyx_L1;} + __pyx_4 = __pyx_4 == 0; + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__pyx_4) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":846 */ + __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; goto __pyx_L1;} + __pyx_2 = PyNumber_Remainder(__pyx_k115p, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; goto __pyx_L1;} + goto __pyx_L2; + } + /*else*/ { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":848 */ + __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->outputs), __pyx_n_s); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; goto __pyx_L1;} + __pyx_3 = PyNumber_Remainder(__pyx_k116p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; goto __pyx_L1;} + } + __pyx_L2:; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_mloess.loess.outputs_summary"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_n_divmod; + +static PyObject *__pyx_k121p; +static PyObject *__pyx_k122p; + +static char (__pyx_k121[]) = "Can't predict without input data !"; +static char (__pyx_k122[]) = "Incompatible data size: there should be as many rows as parameters"; + +static PyObject *__pyx_f_7_mloess_5loess_predict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_7_mloess_5loess_predict[] = "Computes loess estimates at the given new data points newdata. Returns\na loess_predicted object, whose attributes are described below.\n \n:Parameters:\n newdata : ndarray\n The (m,p) array of independent variables where the surface must be estimated,\n with m the number of new data points, and p the number of independent\n variables.\n stderror : boolean\n Whether the standard error should be computed\n \n:Returns:\n A new loess_predicted object, consisting of:\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n residual_scale : float\n Estimate of the scale of the residuals\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n nest : integer\n Number of new observations.\n "; +static PyObject *__pyx_f_7_mloess_5loess_predict(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_newdata = 0; + PyObject *__pyx_v_stderror = 0; + PyArrayObject *__pyx_v_p_ndr; + double (*__pyx_v_p_dat); + prediction __pyx_v__prediction; + int __pyx_v_m; + PyObject *__pyx_v_notOK; + PyObject *__pyx_r; + int __pyx_1; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + PyObject *__pyx_5 = 0; + static char *__pyx_argnames[] = {"newdata","stderror",0}; + __pyx_v_stderror = __pyx_k12; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_newdata, &__pyx_v_stderror)) return 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_newdata); + Py_INCREF(__pyx_v_stderror); + __pyx_v_p_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + __pyx_v_notOK = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":882 */ + __pyx_1 = (((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->outputs->activated == 0); + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":883 */ + loess_fit((&((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base)); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":884 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; goto __pyx_L1;} + __pyx_1 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->outputs->activated = __pyx_1; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":885 */ + __pyx_1 = ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base.status.err_status; + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":886 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; goto __pyx_L1;} + __pyx_3 = PyString_FromString(((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; goto __pyx_L1;} + goto __pyx_L3; + } + __pyx_L3:; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":888 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_narray); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + Py_INCREF(__pyx_v_newdata); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_newdata); + __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_copy, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + if (PyDict_SetItem(__pyx_3, __pyx_n_subok, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (PyDict_SetItem(__pyx_3, __pyx_n_order, __pyx_n_C) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_ravel); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; goto __pyx_L1;} + Py_DECREF(((PyObject *)__pyx_v_p_ndr)); + __pyx_v_p_ndr = ((PyArrayObject *)__pyx_4); + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":889 */ + __pyx_v_p_dat = ((double (*))__pyx_v_p_ndr->data); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":891 */ + __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_p_ndr), __pyx_n_size); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;} + __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_3, __pyx_5, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; goto __pyx_L1;} + __pyx_1 = __pyx_1 == 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":892 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; goto __pyx_L1;} + Py_INCREF(__pyx_k121p); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k121p); + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_3, 0, 0); + Py_DECREF(__pyx_3); __pyx_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; goto __pyx_L1;} + goto __pyx_L4; + } + __pyx_L4:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":893 */ + __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_divmod); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + Py_INCREF(((PyObject *)__pyx_v_p_ndr)); + PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_p_ndr)); + __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_2 = PyInt_FromLong(((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->inputs->npar); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2); + __pyx_3 = 0; + __pyx_2 = 0; + __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_2 = PyObject_GetIter(__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + __pyx_1 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + Py_DECREF(__pyx_5); __pyx_5 = 0; + __pyx_v_m = __pyx_1; + __pyx_4 = __Pyx_UnpackItem(__pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + Py_DECREF(__pyx_v_notOK); + __pyx_v_notOK = __pyx_4; + __pyx_4 = 0; + if (__Pyx_EndUnpack(__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":894 */ + __pyx_1 = PyObject_IsTrue(__pyx_v_notOK); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; goto __pyx_L1;} + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":895 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} + Py_INCREF(__pyx_k122p); + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k122p); + __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; goto __pyx_L1;} + goto __pyx_L5; + } + __pyx_L5:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":898 */ + __pyx_1 = PyInt_AsLong(__pyx_v_stderror); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; goto __pyx_L1;} + predict(__pyx_v_p_dat,__pyx_v_m,(&((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base),(&__pyx_v__prediction),__pyx_1); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":899 */ + __pyx_1 = ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base.status.err_status; + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":900 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;} + __pyx_3 = PyString_FromString(((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base.status.err_msg); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;} + __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3); + __pyx_3 = 0; + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_5); __pyx_5 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; goto __pyx_L1;} + goto __pyx_L6; + } + __pyx_L6:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":901 */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_7_mloess_loess_predicted), 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; goto __pyx_L1;} + if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_7_mloess_loess_predicted)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; goto __pyx_L1;} + Py_DECREF(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->predicted)); + ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->predicted = ((struct __pyx_obj_7_mloess_loess_predicted *)__pyx_3); + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":902 */ + ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->predicted->_base = __pyx_v__prediction; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":903 */ + ((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->predicted->nest = __pyx_v_m; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":905 */ + Py_INCREF(((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->predicted)); + __pyx_r = ((PyObject *)((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->predicted); + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_5); + __Pyx_AddTraceback("_mloess.loess.predict"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_p_ndr); + Py_DECREF(__pyx_v_notOK); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_newdata); + Py_DECREF(__pyx_v_stderror); + return __pyx_r; +} + +static void __pyx_f_7_mloess_5loess___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_f_7_mloess_5loess___dealloc__(PyObject *__pyx_v_self) { + Py_INCREF(__pyx_v_self); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":908 */ + loess_free_mem((&((struct __pyx_obj_7_mloess_loess *)__pyx_v_self)->_base)); + + Py_DECREF(__pyx_v_self); +} + +static PyObject *__pyx_n_isinstance; +static PyObject *__pyx_n_type; +static PyObject *__pyx_n_outputs; +static PyObject *__pyx_n_abs; + +static PyObject *__pyx_k123p; + +static char (__pyx_k123[]) = "Arguments should be valid loess objects!got '%s' instead"; + +static int __pyx_f_7_mloess_5anova___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_7_mloess_5anova___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_loess_one = 0; + PyObject *__pyx_v_loess_two = 0; + double __pyx_v_one_d1; + double __pyx_v_one_d2; + double __pyx_v_one_s; + double __pyx_v_two_d1; + double __pyx_v_two_d2; + double __pyx_v_two_s; + double __pyx_v_rssdiff; + double __pyx_v_d1diff; + double __pyx_v_tmp; + double __pyx_v_df1; + double __pyx_v_df2; + PyObject *__pyx_v_out_one; + PyObject *__pyx_v_out_two; + PyObject *__pyx_v_F_value; + int __pyx_r; + int __pyx_1; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + int __pyx_5; + PyObject *__pyx_6 = 0; + double __pyx_7; + static char *__pyx_argnames[] = {"loess_one","loess_two",0}; + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_loess_one, &__pyx_v_loess_two)) return -1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_loess_one); + Py_INCREF(__pyx_v_loess_two); + __pyx_v_out_one = Py_None; Py_INCREF(Py_None); + __pyx_v_out_two = Py_None; Py_INCREF(Py_None); + __pyx_v_F_value = Py_None; Py_INCREF(Py_None); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":922 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} + Py_INCREF(__pyx_v_loess_one); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_loess_one); + Py_INCREF(((PyObject*)__pyx_ptype_7_mloess_loess)); + PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_7_mloess_loess)); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_1 = (!__pyx_5); + if (!__pyx_1) { + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} + __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} + Py_INCREF(__pyx_v_loess_two); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_loess_two); + Py_INCREF(((PyObject*)__pyx_ptype_7_mloess_loess)); + PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_7_mloess_loess)); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_1 = (!__pyx_5); + } + if (__pyx_1) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":923 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;} + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;} + Py_INCREF(__pyx_v_loess_one); + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_loess_one); + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_3 = PyNumber_Remainder(__pyx_k123p, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __Pyx_Raise(__pyx_6, 0, 0); + Py_DECREF(__pyx_6); __pyx_6 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 923; goto __pyx_L1;} + goto __pyx_L2; + } + __pyx_L2:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":926 */ + __pyx_3 = PyObject_GetAttr(__pyx_v_loess_one, __pyx_n_outputs); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;} + Py_DECREF(__pyx_v_out_one); + __pyx_v_out_one = __pyx_3; + __pyx_3 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":927 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_loess_two, __pyx_n_outputs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;} + Py_DECREF(__pyx_v_out_two); + __pyx_v_out_two = __pyx_2; + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":929 */ + __pyx_4 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_one_delta); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_v_one_d1 = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":930 */ + __pyx_6 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_two_delta); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_v_one_d2 = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":931 */ + __pyx_3 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_s); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __pyx_v_one_s = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":933 */ + __pyx_2 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_one_delta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_v_two_d1 = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":934 */ + __pyx_4 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_two_delta); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_v_two_d2 = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":935 */ + __pyx_6 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_s); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;} + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_v_two_s = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":937 */ + __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;} + __pyx_2 = PyFloat_FromDouble((((__pyx_v_one_s * __pyx_v_one_s) * __pyx_v_one_d1) - ((__pyx_v_two_s * __pyx_v_two_s) * __pyx_v_two_d1))); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2); + __pyx_2 = 0; + __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_v_rssdiff = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":938 */ + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;} + __pyx_3 = PyFloat_FromDouble((__pyx_v_one_d1 - __pyx_v_two_d1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;} + __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); + __pyx_3 = 0; + __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_7 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_v_d1diff = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":939 */ + __pyx_3 = PyFloat_FromDouble((__pyx_v_d1diff * __pyx_v_d1diff)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;} + __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;} + __pyx_4 = PyFloat_FromDouble((__pyx_v_one_d2 - __pyx_v_two_d2)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;} + __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_6, 0, __pyx_4); + __pyx_4 = 0; + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_6); __pyx_6 = 0; + __pyx_2 = PyNumber_Divide(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_7 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + ((struct __pyx_obj_7_mloess_anova *)__pyx_v_self)->dfn = __pyx_7; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":940 */ + __pyx_v_df1 = ((struct __pyx_obj_7_mloess_anova *)__pyx_v_self)->dfn; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":942 */ + __pyx_6 = PyObject_GetAttr(__pyx_v_out_one, __pyx_n_enp); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;} + __pyx_3 = PyObject_GetAttr(__pyx_v_out_two, __pyx_n_enp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;} + if (PyObject_Cmp(__pyx_6, __pyx_3, &__pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;} + __pyx_5 = __pyx_5 > 0; + Py_DECREF(__pyx_6); __pyx_6 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + if (__pyx_5) { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":943 */ + ((struct __pyx_obj_7_mloess_anova *)__pyx_v_self)->dfd = ((__pyx_v_one_d1 * __pyx_v_one_d1) / __pyx_v_one_d2); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":944 */ + __pyx_v_tmp = __pyx_v_one_s; + goto __pyx_L3; + } + /*else*/ { + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":946 */ + ((struct __pyx_obj_7_mloess_anova *)__pyx_v_self)->dfd = ((__pyx_v_two_d1 * __pyx_v_two_d1) / __pyx_v_two_d2); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":947 */ + __pyx_v_tmp = __pyx_v_two_s; + } + __pyx_L3:; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":948 */ + __pyx_v_df2 = ((struct __pyx_obj_7_mloess_anova *)__pyx_v_self)->dfd; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":949 */ + __pyx_4 = PyFloat_FromDouble(((__pyx_v_rssdiff / __pyx_v_d1diff) / (__pyx_v_tmp * __pyx_v_tmp))); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; goto __pyx_L1;} + Py_DECREF(__pyx_v_F_value); + __pyx_v_F_value = __pyx_4; + __pyx_4 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":951 */ + __pyx_2 = PyFloat_FromDouble(__pyx_v_df1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;} + __pyx_6 = PyNumber_Multiply(__pyx_v_F_value, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = PyFloat_FromDouble(__pyx_v_df2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;} + __pyx_4 = PyFloat_FromDouble(__pyx_v_df1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;} + __pyx_2 = PyNumber_Multiply(__pyx_v_F_value, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;} + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_4 = PyNumber_Add(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_3 = PyNumber_Divide(__pyx_6, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;} + Py_DECREF(__pyx_6); __pyx_6 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + ((struct __pyx_obj_7_mloess_anova *)__pyx_v_self)->Pr_F = (1. - ibeta(__pyx_7,(__pyx_v_df1 / 2),(__pyx_v_df2 / 2))); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":952 */ + __pyx_7 = PyFloat_AsDouble(__pyx_v_F_value); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; goto __pyx_L1;} + ((struct __pyx_obj_7_mloess_anova *)__pyx_v_self)->F_value = __pyx_7; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + Py_XDECREF(__pyx_6); + __Pyx_AddTraceback("_mloess.anova.__init__"); + __pyx_r = -1; + __pyx_L0:; + Py_DECREF(__pyx_v_out_one); + Py_DECREF(__pyx_v_out_two); + Py_DECREF(__pyx_v_F_value); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_loess_one); + Py_DECREF(__pyx_v_loess_two); + return __pyx_r; +} + +static __Pyx_InternTabEntry __pyx_intern_tab[] = { + {&__pyx_n_C, "C"}, + {&__pyx_n_False, "False"}, + {&__pyx_n_T, "T"}, + {&__pyx_n_True, "True"}, + {&__pyx_n_ValueError, "ValueError"}, + {&__pyx_n_abs, "abs"}, + {&__pyx_n_any, "any"}, + {&__pyx_n_approximate, "approximate"}, + {&__pyx_n_array, "array"}, + {&__pyx_n_astype, "astype"}, + {&__pyx_n_atleast_1d, "atleast_1d"}, + {&__pyx_n_axis, "axis"}, + {&__pyx_n_bool, "bool"}, + {&__pyx_n_c_loess, "c_loess"}, + {&__pyx_n_c_numpy, "c_numpy"}, + {&__pyx_n_c_python, "c_python"}, + {&__pyx_n_cell, "cell"}, + {&__pyx_n_copy, "copy"}, + {&__pyx_n_data, "data"}, + {&__pyx_n_degree, "degree"}, + {&__pyx_n_df, "df"}, + {&__pyx_n_direct, "direct"}, + {&__pyx_n_divisor, "divisor"}, + {&__pyx_n_divmod, "divmod"}, + {&__pyx_n_drop_square, "drop_square"}, + {&__pyx_n_drop_square_flags, "drop_square_flags"}, + {&__pyx_n_dtype, "dtype"}, + {&__pyx_n_empty, "empty"}, + {&__pyx_n_enp, "enp"}, + {&__pyx_n_exact, "exact"}, + {&__pyx_n_family, "family"}, + {&__pyx_n_fitted_residuals, "fitted_residuals"}, + {&__pyx_n_fitted_values, "fitted_values"}, + {&__pyx_n_flat, "flat"}, + {&__pyx_n_float_, "float_"}, + {&__pyx_n_gaussian, "gaussian"}, + {&__pyx_n_get, "get"}, + {&__pyx_n_getmaskarray, "getmaskarray"}, + {&__pyx_n_interpolate, "interpolate"}, + {&__pyx_n_isinstance, "isinstance"}, + {&__pyx_n_iterations, "iterations"}, + {&__pyx_n_iteritems, "iteritems"}, + {&__pyx_n_join, "join"}, + {&__pyx_n_len, "len"}, + {&__pyx_n_logical_not, "logical_not"}, + {&__pyx_n_lower, "lower"}, + {&__pyx_n_marray, "marray"}, + {&__pyx_n_mask, "mask"}, + {&__pyx_n_mask_or, "mask_or"}, + {&__pyx_n_masked_array, "masked_array"}, + {&__pyx_n_maskedarray, "maskedarray"}, + {&__pyx_n_min, "min"}, + {&__pyx_n_narray, "narray"}, + {&__pyx_n_ndim, "ndim"}, + {&__pyx_n_normalize, "normalize"}, + {&__pyx_n_numpy, "numpy"}, + {&__pyx_n_one_delta, "one_delta"}, + {&__pyx_n_ones, "ones"}, + {&__pyx_n_order, "order"}, + {&__pyx_n_outputs, "outputs"}, + {&__pyx_n_parametric, "parametric"}, + {&__pyx_n_parametric_flags, "parametric_flags"}, + {&__pyx_n_r_, "r_"}, + {&__pyx_n_ravel, "ravel"}, + {&__pyx_n_residual_scale, "residual_scale"}, + {&__pyx_n_s, "s"}, + {&__pyx_n_shape, "shape"}, + {&__pyx_n_size, "size"}, + {&__pyx_n_small_mask, "small_mask"}, + {&__pyx_n_span, "span"}, + {&__pyx_n_statistics, "statistics"}, + {&__pyx_n_stderr, "stderr"}, + {&__pyx_n_str, "str"}, + {&__pyx_n_subok, "subok"}, + {&__pyx_n_sum, "sum"}, + {&__pyx_n_surface, "surface"}, + {&__pyx_n_symmetric, "symmetric"}, + {&__pyx_n_trace_hat, "trace_hat"}, + {&__pyx_n_two_delta, "two_delta"}, + {&__pyx_n_type, "type"}, + {&__pyx_n_update, "update"}, + {&__pyx_n_values, "values"}, + {0, 0} +}; + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_k26p, __pyx_k26, sizeof(__pyx_k26)}, + {&__pyx_k31p, __pyx_k31, sizeof(__pyx_k31)}, + {&__pyx_k34p, __pyx_k34, sizeof(__pyx_k34)}, + {&__pyx_k35p, __pyx_k35, sizeof(__pyx_k35)}, + {&__pyx_k38p, __pyx_k38, sizeof(__pyx_k38)}, + {&__pyx_k41p, __pyx_k41, sizeof(__pyx_k41)}, + {&__pyx_k42p, __pyx_k42, sizeof(__pyx_k42)}, + {&__pyx_k43p, __pyx_k43, sizeof(__pyx_k43)}, + {&__pyx_k49p, __pyx_k49, sizeof(__pyx_k49)}, + {&__pyx_k50p, __pyx_k50, sizeof(__pyx_k50)}, + {&__pyx_k51p, __pyx_k51, sizeof(__pyx_k51)}, + {&__pyx_k52p, __pyx_k52, sizeof(__pyx_k52)}, + {&__pyx_k53p, __pyx_k53, sizeof(__pyx_k53)}, + {&__pyx_k54p, __pyx_k54, sizeof(__pyx_k54)}, + {&__pyx_k55p, __pyx_k55, sizeof(__pyx_k55)}, + {&__pyx_k56p, __pyx_k56, sizeof(__pyx_k56)}, + {&__pyx_k57p, __pyx_k57, sizeof(__pyx_k57)}, + {&__pyx_k60p, __pyx_k60, sizeof(__pyx_k60)}, + {&__pyx_k73p, __pyx_k73, sizeof(__pyx_k73)}, + {&__pyx_k74p, __pyx_k74, sizeof(__pyx_k74)}, + {&__pyx_k75p, __pyx_k75, sizeof(__pyx_k75)}, + {&__pyx_k76p, __pyx_k76, sizeof(__pyx_k76)}, + {&__pyx_k77p, __pyx_k77, sizeof(__pyx_k77)}, + {&__pyx_k78p, __pyx_k78, sizeof(__pyx_k78)}, + {&__pyx_k79p, __pyx_k79, sizeof(__pyx_k79)}, + {&__pyx_k80p, __pyx_k80, sizeof(__pyx_k80)}, + {&__pyx_k81p, __pyx_k81, sizeof(__pyx_k81)}, + {&__pyx_k83p, __pyx_k83, sizeof(__pyx_k83)}, + {&__pyx_k84p, __pyx_k84, sizeof(__pyx_k84)}, + {&__pyx_k85p, __pyx_k85, sizeof(__pyx_k85)}, + {&__pyx_k86p, __pyx_k86, sizeof(__pyx_k86)}, + {&__pyx_k87p, __pyx_k87, sizeof(__pyx_k87)}, + {&__pyx_k88p, __pyx_k88, sizeof(__pyx_k88)}, + {&__pyx_k89p, __pyx_k89, sizeof(__pyx_k89)}, + {&__pyx_k90p, __pyx_k90, sizeof(__pyx_k90)}, + {&__pyx_k91p, __pyx_k91, sizeof(__pyx_k91)}, + {&__pyx_k92p, __pyx_k92, sizeof(__pyx_k92)}, + {&__pyx_k93p, __pyx_k93, sizeof(__pyx_k93)}, + {&__pyx_k94p, __pyx_k94, sizeof(__pyx_k94)}, + {&__pyx_k95p, __pyx_k95, sizeof(__pyx_k95)}, + {&__pyx_k96p, __pyx_k96, sizeof(__pyx_k96)}, + {&__pyx_k97p, __pyx_k97, sizeof(__pyx_k97)}, + {&__pyx_k98p, __pyx_k98, sizeof(__pyx_k98)}, + {&__pyx_k110p, __pyx_k110, sizeof(__pyx_k110)}, + {&__pyx_k111p, __pyx_k111, sizeof(__pyx_k111)}, + {&__pyx_k112p, __pyx_k112, sizeof(__pyx_k112)}, + {&__pyx_k113p, __pyx_k113, sizeof(__pyx_k113)}, + {&__pyx_k115p, __pyx_k115, sizeof(__pyx_k115)}, + {&__pyx_k116p, __pyx_k116, sizeof(__pyx_k116)}, + {&__pyx_k121p, __pyx_k121, sizeof(__pyx_k121)}, + {&__pyx_k122p, __pyx_k122, sizeof(__pyx_k122)}, + {&__pyx_k123p, __pyx_k123, sizeof(__pyx_k123)}, + {0, 0, 0} +}; + +static PyObject *__pyx_tp_new_7_mloess_loess_inputs(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_7_mloess_loess_inputs *p = (struct __pyx_obj_7_mloess_loess_inputs *)o; + p->w_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->x = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->y = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->masked = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->x_eff = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->y_eff = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_7_mloess_loess_inputs(PyObject *o) { + struct __pyx_obj_7_mloess_loess_inputs *p = (struct __pyx_obj_7_mloess_loess_inputs *)o; + Py_XDECREF(((PyObject *)p->w_ndr)); + Py_XDECREF(((PyObject *)p->x)); + Py_XDECREF(((PyObject *)p->y)); + Py_XDECREF(((PyObject *)p->masked)); + Py_XDECREF(((PyObject *)p->x_eff)); + Py_XDECREF(((PyObject *)p->y_eff)); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_7_mloess_loess_inputs(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7_mloess_loess_inputs *p = (struct __pyx_obj_7_mloess_loess_inputs *)o; + if (p->w_ndr) { + e = (*v)(((PyObject*)p->w_ndr), a); if (e) return e; + } + if (p->x) { + e = (*v)(((PyObject*)p->x), a); if (e) return e; + } + if (p->y) { + e = (*v)(((PyObject*)p->y), a); if (e) return e; + } + if (p->masked) { + e = (*v)(((PyObject*)p->masked), a); if (e) return e; + } + if (p->x_eff) { + e = (*v)(((PyObject*)p->x_eff), a); if (e) return e; + } + if (p->y_eff) { + e = (*v)(((PyObject*)p->y_eff), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7_mloess_loess_inputs(PyObject *o) { + struct __pyx_obj_7_mloess_loess_inputs *p = (struct __pyx_obj_7_mloess_loess_inputs *)o; + Py_XDECREF(((PyObject *)p->w_ndr)); + p->w_ndr = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->x)); + p->x = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->y)); + p->y = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->masked)); + p->masked = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->x_eff)); + p->x_eff = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->y_eff)); + p->y_eff = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return 0; +} + +static PyObject *__pyx_getprop_7_mloess_12loess_inputs_weights(PyObject *o, void *x) { + return __pyx_f_7_mloess_12loess_inputs_7weights___get__(o); +} + +static int __pyx_setprop_7_mloess_12loess_inputs_weights(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_7_mloess_12loess_inputs_7weights___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static struct PyMethodDef __pyx_methods_7_mloess_loess_inputs[] = { + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_7_mloess_loess_inputs[] = { + {"x", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_loess_inputs, x), READONLY, 0}, + {"y", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_loess_inputs, y), READONLY, 0}, + {"masked", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_loess_inputs, masked), READONLY, 0}, + {"x_eff", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_loess_inputs, x_eff), READONLY, 0}, + {"y_eff", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_loess_inputs, y_eff), READONLY, 0}, + {"nobs", T_INT, offsetof(struct __pyx_obj_7_mloess_loess_inputs, nobs), READONLY, 0}, + {"nobs_eff", T_INT, offsetof(struct __pyx_obj_7_mloess_loess_inputs, nobs_eff), READONLY, 0}, + {"npar", T_INT, offsetof(struct __pyx_obj_7_mloess_loess_inputs, npar), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_7_mloess_loess_inputs[] = { + {"weights", __pyx_getprop_7_mloess_12loess_inputs_weights, __pyx_setprop_7_mloess_12loess_inputs_weights, __pyx_k1, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_inputs = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_inputs = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_inputs = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_inputs = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_7_mloess_loess_inputs = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_mloess.loess_inputs", /*tp_name*/ + sizeof(struct __pyx_obj_7_mloess_loess_inputs), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7_mloess_loess_inputs, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_inputs, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_inputs, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_inputs, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_inputs, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "Loess inputs\n \n:IVariables:\n x : ndarray\n A (n,p) ndarray of independent variables, with n the number of observations\n and p the number of variables.\n y : ndarray\n A (n,) ndarray of observations\n nobs : integer\n Number of observations: nobs=n.\n npar : integer\n Number of independent variables: npar=p.\n weights : ndarray\n A (n,) ndarray of weights to be given to individual observations in the \n sum of squared residuals that forms the local fitting criterion. If not\n None, the weights should be non negative. If the different observations\n have non-equal variances, the weights should be inversely proportional \n to the variances.\n By default, an unweighted fit is carried out (all the weights are one).\n ", /*tp_doc*/ + __pyx_tp_traverse_7_mloess_loess_inputs, /*tp_traverse*/ + __pyx_tp_clear_7_mloess_loess_inputs, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7_mloess_loess_inputs, /*tp_methods*/ + __pyx_members_7_mloess_loess_inputs, /*tp_members*/ + __pyx_getsets_7_mloess_loess_inputs, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_f_7_mloess_12loess_inputs___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7_mloess_loess_inputs, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_7_mloess_loess_control(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + return o; +} + +static void __pyx_tp_dealloc_7_mloess_loess_control(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_7_mloess_loess_control(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_7_mloess_loess_control(PyObject *o) { + return 0; +} + +static PyObject *__pyx_getprop_7_mloess_13loess_control_surface(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_control_7surface___get__(o); +} + +static int __pyx_setprop_7_mloess_13loess_control_surface(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_7_mloess_13loess_control_7surface___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_7_mloess_13loess_control_statistics(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_control_10statistics___get__(o); +} + +static int __pyx_setprop_7_mloess_13loess_control_statistics(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_7_mloess_13loess_control_10statistics___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_7_mloess_13loess_control_trace_hat(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_control_9trace_hat___get__(o); +} + +static int __pyx_setprop_7_mloess_13loess_control_trace_hat(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_7_mloess_13loess_control_9trace_hat___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_7_mloess_13loess_control_iterations(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_control_10iterations___get__(o); +} + +static int __pyx_setprop_7_mloess_13loess_control_iterations(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_7_mloess_13loess_control_10iterations___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_7_mloess_13loess_control_cell(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_control_4cell___get__(o); +} + +static int __pyx_setprop_7_mloess_13loess_control_cell(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_7_mloess_13loess_control_4cell___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static struct PyMethodDef __pyx_methods_7_mloess_loess_control[] = { + {"update", (PyCFunction)__pyx_f_7_mloess_13loess_control_update, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7_mloess_13loess_control_update}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_7_mloess_loess_control[] = { + {"surface", __pyx_getprop_7_mloess_13loess_control_surface, __pyx_setprop_7_mloess_13loess_control_surface, __pyx_k2, 0}, + {"statistics", __pyx_getprop_7_mloess_13loess_control_statistics, __pyx_setprop_7_mloess_13loess_control_statistics, __pyx_k3, 0}, + {"trace_hat", __pyx_getprop_7_mloess_13loess_control_trace_hat, __pyx_setprop_7_mloess_13loess_control_trace_hat, __pyx_k4, 0}, + {"iterations", __pyx_getprop_7_mloess_13loess_control_iterations, __pyx_setprop_7_mloess_13loess_control_iterations, __pyx_k5, 0}, + {"cell", __pyx_getprop_7_mloess_13loess_control_cell, __pyx_setprop_7_mloess_13loess_control_cell, __pyx_k6, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_control = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_control = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_control = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_control = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_7_mloess_loess_control = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_mloess.loess_control", /*tp_name*/ + sizeof(struct __pyx_obj_7_mloess_loess_control), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7_mloess_loess_control, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_control, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_control, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_control, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_f_7_mloess_13loess_control___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_control, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "Loess control parameters.\n \n:IVariables:\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n \n ", /*tp_doc*/ + __pyx_tp_traverse_7_mloess_loess_control, /*tp_traverse*/ + __pyx_tp_clear_7_mloess_loess_control, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7_mloess_loess_control, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_7_mloess_loess_control, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7_mloess_loess_control, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_7_mloess_loess_kd_tree(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + return o; +} + +static void __pyx_tp_dealloc_7_mloess_loess_kd_tree(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_7_mloess_loess_kd_tree(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_7_mloess_loess_kd_tree(PyObject *o) { + return 0; +} + +static struct PyMethodDef __pyx_methods_7_mloess_loess_kd_tree[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_kd_tree = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_kd_tree = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_kd_tree = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_kd_tree = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_7_mloess_loess_kd_tree = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_mloess.loess_kd_tree", /*tp_name*/ + sizeof(struct __pyx_obj_7_mloess_loess_kd_tree), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7_mloess_loess_kd_tree, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_kd_tree, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_kd_tree, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_kd_tree, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_kd_tree, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_7_mloess_loess_kd_tree, /*tp_traverse*/ + __pyx_tp_clear_7_mloess_loess_kd_tree, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7_mloess_loess_kd_tree, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7_mloess_loess_kd_tree, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; +static struct __pyx_vtabstruct_7_mloess_loess_model __pyx_vtable_7_mloess_loess_model; + +static PyObject *__pyx_tp_new_7_mloess_loess_model(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_7_mloess_loess_model *p = (struct __pyx_obj_7_mloess_loess_model *)o; + *(struct __pyx_vtabstruct_7_mloess_loess_model **)&p->__pyx_vtab = __pyx_vtabptr_7_mloess_loess_model; + return o; +} + +static void __pyx_tp_dealloc_7_mloess_loess_model(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_7_mloess_loess_model(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_7_mloess_loess_model(PyObject *o) { + return 0; +} + +static PyObject *__pyx_getprop_7_mloess_11loess_model_normalize(PyObject *o, void *x) { + return __pyx_f_7_mloess_11loess_model_9normalize___get__(o); +} + +static int __pyx_setprop_7_mloess_11loess_model_normalize(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_7_mloess_11loess_model_9normalize___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_7_mloess_11loess_model_span(PyObject *o, void *x) { + return __pyx_f_7_mloess_11loess_model_4span___get__(o); +} + +static int __pyx_setprop_7_mloess_11loess_model_span(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_7_mloess_11loess_model_4span___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_7_mloess_11loess_model_degree(PyObject *o, void *x) { + return __pyx_f_7_mloess_11loess_model_6degree___get__(o); +} + +static int __pyx_setprop_7_mloess_11loess_model_degree(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_7_mloess_11loess_model_6degree___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_7_mloess_11loess_model_family(PyObject *o, void *x) { + return __pyx_f_7_mloess_11loess_model_6family___get__(o); +} + +static int __pyx_setprop_7_mloess_11loess_model_family(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_7_mloess_11loess_model_6family___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_7_mloess_11loess_model_parametric_flags(PyObject *o, void *x) { + return __pyx_f_7_mloess_11loess_model_16parametric_flags___get__(o); +} + +static int __pyx_setprop_7_mloess_11loess_model_parametric_flags(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_7_mloess_11loess_model_16parametric_flags___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_7_mloess_11loess_model_drop_square_flags(PyObject *o, void *x) { + return __pyx_f_7_mloess_11loess_model_17drop_square_flags___get__(o); +} + +static int __pyx_setprop_7_mloess_11loess_model_drop_square_flags(PyObject *o, PyObject *v, void *x) { + if (v) { + return __pyx_f_7_mloess_11loess_model_17drop_square_flags___set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static struct PyMethodDef __pyx_methods_7_mloess_loess_model[] = { + {"update", (PyCFunction)__pyx_f_7_mloess_11loess_model_update, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_7_mloess_loess_model[] = { + {"normalize", __pyx_getprop_7_mloess_11loess_model_normalize, __pyx_setprop_7_mloess_11loess_model_normalize, 0, 0}, + {"span", __pyx_getprop_7_mloess_11loess_model_span, __pyx_setprop_7_mloess_11loess_model_span, 0, 0}, + {"degree", __pyx_getprop_7_mloess_11loess_model_degree, __pyx_setprop_7_mloess_11loess_model_degree, 0, 0}, + {"family", __pyx_getprop_7_mloess_11loess_model_family, __pyx_setprop_7_mloess_11loess_model_family, 0, 0}, + {"parametric_flags", __pyx_getprop_7_mloess_11loess_model_parametric_flags, __pyx_setprop_7_mloess_11loess_model_parametric_flags, 0, 0}, + {"drop_square_flags", __pyx_getprop_7_mloess_11loess_model_drop_square_flags, __pyx_setprop_7_mloess_11loess_model_drop_square_flags, 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_model = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_model = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_model = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_model = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_7_mloess_loess_model = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_mloess.loess_model", /*tp_name*/ + sizeof(struct __pyx_obj_7_mloess_loess_model), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7_mloess_loess_model, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + __pyx_f_7_mloess_11loess_model___repr__, /*tp_repr*/ + &__pyx_tp_as_number_loess_model, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_model, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_model, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_f_7_mloess_11loess_model___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_model, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "loess_model contains parameters required for a loess fit.\n \n:IVariables:\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n span : float [0.75]\n Smoothing factor, as a fraction of the number of points to take into\n account. \n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n family : string [\"gaussian\"]\n Determines the assumed distribution of the errors. The values are \n \"gaussian\" or \"symmetric\". If \"gaussian\" is selected, the fit is \n performed with least-squares. If \"symmetric\" is selected, the fit\n is performed robustly by redescending M-estimators.\n parametric_flags : sequence [ [False]*p ]\n Indicates which independent variables should be conditionally-parametric\n (if there are two or more independent variables). The argument should be\n a sequence of booleans, with the same size as the number of independent \n variables, specified in the order of the predictor group ordered in x. \n Note: elements of the sequence cannot be modified individually: the whole\n sequence must be given.\n drop_square : sequence [ [False]* p]\n When there are two or more independent variables and when a 2nd order\n polynomial is used, \"drop_square_flags\" specifies those numeric predictors \n whose squares should be dropped from the set of fitting variables. \n The method of specification is the same as for parametric. \n Note: elements of the sequence cannot be modified individually: the whole\n sequence must be given.\n\n ", /*tp_doc*/ + __pyx_tp_traverse_7_mloess_loess_model, /*tp_traverse*/ + __pyx_tp_clear_7_mloess_loess_model, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7_mloess_loess_model, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_7_mloess_loess_model, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7_mloess_loess_model, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; +static struct __pyx_vtabstruct_7_mloess_loess_outputs __pyx_vtable_7_mloess_loess_outputs; + +static PyObject *__pyx_tp_new_7_mloess_loess_outputs(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_7_mloess_loess_outputs *p = (struct __pyx_obj_7_mloess_loess_outputs *)o; + *(struct __pyx_vtabstruct_7_mloess_loess_outputs **)&p->__pyx_vtab = __pyx_vtabptr_7_mloess_loess_outputs; + p->masked = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->unmasked = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_7_mloess_loess_outputs(PyObject *o) { + struct __pyx_obj_7_mloess_loess_outputs *p = (struct __pyx_obj_7_mloess_loess_outputs *)o; + Py_XDECREF(((PyObject *)p->masked)); + Py_XDECREF(((PyObject *)p->unmasked)); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_7_mloess_loess_outputs(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7_mloess_loess_outputs *p = (struct __pyx_obj_7_mloess_loess_outputs *)o; + if (p->masked) { + e = (*v)(((PyObject*)p->masked), a); if (e) return e; + } + if (p->unmasked) { + e = (*v)(((PyObject*)p->unmasked), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7_mloess_loess_outputs(PyObject *o) { + struct __pyx_obj_7_mloess_loess_outputs *p = (struct __pyx_obj_7_mloess_loess_outputs *)o; + Py_XDECREF(((PyObject *)p->masked)); + p->masked = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->unmasked)); + p->unmasked = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return 0; +} + +static PyObject *__pyx_getprop_7_mloess_13loess_outputs_fitted_values(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_outputs_13fitted_values___get__(o); +} + +static PyObject *__pyx_getprop_7_mloess_13loess_outputs_fitted_residuals(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_outputs_16fitted_residuals___get__(o); +} + +static PyObject *__pyx_getprop_7_mloess_13loess_outputs_pseudovalues(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_outputs_12pseudovalues___get__(o); +} + +static PyObject *__pyx_getprop_7_mloess_13loess_outputs_diagonal(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_outputs_8diagonal___get__(o); +} + +static PyObject *__pyx_getprop_7_mloess_13loess_outputs_robust(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_outputs_6robust___get__(o); +} + +static PyObject *__pyx_getprop_7_mloess_13loess_outputs_divisor(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_outputs_7divisor___get__(o); +} + +static PyObject *__pyx_getprop_7_mloess_13loess_outputs_enp(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_outputs_3enp___get__(o); +} + +static PyObject *__pyx_getprop_7_mloess_13loess_outputs_s(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_outputs_1s___get__(o); +} + +static PyObject *__pyx_getprop_7_mloess_13loess_outputs_one_delta(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_outputs_9one_delta___get__(o); +} + +static PyObject *__pyx_getprop_7_mloess_13loess_outputs_two_delta(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_outputs_9two_delta___get__(o); +} + +static PyObject *__pyx_getprop_7_mloess_13loess_outputs_trace_hat(PyObject *o, void *x) { + return __pyx_f_7_mloess_13loess_outputs_9trace_hat___get__(o); +} + +static struct PyMethodDef __pyx_methods_7_mloess_loess_outputs[] = { + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_7_mloess_loess_outputs[] = { + {"activated", T_INT, offsetof(struct __pyx_obj_7_mloess_loess_outputs, activated), READONLY, 0}, + {"ismasked", T_INT, offsetof(struct __pyx_obj_7_mloess_loess_outputs, ismasked), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_7_mloess_loess_outputs[] = { + {"fitted_values", __pyx_getprop_7_mloess_13loess_outputs_fitted_values, 0, 0, 0}, + {"fitted_residuals", __pyx_getprop_7_mloess_13loess_outputs_fitted_residuals, 0, 0, 0}, + {"pseudovalues", __pyx_getprop_7_mloess_13loess_outputs_pseudovalues, 0, 0, 0}, + {"diagonal", __pyx_getprop_7_mloess_13loess_outputs_diagonal, 0, 0, 0}, + {"robust", __pyx_getprop_7_mloess_13loess_outputs_robust, 0, 0, 0}, + {"divisor", __pyx_getprop_7_mloess_13loess_outputs_divisor, 0, 0, 0}, + {"enp", __pyx_getprop_7_mloess_13loess_outputs_enp, 0, 0, 0}, + {"s", __pyx_getprop_7_mloess_13loess_outputs_s, 0, 0, 0}, + {"one_delta", __pyx_getprop_7_mloess_13loess_outputs_one_delta, 0, 0, 0}, + {"two_delta", __pyx_getprop_7_mloess_13loess_outputs_two_delta, 0, 0, 0}, + {"trace_hat", __pyx_getprop_7_mloess_13loess_outputs_trace_hat, 0, 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_outputs = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_outputs = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_outputs = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_outputs = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_7_mloess_loess_outputs = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_mloess.loess_outputs", /*tp_name*/ + sizeof(struct __pyx_obj_7_mloess_loess_outputs), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7_mloess_loess_outputs, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_outputs, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_outputs, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_outputs, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_f_7_mloess_13loess_outputs___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_outputs, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "Outputs of a loess fit. This object is automatically created with empty\nvalues when a new loess object is instantiated. The object gets filled when the \nloess.fit() method is called.\n \n:IVariables:\n fitted_values : ndarray\n The (n,) ndarray of fitted values.\n fitted_residuals : ndarray\n The (n,) ndarray of fitted residuals (observations - fitted values).\n enp : float\n Equivalent number of parameters.\n s : float\n Estimate of the scale of residuals.\n one_delta: float\n Statistical parameter used in the computation of standard errors.\n two_delta : float\n Statistical parameter used in the computation of standard errors.\n pseudovalues : ndarray\n The (n,) ndarray of adjusted values of the response when robust estimation \n is used.\n trace_hat : float \n Trace of the operator hat matrix.\n diagonal : ndarray\n Diagonal of the operator hat matrix.\n robust : ndarray\n The (n,) ndarray of robustness weights for robust fitting.\n divisor : ndarray\n The (p,) array of normalization divisors for numeric predictors.\n ", /*tp_doc*/ + __pyx_tp_traverse_7_mloess_loess_outputs, /*tp_traverse*/ + __pyx_tp_clear_7_mloess_loess_outputs, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7_mloess_loess_outputs, /*tp_methods*/ + __pyx_members_7_mloess_loess_outputs, /*tp_members*/ + __pyx_getsets_7_mloess_loess_outputs, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7_mloess_loess_outputs, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; +static struct __pyx_vtabstruct_7_mloess_conf_intervals __pyx_vtable_7_mloess_conf_intervals; + +static PyObject *__pyx_tp_new_7_mloess_conf_intervals(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_7_mloess_conf_intervals *p = (struct __pyx_obj_7_mloess_conf_intervals *)o; + *(struct __pyx_vtabstruct_7_mloess_conf_intervals **)&p->__pyx_vtab = __pyx_vtabptr_7_mloess_conf_intervals; + p->lower = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->fit = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->upper = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_7_mloess_conf_intervals(PyObject *o) { + struct __pyx_obj_7_mloess_conf_intervals *p = (struct __pyx_obj_7_mloess_conf_intervals *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++o->ob_refcnt; + __pyx_f_7_mloess_14conf_intervals___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --o->ob_refcnt; + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(((PyObject *)p->lower)); + Py_XDECREF(((PyObject *)p->fit)); + Py_XDECREF(((PyObject *)p->upper)); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_7_mloess_conf_intervals(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7_mloess_conf_intervals *p = (struct __pyx_obj_7_mloess_conf_intervals *)o; + if (p->lower) { + e = (*v)(((PyObject*)p->lower), a); if (e) return e; + } + if (p->fit) { + e = (*v)(((PyObject*)p->fit), a); if (e) return e; + } + if (p->upper) { + e = (*v)(((PyObject*)p->upper), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7_mloess_conf_intervals(PyObject *o) { + struct __pyx_obj_7_mloess_conf_intervals *p = (struct __pyx_obj_7_mloess_conf_intervals *)o; + Py_XDECREF(((PyObject *)p->lower)); + p->lower = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->fit)); + p->fit = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->upper)); + p->upper = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return 0; +} + +static struct PyMethodDef __pyx_methods_7_mloess_conf_intervals[] = { + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_7_mloess_conf_intervals[] = { + {"lower", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_conf_intervals, lower), READONLY, 0}, + {"fit", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_conf_intervals, fit), READONLY, 0}, + {"upper", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_conf_intervals, upper), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_conf_intervals = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_conf_intervals = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_conf_intervals = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_conf_intervals = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_7_mloess_conf_intervals = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_mloess.conf_intervals", /*tp_name*/ + sizeof(struct __pyx_obj_7_mloess_conf_intervals), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7_mloess_conf_intervals, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_conf_intervals, /*tp_as_number*/ + &__pyx_tp_as_sequence_conf_intervals, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_conf_intervals, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_f_7_mloess_14conf_intervals___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_conf_intervals, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "Pointwise confidence intervals of a loess-predicted object:\n \n:IVariables:\n fit : ndarray\n Predicted values.\n lower : ndarray\n Lower bounds of the confidence intervals.\n upper : ndarray\n Upper bounds of the confidence intervals.\n ", /*tp_doc*/ + __pyx_tp_traverse_7_mloess_conf_intervals, /*tp_traverse*/ + __pyx_tp_clear_7_mloess_conf_intervals, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7_mloess_conf_intervals, /*tp_methods*/ + __pyx_members_7_mloess_conf_intervals, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7_mloess_conf_intervals, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; +static struct __pyx_vtabstruct_7_mloess_loess_predicted __pyx_vtable_7_mloess_loess_predicted; + +static PyObject *__pyx_tp_new_7_mloess_loess_predicted(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_7_mloess_loess_predicted *p = (struct __pyx_obj_7_mloess_loess_predicted *)o; + *(struct __pyx_vtabstruct_7_mloess_loess_predicted **)&p->__pyx_vtab = __pyx_vtabptr_7_mloess_loess_predicted; + p->confidence_intervals = ((struct __pyx_obj_7_mloess_conf_intervals *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_7_mloess_loess_predicted(PyObject *o) { + struct __pyx_obj_7_mloess_loess_predicted *p = (struct __pyx_obj_7_mloess_loess_predicted *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++o->ob_refcnt; + __pyx_f_7_mloess_15loess_predicted___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --o->ob_refcnt; + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(((PyObject *)p->confidence_intervals)); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_7_mloess_loess_predicted(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7_mloess_loess_predicted *p = (struct __pyx_obj_7_mloess_loess_predicted *)o; + if (p->confidence_intervals) { + e = (*v)(((PyObject*)p->confidence_intervals), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7_mloess_loess_predicted(PyObject *o) { + struct __pyx_obj_7_mloess_loess_predicted *p = (struct __pyx_obj_7_mloess_loess_predicted *)o; + Py_XDECREF(((PyObject *)p->confidence_intervals)); + p->confidence_intervals = ((struct __pyx_obj_7_mloess_conf_intervals *)Py_None); Py_INCREF(Py_None); + return 0; +} + +static PyObject *__pyx_getprop_7_mloess_15loess_predicted_values(PyObject *o, void *x) { + return __pyx_f_7_mloess_15loess_predicted_6values___get__(o); +} + +static PyObject *__pyx_getprop_7_mloess_15loess_predicted_stderr(PyObject *o, void *x) { + return __pyx_f_7_mloess_15loess_predicted_6stderr___get__(o); +} + +static PyObject *__pyx_getprop_7_mloess_15loess_predicted_residual_scale(PyObject *o, void *x) { + return __pyx_f_7_mloess_15loess_predicted_14residual_scale___get__(o); +} + +static PyObject *__pyx_getprop_7_mloess_15loess_predicted_df(PyObject *o, void *x) { + return __pyx_f_7_mloess_15loess_predicted_2df___get__(o); +} + +static struct PyMethodDef __pyx_methods_7_mloess_loess_predicted[] = { + {"confidence", (PyCFunction)__pyx_f_7_mloess_15loess_predicted_confidence, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7_mloess_15loess_predicted_confidence}, + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_7_mloess_loess_predicted[] = { + {"nest", T_LONG, offsetof(struct __pyx_obj_7_mloess_loess_predicted, nest), READONLY, 0}, + {"confidence_intervals", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_loess_predicted, confidence_intervals), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_7_mloess_loess_predicted[] = { + {"values", __pyx_getprop_7_mloess_15loess_predicted_values, 0, 0, 0}, + {"stderr", __pyx_getprop_7_mloess_15loess_predicted_stderr, 0, 0, 0}, + {"residual_scale", __pyx_getprop_7_mloess_15loess_predicted_residual_scale, 0, 0, 0}, + {"df", __pyx_getprop_7_mloess_15loess_predicted_df, 0, 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess_predicted = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess_predicted = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess_predicted = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess_predicted = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_7_mloess_loess_predicted = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_mloess.loess_predicted", /*tp_name*/ + sizeof(struct __pyx_obj_7_mloess_loess_predicted), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7_mloess_loess_predicted, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess_predicted, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess_predicted, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess_predicted, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_f_7_mloess_15loess_predicted___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess_predicted, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "Predicted values and standard errors of a loess object\n\n:IVariables:\n values : ndarray\n The (m,) ndarray of loess values evaluated at newdata\n stderr : ndarray\n The (m,) ndarray of the estimates of the standard error on the estimated\n values.\n residual_scale : float\n Estimate of the scale of the residuals\n df : integer\n Degrees of freedom of the t-distribution used to compute pointwise \n confidence intervals for the evaluated surface.\n nest : integer\n Number of new observations.\n ", /*tp_doc*/ + __pyx_tp_traverse_7_mloess_loess_predicted, /*tp_traverse*/ + __pyx_tp_clear_7_mloess_loess_predicted, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7_mloess_loess_predicted, /*tp_methods*/ + __pyx_members_7_mloess_loess_predicted, /*tp_members*/ + __pyx_getsets_7_mloess_loess_predicted, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7_mloess_loess_predicted, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_7_mloess_loess(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + struct __pyx_obj_7_mloess_loess *p = (struct __pyx_obj_7_mloess_loess *)o; + p->inputs = ((struct __pyx_obj_7_mloess_loess_inputs *)Py_None); Py_INCREF(Py_None); + p->model = ((struct __pyx_obj_7_mloess_loess_model *)Py_None); Py_INCREF(Py_None); + p->control = ((struct __pyx_obj_7_mloess_loess_control *)Py_None); Py_INCREF(Py_None); + p->kd_tree = ((struct __pyx_obj_7_mloess_loess_kd_tree *)Py_None); Py_INCREF(Py_None); + p->outputs = ((struct __pyx_obj_7_mloess_loess_outputs *)Py_None); Py_INCREF(Py_None); + p->predicted = ((struct __pyx_obj_7_mloess_loess_predicted *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_7_mloess_loess(PyObject *o) { + struct __pyx_obj_7_mloess_loess *p = (struct __pyx_obj_7_mloess_loess *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++o->ob_refcnt; + __pyx_f_7_mloess_5loess___dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --o->ob_refcnt; + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(((PyObject *)p->inputs)); + Py_XDECREF(((PyObject *)p->model)); + Py_XDECREF(((PyObject *)p->control)); + Py_XDECREF(((PyObject *)p->kd_tree)); + Py_XDECREF(((PyObject *)p->outputs)); + Py_XDECREF(((PyObject *)p->predicted)); + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_7_mloess_loess(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_7_mloess_loess *p = (struct __pyx_obj_7_mloess_loess *)o; + if (p->inputs) { + e = (*v)(((PyObject*)p->inputs), a); if (e) return e; + } + if (p->model) { + e = (*v)(((PyObject*)p->model), a); if (e) return e; + } + if (p->control) { + e = (*v)(((PyObject*)p->control), a); if (e) return e; + } + if (p->kd_tree) { + e = (*v)(((PyObject*)p->kd_tree), a); if (e) return e; + } + if (p->outputs) { + e = (*v)(((PyObject*)p->outputs), a); if (e) return e; + } + if (p->predicted) { + e = (*v)(((PyObject*)p->predicted), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_7_mloess_loess(PyObject *o) { + struct __pyx_obj_7_mloess_loess *p = (struct __pyx_obj_7_mloess_loess *)o; + Py_XDECREF(((PyObject *)p->inputs)); + p->inputs = ((struct __pyx_obj_7_mloess_loess_inputs *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->model)); + p->model = ((struct __pyx_obj_7_mloess_loess_model *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->control)); + p->control = ((struct __pyx_obj_7_mloess_loess_control *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->kd_tree)); + p->kd_tree = ((struct __pyx_obj_7_mloess_loess_kd_tree *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->outputs)); + p->outputs = ((struct __pyx_obj_7_mloess_loess_outputs *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(((PyObject *)p->predicted)); + p->predicted = ((struct __pyx_obj_7_mloess_loess_predicted *)Py_None); Py_INCREF(Py_None); + return 0; +} + +static struct PyMethodDef __pyx_methods_7_mloess_loess[] = { + {"fit", (PyCFunction)__pyx_f_7_mloess_5loess_fit, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7_mloess_5loess_fit}, + {"inputs_summary", (PyCFunction)__pyx_f_7_mloess_5loess_inputs_summary, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7_mloess_5loess_inputs_summary}, + {"outputs_summary", (PyCFunction)__pyx_f_7_mloess_5loess_outputs_summary, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7_mloess_5loess_outputs_summary}, + {"predict", (PyCFunction)__pyx_f_7_mloess_5loess_predict, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7_mloess_5loess_predict}, + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_7_mloess_loess[] = { + {"inputs", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_loess, inputs), READONLY, 0}, + {"model", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_loess, model), READONLY, 0}, + {"control", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_loess, control), READONLY, 0}, + {"kd_tree", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_loess, kd_tree), READONLY, 0}, + {"outputs", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_loess, outputs), READONLY, 0}, + {"predicted", T_OBJECT, offsetof(struct __pyx_obj_7_mloess_loess, predicted), READONLY, 0}, + {"nobs", T_LONG, offsetof(struct __pyx_obj_7_mloess_loess, nobs), 0, 0}, + {"npar", T_LONG, offsetof(struct __pyx_obj_7_mloess_loess, npar), 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_loess = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_loess = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_loess = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_loess = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_7_mloess_loess = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_mloess.loess", /*tp_name*/ + sizeof(struct __pyx_obj_7_mloess_loess), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7_mloess_loess, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_loess, /*tp_as_number*/ + &__pyx_tp_as_sequence_loess, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_loess, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_loess, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "\n \n:Keywords:\n x : ndarray\n A (n,p) ndarray of independent variables, with n the number of observations\n and p the number of variables.\n y : ndarray\n A (n,) ndarray of observations\n weights : ndarray\n A (n,) ndarray of weights to be given to individual observations in the \n sum of squared residuals that forms the local fitting criterion. If not\n None, the weights should be non negative. If the different observations\n have non-equal variances, the weights should be inversely proportional \n to the variances.\n By default, an unweighted fit is carried out (all the weights are one).\n surface : string [\"interpolate\"]\n Determines whether the fitted surface is computed directly at all points\n (\"direct\") or whether an interpolation method is used (\"interpolate\").\n The default (\"interpolate\") is what most users should use unless special \n circumstances warrant.\n statistics : string [\"approximate\"]\n Determines whether the statistical quantities are computed exactly \n (\"exact\") or approximately (\"approximate\"). \"exact\" should only be used \n for testing the approximation in statistical development and is not meant \n for routine usage because computation time can be horrendous.\n trace_hat : string [\"wait.to.decide\"]\n Determines how the trace of the hat matrix should be computed. The hat\n matrix is used in the computation of the statistical quantities. \n If \"exact\", an exact computation is done; this could be slow when the\n number of observations n becomes large. If \"wait.to.decide\" is selected, \n then a default is \"exact\" for n < 500 and \"approximate\" otherwise. \n This option is only useful when the fitted surface is interpolated. If \n surface is \"exact\", an exact computation is always done for the trace. \n Setting trace_hat to \"approximate\" for large dataset will substantially \n reduce the computation time.\n iterations : integer\n Number of iterations of the robust fitting method. If the family is \n \"gaussian\", the number of iterations is set to 0.\n cell : integer\n Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span),\n where n is the number of observations, and span the smoothing parameter.\n Then, a cell is further divided if the number of observations within it \n is greater than or equal to k. This option is only used if the surface \n is interpolated.\n span : float [0.75]\n Smoothing factor, as a fraction of the number of points to take into\n account. \n degree : integer [2]\n Overall degree of locally-fitted polynomial. 1 is locally-linear \n fitting and 2 is locally-quadratic fitting. Degree should be 2 at most.\n normalize : boolean [True]\n Determines whether the independent variables should be normalized. \n If True, the normalization is performed by setting the 10% trimmed \n standard deviation to one. If False, no normalization is carried out. \n This option is only useful for more than one variable. For spatial\n coordinates predictors or variables with a common scale, it should be \n set to False.\n family : string [\"gaussian\"]\n Determines the assumed distribution of the errors. The values are \n \"gaussian\" or \"symmetric\". If \"gaussian\" is selected, the fit is \n performed with least-squares. If \"symmetric\" is selected, the fit\n is performed robustly by redescending M-estimators.\n parametric_flags : sequence [ [False]*p ]\n Indicates which independent variables should be conditionally-parametric\n (if there are two or more independent variables). The argument should \n be a sequence of booleans, with the same size as the number of independent \n variables, specified in the order of the predictor group ordered in x. \n drop_square : sequence [ [False]* p]\n When there are two or more independent variables and when a 2nd order\n polynomial is used, \"drop_square_flags\" specifies those numeric predictors \n whose squares should be dropped from the set of fitting variables. \n The method of specification is the same as for parametric. \n \n:Outputs:\n fitted_values : ndarray\n The (n,) ndarray of fitted values.\n fitted_residuals : ndarray\n The (n,) ndarray of fitted residuals (observations - fitted values).\n enp : float\n Equivalent number of parameters.\n s : float\n Estimate of the scale of residuals.\n one_delta: float\n Statistical parameter used in the computation of standard errors.\n two_delta : float\n Statistical parameter used in the computation of standard errors.\n pseudovalues : ndarray\n The (n,) ndarray of adjusted values of the response when robust estimation \n is used.\n trace_hat : float \n Trace of the operator hat matrix.\n diagonal :\n Diagonal of the operator hat matrix.\n robust : ndarray\n The (n,) ndarray of robustness weights for robust fitting.\n divisor : ndarray\n The (p,) array of normalization divisors for numeric predictors.\n\n ", /*tp_doc*/ + __pyx_tp_traverse_7_mloess_loess, /*tp_traverse*/ + __pyx_tp_clear_7_mloess_loess, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7_mloess_loess, /*tp_methods*/ + __pyx_members_7_mloess_loess, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_f_7_mloess_5loess___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7_mloess_loess, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static PyObject *__pyx_tp_new_7_mloess_anova(PyTypeObject *t, PyObject *a, PyObject *k) { + PyObject *o = (*t->tp_alloc)(t, 0); + return o; +} + +static void __pyx_tp_dealloc_7_mloess_anova(PyObject *o) { + (*o->ob_type->tp_free)(o); +} + +static int __pyx_tp_traverse_7_mloess_anova(PyObject *o, visitproc v, void *a) { + return 0; +} + +static int __pyx_tp_clear_7_mloess_anova(PyObject *o) { + return 0; +} + +static struct PyMethodDef __pyx_methods_7_mloess_anova[] = { + {0, 0, 0, 0} +}; + +static struct PyMemberDef __pyx_members_7_mloess_anova[] = { + {"dfn", T_DOUBLE, offsetof(struct __pyx_obj_7_mloess_anova, dfn), READONLY, 0}, + {"dfd", T_DOUBLE, offsetof(struct __pyx_obj_7_mloess_anova, dfd), READONLY, 0}, + {"F_value", T_DOUBLE, offsetof(struct __pyx_obj_7_mloess_anova, F_value), READONLY, 0}, + {"Pr_F", T_DOUBLE, offsetof(struct __pyx_obj_7_mloess_anova, Pr_F), READONLY, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_anova = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + 0, /*nb_divide*/ + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + 0, /*nb_coerce*/ + 0, /*nb_int*/ + 0, /*nb_long*/ + 0, /*nb_float*/ + 0, /*nb_oct*/ + 0, /*nb_hex*/ + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + 0, /*nb_inplace_divide*/ + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ +}; + +static PySequenceMethods __pyx_tp_as_sequence_anova = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_anova = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_anova = { + 0, /*bf_getreadbuffer*/ + 0, /*bf_getwritebuffer*/ + 0, /*bf_getsegcount*/ + 0, /*bf_getcharbuffer*/ +}; + +PyTypeObject __pyx_type_7_mloess_anova = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + "_mloess.anova", /*tp_name*/ + sizeof(struct __pyx_obj_7_mloess_anova), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_7_mloess_anova, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &__pyx_tp_as_number_anova, /*tp_as_number*/ + &__pyx_tp_as_sequence_anova, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_anova, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_anova, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_7_mloess_anova, /*tp_traverse*/ + __pyx_tp_clear_7_mloess_anova, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_7_mloess_anova, /*tp_methods*/ + __pyx_members_7_mloess_anova, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_f_7_mloess_5anova___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_7_mloess_anova, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ +}; + +static struct PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +static void __pyx_init_filenames(void); /*proto*/ + +PyMODINIT_FUNC init_mloess(void); /*proto*/ +PyMODINIT_FUNC init_mloess(void) { + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + __pyx_init_filenames(); + __pyx_m = Py_InitModule4("_mloess", __pyx_methods, 0, 0, PYTHON_API_VERSION); + if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + __pyx_b = PyImport_AddModule("__builtin__"); + if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}; + __pyx_type_7_mloess_loess_inputs.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_7_mloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_inputs", (PyObject *)&__pyx_type_7_mloess_loess_inputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;} + __pyx_ptype_7_mloess_loess_inputs = &__pyx_type_7_mloess_loess_inputs; + if (PyType_Ready(&__pyx_type_7_mloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_control", (PyObject *)&__pyx_type_7_mloess_loess_control) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;} + __pyx_ptype_7_mloess_loess_control = &__pyx_type_7_mloess_loess_control; + if (PyType_Ready(&__pyx_type_7_mloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_kd_tree", (PyObject *)&__pyx_type_7_mloess_loess_kd_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; goto __pyx_L1;} + __pyx_ptype_7_mloess_loess_kd_tree = &__pyx_type_7_mloess_loess_kd_tree; + __pyx_vtabptr_7_mloess_loess_model = &__pyx_vtable_7_mloess_loess_model; + *(void(**)())&__pyx_vtable_7_mloess_loess_model.setup = (void(*)())__pyx_f_7_mloess_11loess_model_setup; + if (PyType_Ready(&__pyx_type_7_mloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_7_mloess_loess_model.tp_dict, __pyx_vtabptr_7_mloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_model", (PyObject *)&__pyx_type_7_mloess_loess_model) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; goto __pyx_L1;} + __pyx_ptype_7_mloess_loess_model = &__pyx_type_7_mloess_loess_model; + __pyx_vtabptr_7_mloess_loess_outputs = &__pyx_vtable_7_mloess_loess_outputs; + *(void(**)())&__pyx_vtable_7_mloess_loess_outputs.setup = (void(*)())__pyx_f_7_mloess_13loess_outputs_setup; + *(void(**)())&__pyx_vtable_7_mloess_loess_outputs.getoutput = (void(*)())__pyx_f_7_mloess_13loess_outputs_getoutput; + __pyx_type_7_mloess_loess_outputs.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_7_mloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_7_mloess_loess_outputs.tp_dict, __pyx_vtabptr_7_mloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_outputs", (PyObject *)&__pyx_type_7_mloess_loess_outputs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; goto __pyx_L1;} + __pyx_ptype_7_mloess_loess_outputs = &__pyx_type_7_mloess_loess_outputs; + __pyx_vtabptr_7_mloess_conf_intervals = &__pyx_vtable_7_mloess_conf_intervals; + *(void(**)())&__pyx_vtable_7_mloess_conf_intervals.setup = (void(*)())__pyx_f_7_mloess_14conf_intervals_setup; + __pyx_type_7_mloess_conf_intervals.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_7_mloess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_7_mloess_conf_intervals.tp_dict, __pyx_vtabptr_7_mloess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "conf_intervals", (PyObject *)&__pyx_type_7_mloess_conf_intervals) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; goto __pyx_L1;} + __pyx_ptype_7_mloess_conf_intervals = &__pyx_type_7_mloess_conf_intervals; + __pyx_vtabptr_7_mloess_loess_predicted = &__pyx_vtable_7_mloess_loess_predicted; + *(void(**)())&__pyx_vtable_7_mloess_loess_predicted.setup = (void(*)())__pyx_f_7_mloess_15loess_predicted_setup; + __pyx_type_7_mloess_loess_predicted.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_7_mloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;} + if (__Pyx_SetVtable(__pyx_type_7_mloess_loess_predicted.tp_dict, __pyx_vtabptr_7_mloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess_predicted", (PyObject *)&__pyx_type_7_mloess_loess_predicted) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;} + __pyx_ptype_7_mloess_loess_predicted = &__pyx_type_7_mloess_loess_predicted; + __pyx_type_7_mloess_loess.tp_free = _PyObject_GC_Del; + if (PyType_Ready(&__pyx_type_7_mloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "loess", (PyObject *)&__pyx_type_7_mloess_loess) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;} + __pyx_ptype_7_mloess_loess = &__pyx_type_7_mloess_loess; + if (PyType_Ready(&__pyx_type_7_mloess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; goto __pyx_L1;} + if (PyObject_SetAttrString(__pyx_m, "anova", (PyObject *)&__pyx_type_7_mloess_anova) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; goto __pyx_L1;} + __pyx_ptype_7_mloess_anova = &__pyx_type_7_mloess_anova; + __pyx_ptype_7c_numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (!__pyx_ptype_7c_numpy_dtype) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; goto __pyx_L1;} + __pyx_ptype_7c_numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (!__pyx_ptype_7c_numpy_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 81; goto __pyx_L1;} + __pyx_ptype_7c_numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject)); if (!__pyx_ptype_7c_numpy_flatiter) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 90; goto __pyx_L1;} + __pyx_ptype_7c_numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject)); if (!__pyx_ptype_7c_numpy_broadcast) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; goto __pyx_L1;} + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":8 */ + __pyx_1 = __Pyx_Import(__pyx_n_numpy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_numpy, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":9 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (PyObject_SetAttr(__pyx_m, __pyx_n_narray, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":10 */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_numpy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_float_); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + if (PyObject_SetAttr(__pyx_m, __pyx_n_float_, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":11 */ + __pyx_1 = __Pyx_Import(__pyx_n_maskedarray, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_maskedarray, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":12 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_maskedarray); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_masked_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (PyObject_SetAttr(__pyx_m, __pyx_n_marray, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":13 */ + __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_maskedarray); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;} + __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_getmaskarray); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + if (PyObject_SetAttr(__pyx_m, __pyx_n_getmaskarray, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":16 */ + import_array(); + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":39 */ + __pyx_k9; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":636 */ + __pyx_2 = PyFloat_FromDouble(0.95); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;} + __pyx_k10 = __pyx_2; + __pyx_2 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":786 */ + Py_INCREF(Py_None); + __pyx_k11 = Py_None; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":850 */ + __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; goto __pyx_L1;} + __pyx_k12 = __pyx_1; + __pyx_1 = 0; + + /* "/home/backtopop/workspace/pyloess/src/_mloess.pyx":918 */ + return; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + __Pyx_AddTraceback("_mloess"); +} + +static char *__pyx_filenames[] = { + "_mloess.pyx", + "c_numpy.pxd", +}; + +/* Runtime support code */ + +static void __pyx_init_filenames(void) { + __pyx_f = __pyx_filenames; +} + +static int __Pyx_GetStarArgs( + PyObject **args, + PyObject **kwds, + char *kwd_list[], + int nargs, + PyObject **args2, + PyObject **kwds2) +{ + PyObject *x = 0, *args1 = 0, *kwds1 = 0; + + if (args2) + *args2 = 0; + if (kwds2) + *kwds2 = 0; + + if (args2) { + args1 = PyTuple_GetSlice(*args, 0, nargs); + if (!args1) + goto bad; + *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_Size(*args)); + if (!*args2) + goto bad; + } + else { + args1 = *args; + Py_INCREF(args1); + } + + if (kwds2) { + if (*kwds) { + char **p; + kwds1 = PyDict_New(); + if (!kwds) + goto bad; + *kwds2 = PyDict_Copy(*kwds); + if (!*kwds2) + goto bad; + for (p = kwd_list; *p; p++) { + x = PyDict_GetItemString(*kwds, *p); + if (x) { + if (PyDict_SetItemString(kwds1, *p, x) < 0) + goto bad; + if (PyDict_DelItemString(*kwds2, *p) < 0) + goto bad; + } + } + } + else { + *kwds2 = PyDict_New(); + if (!*kwds2) + goto bad; + } + } + else { + kwds1 = *kwds; + Py_XINCREF(kwds1); + } + + *args = args1; + *kwds = kwds1; + return 0; +bad: + Py_XDECREF(args1); + Py_XDECREF(kwds1); + if (*args2) { + Py_XDECREF(*args2); + } + if (*kwds2) { + Py_XDECREF(*kwds2); + } + return -1; +} + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) { + PyObject *__import__ = 0; + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + __import__ = PyObject_GetAttrString(__pyx_b, "__import__"); + if (!__import__) + goto bad; + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + module = PyObject_CallFunction(__import__, "OOOO", + name, global_dict, empty_dict, list); +bad: + Py_XDECREF(empty_list); + Py_XDECREF(__import__); + Py_XDECREF(empty_dict); + return module; +} + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { + PyObject *result; + result = PyObject_GetAttr(dict, name); + if (!result) + PyErr_SetObject(PyExc_NameError, name); + return result; +} + +static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (!type) { + PyErr_Format(PyExc_SystemError, "Missing type object"); + return 0; + } + if (obj == Py_None || PyObject_TypeCheck(obj, type)) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s", + obj->ob_type->tp_name, type->tp_name); + return 0; +} + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { + Py_XINCREF(type); + Py_XINCREF(value); + Py_XINCREF(tb); + /* First, check the traceback argument, replacing None with NULL. */ + if (tb == Py_None) { + Py_DECREF(tb); + tb = 0; + } + else if (tb != NULL && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + /* Next, replace a missing value with None */ + if (value == NULL) { + value = Py_None; + Py_INCREF(value); + } + /* Next, repeatedly, replace a tuple exception with its first item */ + while (PyTuple_Check(type) && PyTuple_Size(type) > 0) { + PyObject *tmp = type; + type = PyTuple_GET_ITEM(type, 0); + Py_INCREF(type); + Py_DECREF(tmp); + } + if (PyString_Check(type)) { + if (PyErr_Warn(PyExc_DeprecationWarning, + "raising a string exception is deprecated")) + goto raise_error; + } + else if (PyType_Check(type) || PyClass_Check(type)) + ; /*PyErr_NormalizeException(&type, &value, &tb);*/ + else { + /* Raising an instance. The value should be a dummy. */ + if (value != Py_None) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + /* Normalize to raise , */ + Py_DECREF(value); + value = type; + if (PyInstance_Check(type)) + type = (PyObject*) ((PyInstanceObject*)type)->in_class; + else + type = (PyObject*) type->ob_type; + Py_INCREF(type); + } + PyErr_Restore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} + +static void __Pyx_UnpackError(void) { + PyErr_SetString(PyExc_ValueError, "unpack sequence of wrong size"); +} + +static PyObject *__Pyx_UnpackItem(PyObject *iter) { + PyObject *item; + if (!(item = PyIter_Next(iter))) { + if (!PyErr_Occurred()) + __Pyx_UnpackError(); + } + return item; +} + +static int __Pyx_EndUnpack(PyObject *iter) { + PyObject *item; + if ((item = PyIter_Next(iter))) { + Py_DECREF(item); + __Pyx_UnpackError(); + return -1; + } + else if (!PyErr_Occurred()) + return 0; + else + return -1; +} + +static PyObject *__Pyx_GetStdout(void) { + PyObject *f = PySys_GetObject("stdout"); + if (!f) { + PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); + } + return f; +} + +static int __Pyx_PrintItem(PyObject *v) { + PyObject *f; + + if (!(f = __Pyx_GetStdout())) + return -1; + if (PyFile_SoftSpace(f, 1)) { + if (PyFile_WriteString(" ", f) < 0) + return -1; + } + if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) + return -1; + if (PyString_Check(v)) { + char *s = PyString_AsString(v); + int len = PyString_Size(v); + if (len > 0 && + isspace(Py_CHARMASK(s[len-1])) && + s[len-1] != ' ') + PyFile_SoftSpace(f, 0); + } + return 0; +} + +static int __Pyx_PrintNewline(void) { + PyObject *f; + + if (!(f = __Pyx_GetStdout())) + return -1; + if (PyFile_WriteString("\n", f) < 0) + return -1; + PyFile_SoftSpace(f, 0); + return 0; +} + +static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) { + while (t->p) { + *t->p = PyString_InternFromString(t->s); + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static int __Pyx_SetVtable(PyObject *dict, void *vtable) { + PyObject *pycobj = 0; + int result; + + pycobj = PyCObject_FromVoidPtr(vtable, 0); + if (!pycobj) + goto bad; + if (PyDict_SetItemString(dict, "__pyx_vtable__", pycobj) < 0) + goto bad; + result = 0; + goto done; + +bad: + result = -1; +done: + Py_XDECREF(pycobj); + return result; +} + +static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, + long size) +{ + PyObject *py_module_name = 0; + PyObject *py_class_name = 0; + PyObject *py_name_list = 0; + PyObject *py_module = 0; + PyObject *result = 0; + + py_module_name = PyString_FromString(module_name); + if (!py_module_name) + goto bad; + py_class_name = PyString_FromString(class_name); + if (!py_class_name) + goto bad; + py_name_list = PyList_New(1); + if (!py_name_list) + goto bad; + Py_INCREF(py_class_name); + if (PyList_SetItem(py_name_list, 0, py_class_name) < 0) + goto bad; + py_module = __Pyx_Import(py_module_name, py_name_list); + if (!py_module) + goto bad; + result = PyObject_GetAttr(py_module, py_class_name); + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%s.%s is not a type object", + module_name, class_name); + goto bad; + } + if (((PyTypeObject *)result)->tp_basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%s.%s does not appear to be the correct type object", + module_name, class_name); + goto bad; + } + goto done; +bad: + Py_XDECREF(result); + result = 0; +done: + Py_XDECREF(py_module_name); + Py_XDECREF(py_class_name); + Py_XDECREF(py_name_list); + return (PyTypeObject *)result; +} + +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" + +static void __Pyx_AddTraceback(char *funcname) { + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + PyObject *py_globals = 0; + PyObject *empty_tuple = 0; + PyObject *empty_string = 0; + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + + py_srcfile = PyString_FromString(__pyx_filename); + if (!py_srcfile) goto bad; + py_funcname = PyString_FromString(funcname); + if (!py_funcname) goto bad; + py_globals = PyModule_GetDict(__pyx_m); + if (!py_globals) goto bad; + empty_tuple = PyTuple_New(0); + if (!empty_tuple) goto bad; + empty_string = PyString_FromString(""); + if (!empty_string) goto bad; + py_code = PyCode_New( + 0, /*int argcount,*/ + 0, /*int nlocals,*/ + 0, /*int stacksize,*/ + 0, /*int flags,*/ + empty_string, /*PyObject *code,*/ + empty_tuple, /*PyObject *consts,*/ + empty_tuple, /*PyObject *names,*/ + empty_tuple, /*PyObject *varnames,*/ + empty_tuple, /*PyObject *freevars,*/ + empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + __pyx_lineno, /*int firstlineno,*/ + empty_string /*PyObject *lnotab*/ + ); + if (!py_code) goto bad; + py_frame = PyFrame_New( + PyThreadState_Get(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + py_globals, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = __pyx_lineno; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + Py_XDECREF(empty_tuple); + Py_XDECREF(empty_string); + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} Added: trunk/Lib/sandbox/pyloess/src/_mloess.pyx =================================================================== --- trunk/Lib/sandbox/pyloess/src/_mloess.pyx 2007-03-26 19:37:12 UTC (rev 2873) +++ trunk/Lib/sandbox/pyloess/src/_mloess.pyx 2007-03-27 06:38:36 UTC (rev 2874) @@ -0,0 +1,958 @@ +# -*- Mode: Python -*- +cimport c_python +cimport c_numpy +from c_numpy cimport ndarray, npy_intp, \ + PyArray_SIZE, PyArray_EMPTY, PyArray_FROMANY, \ + NPY_INT, NPY_DOUBLE, NPY_OWNDATA, NPY_ALIGNED, NPY_FORTRAN, \ + PyArray_SimpleNewFromData +import numpy +narray = numpy.array +float_ = numpy.float_ +import maskedarray +marray = maskedarray.masked_array +getmaskarray = maskedarray.getmaskarray + +# NumPy must be initialized +c_numpy.import_array() + +cimport c_loess + +cdef floatarray_from_data(int rows, int cols, double *data): + cdef ndarray a_ndr + cdef npy_intp size + size = rows*cols + a_ndr = PyArray_SimpleNewFromData(1, &size, NPY_DOUBLE, data) + if cols > 1: + a_ndr.shape = (rows, cols) + return a_ndr + +cdef boolarray_from_data(int rows, int cols, int *data): + cdef ndarray a_ndr + cdef npy_intp size + size = rows*cols + a_ndr = PyArray_SimpleNewFromData(1, &size, NPY_DOUBLE, data) + if cols > 1: + a_ndr.shape = (rows, cols) + return a_ndr.astype(numpy.bool) + + +""" + + + newdata : ndarray + The (m,p) array of independent variables where the surface must be estimated. + values : ndarray + The (m,) ndarray of loess values evaluated at newdata + stderr : ndarray + The (m,) ndarray of the estimates of the standard error on the estimated + values. + residual_scale : float + Estimate of the scale of the residuals + df : integer + Degrees of freedom of the t-distribution used to compute pointwise + confidence intervals for the evaluated surface. + nest : integer + Number of new observations. + + +""" + + +#####--------------------------------------------------------------------------- +#---- ---- loess model --- +#####--------------------------------------------------------------------------- +cdef class loess_inputs: + """Loess inputs + +:IVariables: + x : ndarray + A (n,p) ndarray of independent variables, with n the number of observations + and p the number of variables. + y : ndarray + A (n,) ndarray of observations. + masked : ndarray + A (n,) ndarry of booleans indicating the missing observations and responses. + nobs : integer + Number of observations: nobs=n. + nobs_eff : integer + Number of effective observations. + npar : integer + Number of independent variables: npar=p. + weights : ndarray + A (n,) ndarray of weights to be given to individual observations in the + sum of squared residuals that forms the local fitting criterion. If not + None, the weights should be non negative. If the different observations + have non-equal variances, the weights should be inversely proportional + to the variances. + By default, an unweighted fit is carried out (all the weights are one). + """ + cdef c_loess.c_loess_inputs *_base + cdef ndarray w_ndr + cdef readonly ndarray x, y, masked, x_eff, y_eff + cdef readonly int nobs, nobs_eff, npar + #......... + def __init__(self, x_data, y_data): + cdef ndarray unmasked + self.x = marray(x_data, copy=False, subok=True, dtype=float_, order='C') + self.y = marray(y_data, copy=False, subok=True, dtype=float_, order='C') + # Check the dimensions ........ + if self.x.ndim == 1: + self.npar = 1 + self.masked = maskedarray.mask_or(getmaskarray(self.x), + getmaskarray(self.y), + small_mask=False) + elif self.x.ndim == 2: + self.npar = self.x.shape[-1] + self.masked = maskedarray.mask_or(getmaskarray(self.x).any(axis=1), + getmaskarray(self.y), + small_mask=False) + else: + raise ValueError("The array of indepedent varibales should be 2D at most!") + self.nobs = len(self.x) + self.nobs_eff = self.nobs - self.masked.sum() + # Get the effective data ...... + unmasked = numpy.logical_not(self.masked) + self.x_eff = self.x[unmasked].ravel() + self.y_eff = self.y[unmasked] + self.w_ndr = numpy.ones((self.nobs,), dtype=float_) + #......... + property weights: + """A (n,) ndarray of weights to be given to individual observations in the + sum of squared residuals that forms the local fitting criterion. If not + None, the weights should be non negative. If the different observations + have non-equal variances, the weights should be inversely proportional + to the variances. + By default, an unweighted fit is carried out (all the weights are one). + """ + def __get__(self): + return self.w_ndr + + def __set__(self, w): + cdef npy_intp *dims + cdef ndarray w_ndr, unmasked + unmasked = numpy.logical_not(self.masked) + w_ndr = narray(w, copy=False, subok=False, dtype=float_) + if w_ndr.ndim > 1 or w_ndr.size != self.nobs: + raise ValueError, "Invalid size of the 'weights' vector!" + self.w_ndr = w_ndr + self._base.weights = w_ndr[unmasked].data + +######--------------------------------------------------------------------------- +##---- ---- loess control --- +######--------------------------------------------------------------------------- +cdef class loess_control: + """Loess control parameters. + +:IVariables: + surface : string ["interpolate"] + Determines whether the fitted surface is computed directly at all points + ("direct") or whether an interpolation method is used ("interpolate"). + The default ("interpolate") is what most users should use unless special + circumstances warrant. + statistics : string ["approximate"] + Determines whether the statistical quantities are computed exactly + ("exact") or approximately ("approximate"). "exact" should only be used + for testing the approximation in statistical development and is not meant + for routine usage because computation time can be horrendous. + trace_hat : string ["wait.to.decide"] + Determines how the trace of the hat matrix should be computed. The hat + matrix is used in the computation of the statistical quantities. + If "exact", an exact computation is done; this could be slow when the + number of observations n becomes large. If "wait.to.decide" is selected, + then a default is "exact" for n < 500 and "approximate" otherwise. + This option is only useful when the fitted surface is interpolated. If + surface is "exact", an exact computation is always done for the trace. + Setting trace_hat to "approximate" for large dataset will substantially + reduce the computation time. + iterations : integer + Number of iterations of the robust fitting method. If the family is + "gaussian", the number of iterations is set to 0. + cell : integer + Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span), + where n is the number of observations, and span the smoothing parameter. + Then, a cell is further divided if the number of observations within it + is greater than or equal to k. This option is only used if the surface + is interpolated. + + """ + cdef c_loess.c_loess_control *_base + #......... + property surface: + """ + surface : string ["interpolate"] + Determines whether the fitted surface is computed directly at all points + ("direct") or whether an interpolation method is used ("interpolate"). + The default ("interpolate") is what most users should use unless special + circumstances warrant. + """ + def __get__(self): + return self._base.surface + def __set__(self, surface): + if surface.lower() not in ('interpolate', 'direct'): + raise ValueError("Invalid value for the 'surface' argument: "+ + "should be in ('interpolate', 'direct').") + tmpx = surface.lower() + self._base.surface = tmpx + #......... + property statistics: + """ + statistics : string ["approximate"] + Determines whether the statistical quantities are computed exactly + ("exact") or approximately ("approximate"). "exact" should only be used + for testing the approximation in statistical development and is not meant + for routine usage because computation time can be horrendous. + """ + def __get__(self): + return self._base.statistics + def __set__(self, statistics): + if statistics.lower() not in ('approximate', 'exact'): + raise ValueError("Invalid value for the 'statistics' argument: "\ + "should be in ('approximate', 'exact').") + tmpx = statistics.lower() + self._base.statistics = tmpx + #......... + property trace_hat: + """ + trace_hat : string ["wait.to.decide"] + Determines how the trace of the hat matrix should be computed. The hat + matrix is used in the computation of the statistical quantities. + If "exact", an exact computation is done; this could be slow when the + number of observations n becomes large. If "wait.to.decide" is selected, + then a default is "exact" for n < 500 and "approximate" otherwise. + This option is only useful when the fitted surface is interpolated. If + surface is "exact", an exact computation is always done for the trace. + Setting trace_hat to "approximate" for large dataset will substantially + reduce the computation time. + """ + def __get__(self): + return self._base.trace_hat + def __set__(self, trace_hat): + if trace_hat.lower() not in ('approximate', 'exact'): + raise ValueError("Invalid value for the 'trace_hat' argument: "\ + "should be in ('approximate', 'exact').") + tmpx = trace_hat.lower() + self._base.trace_hat = tmpx + #......... + property iterations: + """ + iterations : integer + Number of iterations of the robust fitting method. If the family is + "gaussian", the number of iterations is set to 0. + """ + def __get__(self): + return self._base.iterations + def __set__(self, iterations): + if iterations < 0: + raise ValueError("Invalid number of iterations: should be positive") + self._base.iterations = iterations + #......... + property cell: + """ + cell : integer + Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span), + where n is the number of observations, and span the smoothing parameter. + Then, a cell is further divided if the number of observations within it + is greater than or equal to k. This option is only used if the surface + is interpolated. + """ + def __get__(self): + return self._base.cell + def __set__(self, cell): + if cell <= 0: + raise ValueError("Invalid value for the cell argument: should be positive") + self._base.cell = cell + #......... + def update(self, **cellargs): + """Updates several parameters at once.""" + surface = cellargs.get('surface', None) + if surface is not None: + self.surface = surface + # + statistics = cellargs.get('statistics', None) + if statistics is not None: + self.statistics = statistics + # + trace_hat = cellargs.get('trace_hat', None) + if trace_hat is not None: + self.trace_hat = trace_hat + # + iterations = cellargs.get('iterations', None) + if iterations is not None: + self.iterations = iterations + # + cell = cellargs.get('cell', None) + if cell is not None: + self.parametric_flags = cell + # + #......... + def __str__(self): + strg = ["Control :", + "Surface type : %s" % self.surface, + "Statistics : %s" % self.statistics, + "Trace estimation : %s" % self.trace_hat, + "Cell size : %s" % self.cell, + "Nb iterations : %s" % self.iterations,] + return '\n'.join(strg) + +# +######--------------------------------------------------------------------------- +##---- ---- loess kd_tree --- +######--------------------------------------------------------------------------- +cdef class loess_kd_tree: + cdef c_loess.c_loess_kd_tree *_base + +######--------------------------------------------------------------------------- +##---- ---- loess model --- +######--------------------------------------------------------------------------- +cdef class loess_model: + """loess_model contains parameters required for a loess fit. + +:IVariables: + normalize : boolean [True] + Determines whether the independent variables should be normalized. + If True, the normalization is performed by setting the 10% trimmed + standard deviation to one. If False, no normalization is carried out. + This option is only useful for more than one variable. For spatial + coordinates predictors or variables with a common scale, it should be + set to False. + span : float [0.75] + Smoothing factor, as a fraction of the number of points to take into + account. + degree : integer [2] + Overall degree of locally-fitted polynomial. 1 is locally-linear + fitting and 2 is locally-quadratic fitting. Degree should be 2 at most. + family : string ["gaussian"] + Determines the assumed distribution of the errors. The values are + "gaussian" or "symmetric". If "gaussian" is selected, the fit is + performed with least-squares. If "symmetric" is selected, the fit + is performed robustly by redescending M-estimators. + parametric_flags : sequence [ [False]*p ] + Indicates which independent variables should be conditionally-parametric + (if there are two or more independent variables). The argument should be + a sequence of booleans, with the same size as the number of independent + variables, specified in the order of the predictor group ordered in x. + Note: elements of the sequence cannot be modified individually: the whole + sequence must be given. + drop_square : sequence [ [False]* p] + When there are two or more independent variables and when a 2nd order + polynomial is used, "drop_square_flags" specifies those numeric predictors + whose squares should be dropped from the set of fitting variables. + The method of specification is the same as for parametric. + Note: elements of the sequence cannot be modified individually: the whole + sequence must be given. + + """ + + cdef c_loess.c_loess_model *_base + cdef long npar + #......... + cdef setup(self, c_loess.c_loess_model *base, long npar): + self._base = base + self.npar = npar + return self + #......... + property normalize: + def __get__(self): + return bool(self._base.normalize) + def __set__(self, normalize): + self._base.normalize = normalize + #......... + property span: + def __get__(self): + return self._base.span + def __set__(self, span): + if span <= 0. or span > 1.: + raise ValueError("Span should be between 0 and 1!") + self._base.span = span + #......... + property degree: + def __get__(self): + return self._base.degree + def __set__(self, degree): + if degree < 0 or degree > 2: + raise ValueError("Degree should be between 0 and 2!") + self._base.degree = degree + #......... + property family: + def __get__(self): + return self._base.family + def __set__(self, family): + if family.lower() not in ('symmetric', 'gaussian'): + raise ValueError("Invalid value for the 'family' argument: "\ + "should be in ('symmetric', 'gaussian').") + self._base.family = family + #......... + property parametric_flags: + def __get__(self): + return boolarray_from_data(self.npar, 1, self._base.parametric) + def __set__(self, paramf): + cdef ndarray p_ndr + cdef int i + p_ndr = numpy.atleast_1d(narray(paramf, copy=False, subok=True, + dtype=numpy.bool)) + for i from 0 <= i < min(self.npar, p_ndr.size): + self._base.parametric[i] = p_ndr[i] + #......... + property drop_square_flags: + def __get__(self): + return boolarray_from_data(self.npar, 1, self._base.drop_square) + def __set__(self, drop_sq): + cdef ndarray d_ndr + cdef int i + d_ndr = numpy.atleast_1d(narray(drop_sq, copy=False, subok=True, + dtype=numpy.bool)) + for i from 0 <= i < min(self.npar, d_ndr.size): + self._base.drop_square[i] = d_ndr[i] + #........ + def update(self, **modelargs): + family = modelargs.get('family', None) + if family is not None: + self.family = family + # + span = modelargs.get('span', None) + if span is not None: + self.span = span + # + degree = modelargs.get('degree', None) + if degree is not None: + self.degree = degree + # + normalize = modelargs.get('normalize', None) + if normalize is not None: + self.normalize = normalize + # + parametric = modelargs.get('parametric', None) + if parametric is not None: + self.parametric_flags = parametric + # + drop_square = modelargs.get('drop_square', None) + if drop_square is not None: + self.drop_square_flags = drop_square + #......... + def __repr__(self): + return "" + #......... + def __str__(self): + strg = ["Model parameters.....", + "Family : %s" % self.family, + "Span : %s" % self.span, + "Degree : %s" % self.degree, + "Normalized : %s" % self.normalize, + "Parametric : %s" % self.parametric_flags[:self.npar], + "Drop_square : %s" % self.drop_square_flags[:self.npar] + ] + return '\n'.join(strg) + +#####--------------------------------------------------------------------------- +#---- ---- loess outputs --- +#####--------------------------------------------------------------------------- +cdef class loess_outputs: + """Outputs of a loess fit. This object is automatically created with empty +values when a new loess object is instantiated. The object gets filled when the +loess.fit() method is called. + +:IVariables: + fitted_values : ndarray + The (n,) ndarray of fitted values. + fitted_residuals : ndarray + The (n,) ndarray of fitted residuals (observations - fitted values). + enp : float + Equivalent number of parameters. + s : float + Estimate of the scale of residuals. + one_delta: float + Statistical parameter used in the computation of standard errors. + two_delta : float + Statistical parameter used in the computation of standard errors. + pseudovalues : ndarray + The (n,) ndarray of adjusted values of the response when robust estimation + is used. + trace_hat : float + Trace of the operator hat matrix. + diagonal : ndarray + Diagonal of the operator hat matrix. + robust : ndarray + The (n,) ndarray of robustness weights for robust fitting. + divisor : ndarray + The (p,) array of normalization divisors for numeric predictors. + """ + cdef c_loess.c_loess_outputs *_base + cdef long nobs, nobs_eff, npar + cdef ndarray masked, unmasked + cdef readonly int activated, ismasked + # + cdef setup(self,c_loess.c_loess_outputs *base, + long nobs, long nobs_eff, long npar, ndarray mask): + self._base = base + self.nobs = nobs + self.nobs_eff = nobs_eff + self.npar = npar + self.masked = mask + self.unmasked = numpy.logical_not(mask) + self.activated = False + self.ismasked = mask.any() + #........ + cdef ndarray getoutput(self, double *data): + cdef ndarray out_ndr, tmp_ndr + tmp_ndr = floatarray_from_data(self.nobs_eff, 1, data) + if not self.ismasked: + return tmp_ndr + out_ndr = marray(numpy.empty((self.nobs,), float_), mask=self.masked) + out_ndr[self.unmasked] = tmp_ndr.flat + return out_ndr + #........ + property fitted_values: + def __get__(self): + return self.getoutput(self._base.fitted_values) + #......... + property fitted_residuals: + def __get__(self): + return self.getoutput(self._base.fitted_residuals) + #......... + property pseudovalues: + def __get__(self): + return self.getoutput(self._base.pseudovalues) + #......... + property diagonal: + def __get__(self): + return self.getoutput(self._base.diagonal) + #......... + property robust: + def __get__(self): + return self.getoutput(self._base.robust) + #......... + property divisor: + def __get__(self): + return floatarray_from_data(self.npar, 1, self._base.divisor) + #......... + property enp: + def __get__(self): + return self._base.enp + #......... + property s: + def __get__(self): + return self._base.s + #......... + property one_delta: + def __get__(self): + return self._base.one_delta + #......... + property two_delta: + def __get__(self): + return self._base.two_delta + #......... + property trace_hat: + def __get__(self): + return self._base.trace_hat + #......... + def __str__(self): + strg = ["Outputs................", + "Fitted values : %s\n" % self.fitted_values, + "Fitted residuals : %s\n" % self.fitted_residuals, + "Eqv. nb of parameters : %s" % self.enp, + "Residual error : %s" % self.s, + "Deltas : %s - %s" % (self.one_delta, self.two_delta), + "Normalization factors : %s" % self.divisor,] + return '\n'.join(strg) + + + +#####--------------------------------------------------------------------------- +#---- ---- loess confidence --- +#####--------------------------------------------------------------------------- +cdef class conf_intervals: + """Pointwise confidence intervals of a loess-predicted object: + +:IVariables: + fit : ndarray + Predicted values. + lower : ndarray + Lower bounds of the confidence intervals. + upper : ndarray + Upper bounds of the confidence intervals. + """ + cdef c_loess.c_conf_inv _base + cdef readonly ndarray lower, fit, upper + #......... + def __dealloc__(self): + c_loess.pw_free_mem(&self._base) + #......... + cdef setup(self, c_loess.c_conf_inv base, long nest): + self._base = base + self.fit = floatarray_from_data(nest, 1, base.fit) + self.upper = floatarray_from_data(nest, 1, base.upper) + self.lower = floatarray_from_data(nest, 1, base.lower) + #......... + def __str__(self): + cdef ndarray tmp_ndr + tmp_ndr = numpy.r_[[self.lower,self.fit,self.upper]].T + return "Confidence intervals....\nLower b./ fit / upper b.\n%s" % \ + tmp_ndr + +#####--------------------------------------------------------------------------- +#---- ---- loess predictions --- +#####--------------------------------------------------------------------------- +cdef class loess_predicted: + """Predicted values and standard errors of a loess object + +:IVariables: + values : ndarray + The (m,) ndarray of loess values evaluated at newdata + stderr : ndarray + The (m,) ndarray of the estimates of the standard error on the estimated + values. + residual_scale : float + Estimate of the scale of the residuals + df : integer + Degrees of freedom of the t-distribution used to compute pointwise + confidence intervals for the evaluated surface. + nest : integer + Number of new observations. + """ + + cdef c_loess.c_prediction _base + cdef readonly long nest + cdef readonly conf_intervals confidence_intervals + #......... + def __dealloc__(self): + c_loess.pred_free_mem(&self._base) + #......... + cdef setup(self, c_loess.c_prediction base, long nest): + self._base = base + self.nest = nest + #......... + property values: + def __get__(self): + return floatarray_from_data(self.nest, 1, self._base.fit) + #......... + property stderr: + def __get__(self): + return floatarray_from_data(self.nest, 1, self._base.se_fit) + #......... + property residual_scale: + def __get__(self): + return self._base.residual_scale + #......... + property df: + def __get__(self): + return self._base.df + #......... + def confidence(self, coverage=0.95): + """Returns the pointwise confidence intervals for each predicted values, +at the given confidence interval coverage. + +:Parameters: + coverage : float + Confidence level of the confidence intervals limits, as a fraction. + +:Returns: + A new conf_intervals object, consisting of: + fit : ndarray + Predicted values. + lower : ndarray + Lower bounds of the confidence intervals. + upper : ndarray + Upper bounds of the confidence intervals. + """ + cdef c_loess.c_conf_inv _confintv + if coverage < 0.5: + coverage = 1. - coverage + if coverage > 1. : + raise ValueError("The coverage precentage should be between 0 and 1!") + c_loess.c_pointwise(&self._base, self.nest, coverage, &_confintv) + self.confidence_intervals = conf_intervals() + self.confidence_intervals.setup(_confintv, self.nest) + return self.confidence_intervals + #......... + def __str__(self): + strg = ["Outputs................", + "Predicted values : %s\n" % self.values, + "Predicted std error : %s\n" % self.stderr, + "Residual scale : %s" % self.residual_scale, + "Degrees of freedom : %s" % self.df, +# "Confidence intervals : %s" % self.confidence, + ] + return '\n'.join(strg) + + +#####--------------------------------------------------------------------------- +#---- ---- loess base class --- +#####--------------------------------------------------------------------------- +cdef class loess: + """ + +:Keywords: + x : ndarray + A (n,p) ndarray of independent variables, with n the number of observations + and p the number of variables. + y : ndarray + A (n,) ndarray of observations + weights : ndarray + A (n,) ndarray of weights to be given to individual observations in the + sum of squared residuals that forms the local fitting criterion. If not + None, the weights should be non negative. If the different observations + have non-equal variances, the weights should be inversely proportional + to the variances. + By default, an unweighted fit is carried out (all the weights are one). + surface : string ["interpolate"] + Determines whether the fitted surface is computed directly at all points + ("direct") or whether an interpolation method is used ("interpolate"). + The default ("interpolate") is what most users should use unless special + circumstances warrant. + statistics : string ["approximate"] + Determines whether the statistical quantities are computed exactly + ("exact") or approximately ("approximate"). "exact" should only be used + for testing the approximation in statistical development and is not meant + for routine usage because computation time can be horrendous. + trace_hat : string ["wait.to.decide"] + Determines how the trace of the hat matrix should be computed. The hat + matrix is used in the computation of the statistical quantities. + If "exact", an exact computation is done; this could be slow when the + number of observations n becomes large. If "wait.to.decide" is selected, + then a default is "exact" for n < 500 and "approximate" otherwise. + This option is only useful when the fitted surface is interpolated. If + surface is "exact", an exact computation is always done for the trace. + Setting trace_hat to "approximate" for large dataset will substantially + reduce the computation time. + iterations : integer + Number of iterations of the robust fitting method. If the family is + "gaussian", the number of iterations is set to 0. + cell : integer + Maximum cell size of the kd-tree. Suppose k = floor(n*cell*span), + where n is the number of observations, and span the smoothing parameter. + Then, a cell is further divided if the number of observations within it + is greater than or equal to k. This option is only used if the surface + is interpolated. + span : float [0.75] + Smoothing factor, as a fraction of the number of points to take into + account. + degree : integer [2] + Overall degree of locally-fitted polynomial. 1 is locally-linear + fitting and 2 is locally-quadratic fitting. Degree should be 2 at most. + normalize : boolean [True] + Determines whether the independent variables should be normalized. + If True, the normalization is performed by setting the 10% trimmed + standard deviation to one. If False, no normalization is carried out. + This option is only useful for more than one variable. For spatial + coordinates predictors or variables with a common scale, it should be + set to False. + family : string ["gaussian"] + Determines the assumed distribution of the errors. The values are + "gaussian" or "symmetric". If "gaussian" is selected, the fit is + performed with least-squares. If "symmetric" is selected, the fit + is performed robustly by redescending M-estimators. + parametric_flags : sequence [ [False]*p ] + Indicates which independent variables should be conditionally-parametric + (if there are two or more independent variables). The argument should + be a sequence of booleans, with the same size as the number of independent + variables, specified in the order of the predictor group ordered in x. + drop_square : sequence [ [False]* p] + When there are two or more independent variables and when a 2nd order + polynomial is used, "drop_square_flags" specifies those numeric predictors + whose squares should be dropped from the set of fitting variables. + The method of specification is the same as for parametric. + +:Outputs: + fitted_values : ndarray + The (n,) ndarray of fitted values. + fitted_residuals : ndarray + The (n,) ndarray of fitted residuals (observations - fitted values). + enp : float + Equivalent number of parameters. + s : float + Estimate of the scale of residuals. + one_delta: float + Statistical parameter used in the computation of standard errors. + two_delta : float + Statistical parameter used in the computation of standard errors. + pseudovalues : ndarray + The (n,) ndarray of adjusted values of the response when robust estimation + is used. + trace_hat : float + Trace of the operator hat matrix. + diagonal : + Diagonal of the operator hat matrix. + robust : ndarray + The (n,) ndarray of robustness weights for robust fitting. + divisor : ndarray + The (p,) array of normalization divisors for numeric predictors. + + """ + cdef c_loess.c_loess _base + cdef readonly loess_inputs inputs + cdef readonly loess_model model + cdef readonly loess_control control + cdef readonly loess_kd_tree kd_tree + cdef readonly loess_outputs outputs + cdef readonly loess_predicted predicted + cdef public long nobs, npar + + def __init__(self, object x, object y, object weights=None, **options): + # + cdef ndarray x_ndr, y_ndr, m_ndr + cdef double *x_dat, *y_dat + cdef int i + # Initialize the inputs ....... + self.inputs = loess_inputs(x, y) + x_dat = self.inputs.x_eff.data + y_dat = self.inputs.y_eff.data + n = self.inputs.nobs_eff + p = self.inputs.npar + c_loess.loess_setup(x_dat, y_dat, n, p, &self._base) + # Sets the _base input ......... + self.inputs._base = &self._base.inputs + # Initialize the model parameters + self.model = loess_model() + self.model.setup(&self._base.model, p) + # Initialize the control parameters + self.control = loess_control() + self.control._base = &self._base.control + # Initialize the kd tree ...... + self.kd_tree = loess_kd_tree() + self.kd_tree._base = &self._base.kd_tree + # Initialize the outputs ...... + self.outputs = loess_outputs() + self.outputs.setup(&self._base.outputs, + self.inputs.nobs, n, p, self.inputs.masked) + # Process options ............. + modelopt = {} + controlopt = {} + for (k,v) in options.iteritems(): + if k in ('family', 'span', 'degree', 'normalize', + 'parametric', 'drop_square',): + modelopt[k] = v + elif k in ('surface', 'statistics', 'trace_hat', + 'iterations', 'cell'): + controlopt[k] = v + self.control.update(**controlopt) + self.model.update(**modelopt) + #...................................................... + def fit(self): + """Computes the loess parameters on the current inputs and sets of parameters.""" + c_loess.loess_fit(&self._base) + self.outputs.activated = True + if self._base.status.err_status: + raise ValueError(self._base.status.err_msg) + return + #...................................................... + def inputs_summary(self): + """Returns some generic information about the loess parameters. + """ + toprint = [str(self.inputs), str(self.model), str(self.control)] + return "\n".join(toprint) + + def outputs_summary(self): + """Returns some generic information about the loess fit.""" + print "Number of Observations : %d" % self.inputs.nobs + print "Fit flag : %d" % bool(self.outputs.activated) + print "Equivalent Number of Parameters: %.1f" % self.outputs.enp + if self.model.family == "gaussian": + print "Residual Standard Error : %.4f" % self.outputs.s + else: + print "Residual Scale Estimate : %.4f" % self.outputs.s + #...................................................... + def predict(self, newdata, stderror=False): + """Computes loess estimates at the given new data points newdata. Returns +a loess_predicted object, whose attributes are described below. + +:Parameters: + newdata : ndarray + The (m,p) array of independent variables where the surface must be estimated, + with m the number of new data points, and p the number of independent + variables. + stderror : boolean + Whether the standard error should be computed + +:Returns: + A new loess_predicted object, consisting of: + values : ndarray + The (m,) ndarray of loess values evaluated at newdata + stderr : ndarray + The (m,) ndarray of the estimates of the standard error on the estimated + values. + residual_scale : float + Estimate of the scale of the residuals + df : integer + Degrees of freedom of the t-distribution used to compute pointwise + confidence intervals for the evaluated surface. + nest : integer + Number of new observations. + """ + cdef ndarray p_ndr + cdef double *p_dat + cdef c_loess.c_prediction _prediction + cdef int i, m + # Make sure there's been a fit earlier ... + if self.outputs.activated == 0: + c_loess.loess_fit(&self._base) + self.outputs.activated = True + if self._base.status.err_status: + raise ValueError(self._base.status.err_msg) + # Note : we need a copy as we may have to normalize + p_ndr = narray(newdata, copy=True, subok=True, order='C').ravel() + p_dat = p_ndr.data + # Test the compatibility of sizes ....... + if p_ndr.size == 0: + raise ValueError("Can't predict without input data !") + (m, notOK) = divmod(len(p_ndr), self.inputs.npar) + if notOK: + raise ValueError( + "Incompatible data size: there should be as many rows as parameters") + #..... + c_loess.c_predict(p_dat, m, &self._base, &_prediction, stderror) + if self._base.status.err_status: + raise ValueError(self._base.status.err_msg) + self.predicted = loess_predicted() + self.predicted._base = _prediction + self.predicted.nest = m +# self.predicted.setup(_prediction, m) + return self.predicted + #......... + def __dealloc__(self): + c_loess.loess_free_mem(&self._base) + #...................................................... + + +#####--------------------------------------------------------------------------- +#---- ---- loess anova --- +#####--------------------------------------------------------------------------- +cdef class anova: + cdef readonly double dfn, dfd, F_value, Pr_F + # + def __init__(self, loess_one, loess_two): + cdef double one_d1, one_d2, one_s, two_d1, two_d2, two_s, rssdiff,\ + d1diff, tmp, df1, df2 + # + if not isinstance(loess_one, loess) or not isinstance(loess_two, loess): + raise ValueError("Arguments should be valid loess objects!"\ + "got '%s' instead" % type(loess_one)) + # + out_one = loess_one.outputs + out_two = loess_two.outputs + # + one_d1 = out_one.one_delta + one_d2 = out_one.two_delta + one_s = out_one.s + # + two_d1 = out_two.one_delta + two_d2 = out_two.two_delta + two_s = out_two.s + # + rssdiff = abs(one_s * one_s * one_d1 - two_s * two_s * two_d1) + d1diff = abs(one_d1 - two_d1) + self.dfn = d1diff * d1diff / abs(one_d2 - two_d2) + df1 = self.dfn + # + if out_one.enp > out_two.enp: + self.dfd = one_d1 * one_d1 / one_d2 + tmp = one_s + else: + self.dfd = two_d1 * two_d1 / two_d2 + tmp = two_s + df2 = self.dfd + F_value = (rssdiff / d1diff) / (tmp * tmp) + + self.Pr_F = 1. - c_loess.ibeta(F_value*df1/(df2+F_value*df1), df1/2, df2/2) + self.F_value = F_value + + \ No newline at end of file Modified: trunk/Lib/sandbox/pyloess/src/c_python.pxd =================================================================== --- trunk/Lib/sandbox/pyloess/src/c_python.pxd 2007-03-26 19:37:12 UTC (rev 2873) +++ trunk/Lib/sandbox/pyloess/src/c_python.pxd 2007-03-27 06:38:36 UTC (rev 2874) @@ -20,3 +20,5 @@ void Py_CLEAR(object o) # use instead of decref object PyList_New(int size) + object PyCObject_FromVoidPtr(void *, void (*)(void *)) + void *PyCObject_AsVoidPtr(object) Added: trunk/Lib/sandbox/pyloess/tests/test_mpyloess.py =================================================================== --- trunk/Lib/sandbox/pyloess/tests/test_mpyloess.py 2007-03-26 19:37:12 UTC (rev 2873) +++ trunk/Lib/sandbox/pyloess/tests/test_mpyloess.py 2007-03-27 06:38:36 UTC (rev 2874) @@ -0,0 +1,439 @@ +""" +Test series for lowess, stl and loess routines. + +:author: Pierre GF Gerard-Marchant +:contact: pierregm_at_uga_edu +:date: $Date$ +:version: $Id$ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author$)" +__version__ = '1.0' +__revision__ = "$Revision$" +__date__ = '$Date$' + +import os + +import numpy +from numpy import bool_, complex_, float_, int_, str_, object_ +import numpy.core.numeric as numeric +fromiter = numpy.fromiter + +import maskedarray +marray = maskedarray.masked_array +masked_values = maskedarray.masked_values + +from numpy.testing import NumpyTest, NumpyTestCase +from maskedarray.testutils import build_err_msg, \ + assert_equal, assert_almost_equal + + +import mpyloess +reload(mpyloess) +from mpyloess import lowess, stl, loess, loess_anova + +#####--------------------------------------------------------------------------- +#---- --- LOWESS --- +#####--------------------------------------------------------------------------- +class test_lowess(NumpyTestCase): + "Test class for lowess." + # + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + X = marray([ 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8,10,12,14,50]) + Y = marray([18, 2,15, 6,10, 4,16,11, 7, 3,14,17,20,12, 9,13, 1, 8, 5,19]) + idx = X.argsort() + self.data = (X[idx], Y[idx]) + #............................................ + def test_lowess_1(self): + "Tests lowess on typical data. part #1." + (X, Y) = self.data + YS = [13.659,11.145, 8.701, 9.722,10.000,11.300,11.300,11.300, + 11.300,11.300,11.300,11.300,11.300,11.300,11.300,13.000, + 6.440, 5.596, 5.456,18.998] + Z = lowess(X, Y, span=0.25, nsteps=0, delta=0) + assert_almost_equal(Z.outputs.fitted_values, YS, decimal=3) + assert_almost_equal(Z.outputs.fitted_residuals+Z.outputs.fitted_values, + Z.inputs.y, decimal=3) + #............................................ + def test_lowess_2(self): + "Tests lowess on typical data. part #2." + (X, Y) = self.data + YS = [13.659,12.347,11.034, 9.722,10.511,11.300,11.300,11.300, + 11.300,11.300,11.300,11.300,11.300,11.300,11.300,13.000, + 6.440, 5.596, 5.456,18.998] + Z = lowess(X, Y, span=0.25, nsteps=0, delta=3) + assert_almost_equal(Z.outputs.fitted_values, YS, decimal=3) + assert_almost_equal(Z.outputs.fitted_residuals+Z.outputs.fitted_values, + Z.inputs.y, decimal=3) + #............................................ + def test_lowess_3(self): + "Tests lowess on typical data. part #3." + (X, Y) = self.data + YS = [14.811,12.115, 8.984, 9.676,10.000,11.346,11.346,11.346, + 11.346,11.346,11.346,11.346,11.346,11.346,11.346,13.000, + 6.734, 5.744, 5.415,18.998 ] + Z = lowess(X, Y, span=0.25, nsteps=2, delta=0) + assert_almost_equal(Z.outputs.fitted_values, YS, decimal=3) + assert_almost_equal(Z.outputs.fitted_residuals+Z.outputs.fitted_values, + Z.inputs.y, decimal=3) + #............................................ + def test_lowess_4(self): + "Tests lowess on masked data." + X = masked_values([ 1, 2, 3, 4, 5,-999, 6, 6, 6, 6, -999,-999, + 6, 6, 6, 6, 6, 6, 8,-999,10,12,14,50,-999],-999) + Y = marray([18, 2,15, 6,10,-999, 4, 16,11, 7, -999,-999, + 3,14,17,20,12, 9,13,-999, 1, 8, 5,19,-999]) + YS = [14.811,12.115, 8.984, 9.676,10.000,11.346,11.346,11.346, + 11.346,11.346,11.346,11.346,11.346,11.346,11.346,13.000, + 6.734, 5.744, 5.415,18.998 ] + Z = lowess(X, Y, span=0.25, nsteps=2, delta=0) + assert_almost_equal(Z.outputs.fitted_values.compressed(), YS, decimal=3) + assert_almost_equal(Z.outputs.fitted_residuals + Z.outputs.fitted_values, + Z.inputs.y, decimal=3) +# + +#####--------------------------------------------------------------------------- +#---- --- STL --- +#####--------------------------------------------------------------------------- +class test_stl(NumpyTestCase): + "Tests STL." + # + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + # Get CO2 data ................ + filename = os.path.join('tests','co2_data') + F = open(filename, 'r') + data = [] + for line in F.readlines(): + data.append([float(x) for x in line.rstrip().split()]) + co2_data = numpy.concatenate(data) + # Get CO2 results ............. + filename = os.path.join('tests','co2_results_double') + F = open(filename, 'r') + co2_results = [] + for line in F.readlines(): + co2_results.append(fromiter((float(x) for x in line.rstrip().split()), + float_)) + # + parameters = dict(np=12, ns=35, nt=19, nl=13, no=2, ni=1, + nsjump=4, ntjump=2, nljump=2, + isdeg=1, itdeg=1, ildeg=1) + self.d = (co2_data, co2_results, parameters) + #............................................ + def test_stl_1(self): + "Tests a classic STL." + (co2_data, co2_results, parameters) = self.d + co2_fitted = stl(co2_data, robust=False, **parameters).outputs + assert_almost_equal(co2_fitted.seasonal, co2_results[0], 6) + assert_almost_equal(co2_fitted.trend, co2_results[1], 6) + assert_almost_equal(co2_fitted.weights, co2_results[2], 6) + #............................................ + def test_stl_2(self): + "Tests a robust STL." + (co2_data, co2_results, parameters) = self.d + co2_fitted = stl(co2_data, robust=True, **parameters).outputs + assert_almost_equal(co2_fitted.seasonal, co2_results[4], 6) + assert_almost_equal(co2_fitted.trend, co2_results[5], 6) + assert_almost_equal(co2_fitted.weights, co2_results[6], 6) + + +#####--------------------------------------------------------------------------- +#---- --- LOESS --- +#####--------------------------------------------------------------------------- + +class test_loess2d(NumpyTestCase): + "Test class for lowess." + # + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + dfile = open(os.path.join('tests','madeup_data'), 'r') + dfile.readline() + x = fromiter((float(v) for v in dfile.readline().rstrip().split()), + float_).reshape(-1,2) + x = marray(x) + dfile.readline() + y = fromiter((float(v) for v in dfile.readline().rstrip().split()), + float_) + y = marray(y) + # + rfile = open(os.path.join('tests','madeup_result'), 'r') + results = [] + for i in range(8): + rfile.readline() + z = fromiter((float(v) for v in rfile.readline().rstrip().split()), + float_) + results.append(z) + # + newdata1 = numpy.array([[-2.5, 0.0, 2.5], [0., 0., 0.]]) + newdata2 = numpy.array([[-0.5, 0.5], [0., 0.]]) + # + madeup = loess(x,y) + self.d = (x, y, results, newdata1, newdata2, madeup) + # + def test_2dbasic(self): + "2D standard" + (x, y, results, _, _, madeup) = self.d + madeup = loess(x,y) + madeup.model.span = 0.5 + madeup.model.normalize = True + madeup.fit() + assert_almost_equal(madeup.outputs.fitted_values, results[0], 5) + assert_almost_equal(madeup.outputs.enp, 14.9, 1) + assert_almost_equal(madeup.outputs.s, 0.9693, 4) + # +# def test_2d_modflags_ez(self): +# "2D - modification of model flags" +# (x, y, results, newdata1, newdata2, madeup) = self.d +# madeup = cloess.loess(x,y) +# madeup.model.span = 0.8 +# madeup.model.drop_square_flags[0] = True +# madeup.model.parametric_flags[0] = True +# assert_equal(madeup.model.parametric_flags[:2],[1,0]) +# madeup.fit() +# assert_almost_equal(madeup.outputs.fitted_values, results[1], 5) +# assert_almost_equal(madeup.outputs.enp, 6.9, 1) +# assert_almost_equal(madeup.outputs.s, 1.4804, 4) + # + def test_2d_modflags_tot(self): + "2D - modification of model flags" + (x, y, results, _, _, madeup) = self.d + madeup = loess(x,y) + madeup.model.span = 0.8 + madeup.model.drop_square_flags = [True, False] + madeup.model.parametric_flags = [True, False] + assert_equal(madeup.model.parametric_flags[:2],[1,0]) + madeup.fit() + assert_almost_equal(madeup.outputs.fitted_values, results[1], 5) + assert_almost_equal(madeup.outputs.enp, 6.9, 1) + assert_almost_equal(madeup.outputs.s, 1.4804, 4) + # + def test_2d_modfamily(self): + "2D - family modification" + (_, _, results, _, _, madeup) = self.d + madeup.model.span = 0.8 + madeup.model.drop_square_flags = [True, False] + madeup.model.parametric_flags = [True, False] + madeup.model.family = "symmetric" + madeup.fit() + assert_almost_equal(madeup.outputs.fitted_values, results[2], 5) + assert_almost_equal(madeup.outputs.enp, 6.9, 1) + assert_almost_equal(madeup.outputs.s, 1.0868, 4) + # + def test_2d_modnormalize(self): + "2D - normalization modification" + (_, _, results, _, _, madeup) = self.d + madeup.model.span = 0.8 + madeup.model.drop_square_flags = [True, False] + madeup.model.parametric_flags = [True, False] + madeup.model.family = "symmetric" + madeup.model.normalize = False + madeup.fit() + assert_almost_equal(madeup.outputs.fitted_values, results[3], 5) + assert_almost_equal(madeup.outputs.enp, 6.9, 1) + assert_almost_equal(madeup.outputs.s, 1.0868, 4) + # + def test_2d_pred_nostderr(self): + "2D prediction - no stderr" + (_, _, results, newdata1, _, madeup) = self.d + madeup.model.span = 0.5 + madeup.model.normalize = True + madeup.predict(newdata1, stderror=False) + assert_almost_equal(madeup.predicted.values, results[4], 5) + # + madeup_pred = madeup.predict(newdata1, stderror=False) + assert_almost_equal(madeup_pred.values, results[4], 5) + # + def test_2d_pred_nodata(self): + "2D prediction - nodata" + (_, _, _, _, _, madeup) = self.d + try: + madeup.predict(None) + except ValueError: + pass + else: + raise AssertionError,"The test should have failed" + # + def test_2d_pred_stderr(self): + "2D prediction - w/ stderr" + (_, _, results, _, newdata2, madeup) = self.d + madeup.model.span = 0.5 + madeup.model.normalize = True + madeup_pred = madeup.predict(newdata2, stderror=True) + assert_almost_equal(madeup_pred.values, results[5], 5) + assert_almost_equal(madeup_pred.stderr, [0.276746, 0.278009], 5) + assert_almost_equal(madeup_pred.residual_scale, 0.969302, 6) + assert_almost_equal(madeup_pred.df, 81.2319, 4) + # Direct access + madeup.predict(newdata2, stderror=True) + assert_almost_equal(madeup.predicted.values, results[5], 5) + assert_almost_equal(madeup.predicted.stderr, [0.276746, 0.278009], 5) + assert_almost_equal(madeup.predicted.residual_scale, 0.969302, 6) + assert_almost_equal(madeup.predicted.df, 81.2319, 4) + # + def test_2d_pred_confinv(self): + "2D prediction - confidence" + (_, _, results, _, newdata2, madeup) = self.d + madeup.model.span = 0.5 + madeup.model.normalize = True + madeup_pred = madeup.predict(newdata2, stderror=True) + madeup.predicted.confidence(coverage=0.99) + assert_almost_equal(madeup.predicted.confidence_intervals.lower, + results[6][::3], 5) + assert_almost_equal(madeup.predicted.confidence_intervals.fit, + results[6][1::3], 5) + assert_almost_equal(madeup.predicted.confidence_intervals.upper, + results[6][2::3], 5) + # Direct access + confinv = madeup.predicted.confidence(coverage=0.99) + assert_almost_equal(confinv.lower, results[6][::3], 5) + assert_almost_equal(confinv.fit, results[6][1::3], 5) + assert_almost_equal(confinv.upper, results[6][2::3], 5) + +#####--------------------------------------------------------------------------- +#---- --- test 1D --- +#####--------------------------------------------------------------------------- +class test_loess_gas(NumpyTestCase): + "Test class for lowess." + # + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + NOx = marray([4.818, 2.849, 3.275, 4.691, 4.255, 5.064, 2.118, 4.602, + 2.286, 0.970, 3.965, 5.344, 3.834, 1.990, 5.199, 5.283, + 3.752, 0.537, 1.640, 5.055, 4.937, 1.561]) + E = marray([0.831, 1.045, 1.021, 0.970, 0.825, 0.891, 0.71, 0.801, + 1.074, 1.148, 1.000, 0.928, 0.767, 0.701, 0.807, 0.902, + 0.997, 1.224, 1.089, 0.973, 0.980, 0.665]) + gas_fit_E = numpy.array([0.665, 0.949, 1.224]) + newdata = numpy.array([0.6650000, 0.7581667, 0.8513333, 0.9445000, + 1.0376667, 1.1308333, 1.2240000]) + coverage = 0.99 + + rfile = open(os.path.join('tests','gas_result'), 'r') + results = [] + for i in range(8): + rfile.readline() + z = fromiter((float(v) for v in rfile.readline().rstrip().split()), + float_) + results.append(z) + self.d = (E, NOx, gas_fit_E, newdata, coverage, results) + # + def test_1dbasic(self): + "Basic test 1d" + (E, NOx, _, _, _, results) = self.d + gas = loess(E,NOx) + gas.model.span = 2./3. + gas.fit() + assert_almost_equal(gas.outputs.fitted_values, results[0], 6) + assert_almost_equal(gas.outputs.enp, 5.5, 1) + assert_almost_equal(gas.outputs.s, 0.3404, 4) + # + def test_1dbasic_alt(self): + "Basic test 1d - part #2" + (E, NOx, _, _, _, results) = self.d + gas_null = loess(E, NOx) + gas_null.model.span = 1.0 + gas_null.fit() + assert_almost_equal(gas_null.outputs.fitted_values, results[1], 5) + assert_almost_equal(gas_null.outputs.enp, 3.5, 1) + assert_almost_equal(gas_null.outputs.s, 0.5197, 4) + # + def test_1dpredict(self): + "Basic test 1d - prediction" + (E, NOx, gas_fit_E, _, _, results) = self.d + gas = loess(E,NOx, span=2./3.) + gas.fit() + gas.predict(gas_fit_E, stderror=False) + assert_almost_equal(gas.predicted.values, results[2], 6) + # + def test_1dpredict_2(self): + "Basic test 1d - new predictions" + (E, NOx, _, newdata, _, results) = self.d + gas = loess(E,NOx, span=2./3.) + gas.predict(newdata, stderror=True) + gas.predicted.confidence(0.99) + assert_almost_equal(gas.predicted.confidence_intervals.lower, + results[3][0::3], 6) + assert_almost_equal(gas.predicted.confidence_intervals.fit, + results[3][1::3], 6) + assert_almost_equal(gas.predicted.confidence_intervals.upper, + results[3][2::3], 6) + # + def test_anova(self): + "Tests anova" + (E, NOx, _, _, _, results) = self.d + gas = loess(E,NOx, span=2./3.) + gas.fit() + gas_null = loess(E, NOx, span=1.0) + gas_null.fit() + gas_anova = loess_anova(gas, gas_null) + gas_anova_theo = results[4] + assert_almost_equal(gas_anova.dfn, gas_anova_theo[0], 5) + assert_almost_equal(gas_anova.dfd, gas_anova_theo[1], 5) + assert_almost_equal(gas_anova.F_value, gas_anova_theo[2], 5) + assert_almost_equal(gas_anova.Pr_F, gas_anova_theo[3], 5) + # + def test_failures(self): + "Tests failures" + (E, NOx, gas_fit_E, _, _, _) = self.d + gas = loess(E,NOx, span=2./3.) + # This one should fail (all parametric) + gas.model.parametric_flags = True + self.assertRaises(ValueError, gas.fit) + # This one also (all drop_square) + gas.model.drop_square_flags = True + self.assertRaises(ValueError, gas.fit) + gas.model.degree = 1 + self.assertRaises(ValueError, gas.fit) + # This one should not (revert to std) + gas.model.parametric_flags = False + gas.model.drop_square_flags = False + gas.model.degree = 2 + gas.fit() + # Now, for predict ................. + gas.predict(gas_fit_E, stderror=False) + # This one should fail (extrapolation & blending) + self.assertRaises(ValueError, + gas.predict, gas.predicted.values, stderror=False) + # But this one should not .......... + gas.predict(gas_fit_E, stderror=False) + # + def test_mask(self): + NOx = marray([4.818, 2.849, 3.275, 4.691, 4.255, 5.064, 2.118, 4.602, + 2.286, 0.970, 3.965, 5.344, 3.834, 1.990, 5.199, 5.283, + -9999, -9999, 3.752, 0.537, 1.640, 5.055, 4.937, 1.561]) + NOx = maskedarray.masked_values(NOx, -9999) + E = marray([0.831, 1.045, 1.021, 0.970, 0.825, 0.891, 0.71, 0.801, + 1.074, 1.148, 1.000, 0.928, 0.767, 0.701, 0.807, 0.902, + -9999, -9999, 0.997, 1.224, 1.089, 0.973, 0.980, 0.665]) + gas_fit_E = numpy.array([0.665, 0.949, 1.224]) + newdata = numpy.array([0.6650000, 0.7581667, 0.8513333, 0.9445000, + 1.0376667, 1.1308333, 1.2240000]) + coverage = 0.99 + + rfile = open(os.path.join('tests','gas_result'), 'r') + results = [] + for i in range(8): + rfile.readline() + z = fromiter((float(v) for v in rfile.readline().rstrip().split()), + float_) + results.append(z) + # + gas = loess(E,NOx) + gas.model.span = 2./3. + gas.fit() + assert_almost_equal(gas.outputs.fitted_values.compressed(), results[0], 6) + assert_almost_equal(gas.outputs.enp, 5.5, 1) + assert_almost_equal(gas.outputs.s, 0.3404, 4) + + + + + + + +######################################################################## +if __name__ == '__main__': + NumpyTest().run() + + + Property changes on: trunk/Lib/sandbox/pyloess/tests/test_mpyloess.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Modified: trunk/Lib/sandbox/pyloess/tests/test_pyloess.py =================================================================== --- trunk/Lib/sandbox/pyloess/tests/test_pyloess.py 2007-03-26 19:37:12 UTC (rev 2873) +++ trunk/Lib/sandbox/pyloess/tests/test_pyloess.py 2007-03-27 06:38:36 UTC (rev 2874) @@ -1,15 +1,15 @@ """ -Wrapper to lowess and stl routines. +Test series for lowess, stl and loess routines. :author: Pierre GF Gerard-Marchant :contact: pierregm_at_uga_edu -:date: $Date: 2007-02-28 02:23:25 -0500 (Wed, 28 Feb 2007) $ -:version: $Id: generic.py 145 2007-02-28 07:23:25Z backtopop $ +:date: $Date$ +:version: $Id$ """ -__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)" +__author__ = "Pierre GF Gerard-Marchant ($Author$)" __version__ = '1.0' -__revision__ = "$Revision: 145 $" -__date__ = '$Date: 2007-02-28 02:23:25 -0500 (Wed, 28 Feb 2007) $' +__revision__ = "$Revision$" +__date__ = '$Date$' import os @@ -18,6 +18,7 @@ import numpy.core.numeric as numeric from numpy.core.records import recarray fromiter = numpy.fromiter +narray = numpy.array from numpy.testing import NumpyTest, NumpyTestCase @@ -36,9 +37,10 @@ # def __init__(self, *args, **kwds): NumpyTestCase.__init__(self, *args, **kwds) - X = [ 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8,10,12,14,50] - Y = [18, 2,15, 6,10, 4,16,11, 7, 3,14,17,20,12, 9,13, 1, 8, 5,19] - self.data = (X, Y) + X = narray([ 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8,10,12,14,50]) + Y = narray([18, 2,15, 6,10, 4,16,11, 7, 3,14,17,20,12, 9,13, 1, 8, 5,19]) + idx = X.argsort() + self.data = (X[idx], Y[idx]) #............................................ def test_lowess_1(self): "Tests lowess on typical data. part #1." @@ -46,9 +48,10 @@ YS = [13.659,11.145, 8.701, 9.722,10.000,11.300,11.300,11.300, 11.300,11.300,11.300,11.300,11.300,11.300,11.300,13.000, 6.440, 5.596, 5.456,18.998] - Z = lowess(X, Y, f=0.25, nsteps=0, delta=0) - assert_almost_equal(Z.smooth, YS, decimal=3) - assert_almost_equal(Z.residuals+Z.smooth, Y, decimal=3) + Z = lowess(X, Y, span=0.25, nsteps=0, delta=0) + assert_almost_equal(Z.outputs.fitted_values, YS, decimal=3) + assert_almost_equal(Z.outputs.fitted_residuals+Z.outputs.fitted_values, + Z.inputs.y, decimal=3) #............................................ def test_lowess_2(self): "Tests lowess on typical data. part #2." @@ -56,9 +59,10 @@ YS = [13.659,12.347,11.034, 9.722,10.511,11.300,11.300,11.300, 11.300,11.300,11.300,11.300,11.300,11.300,11.300,13.000, 6.440, 5.596, 5.456,18.998] - Z = lowess(X, Y, f=0.25, nsteps=0, delta=3) - assert_almost_equal(Z.smooth, YS, decimal=3) - assert_almost_equal(Z.residuals+Z.smooth, Y, decimal=3) + Z = lowess(X, Y, span=0.25, nsteps=0, delta=3) + assert_almost_equal(Z.outputs.fitted_values, YS, decimal=3) + assert_almost_equal(Z.outputs.fitted_residuals+Z.outputs.fitted_values, + Z.inputs.y, decimal=3) #............................................ def test_lowess_3(self): "Tests lowess on typical data. part #3." @@ -66,9 +70,10 @@ YS = [14.811,12.115, 8.984, 9.676,10.000,11.346,11.346,11.346, 11.346,11.346,11.346,11.346,11.346,11.346,11.346,13.000, 6.734, 5.744, 5.415,18.998 ] - Z = lowess(X, Y, f=0.25, nsteps=2, delta=0) - assert_almost_equal(Z.smooth, YS, decimal=3) - assert_almost_equal(Z.residuals+Z.smooth, Y, decimal=3) + Z = lowess(X, Y, span=0.25, nsteps=2, delta=0) + assert_almost_equal(Z.outputs.fitted_values, YS, decimal=3) + assert_almost_equal(Z.outputs.fitted_residuals+Z.outputs.fitted_values, + Z.inputs.y, decimal=3) #####--------------------------------------------------------------------------- #---- --- STL --- @@ -131,8 +136,6 @@ dfile.readline() y = fromiter((float(v) for v in dfile.readline().rstrip().split()), float_) - dfile = open(os.path.join('tests','madeup_data'), 'r') - dfile.readline() # rfile = open(os.path.join('tests','madeup_result'), 'r') results = [] Property changes on: trunk/Lib/sandbox/pyloess/tests/test_pyloess.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id From scipy-svn at scipy.org Tue Mar 27 14:10:06 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 27 Mar 2007 13:10:06 -0500 (CDT) Subject: [Scipy-svn] r2875 - trunk/Lib/sandbox/timeseries/src Message-ID: <20070327181006.848DE39C06A@new.scipy.org> Author: mattknox_ca Date: 2007-03-27 13:10:02 -0500 (Tue, 27 Mar 2007) New Revision: 2875 Modified: trunk/Lib/sandbox/timeseries/src/cseries.c Log: fixed some error handling bugs during Date initialization Modified: trunk/Lib/sandbox/timeseries/src/cseries.c =================================================================== --- trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-27 06:38:36 UTC (rev 2874) +++ trunk/Lib/sandbox/timeseries/src/cseries.c 2007-03-27 18:10:02 UTC (rev 2875) @@ -242,11 +242,10 @@ #define Py_AssertWithArg(x,errortype,errorstr,a1) {if (!(x)) {PyErr_Format(errortype,errorstr,a1);goto onError;}} #define Py_Error(errortype,errorstr) {PyErr_SetString(errortype,errorstr);goto onError;} -static PyObject *DateCalc_Error; /* Error Exception object */ -static PyObject *DateCalc_RangeError; /* Error Exception object */ + /* Error Exception objects */ +static PyObject *DateCalc_Error; +static PyObject *DateCalc_RangeError; - - #define GREGORIAN_CALENDAR 0 #define JULIAN_CALENDAR 1 @@ -410,7 +409,7 @@ day); yearoffset = dInfoCalc_YearOffset(year,calendar); - if (yearoffset == -1 && PyErr_Occurred()) goto onError; + if (PyErr_Occurred()) goto onError; absdate = day + month_offset[leap][month - 1] + yearoffset; @@ -487,7 +486,7 @@ while (1) { /* Calculate the year offset */ yearoffset = dInfoCalc_YearOffset(year,calendar); - if (yearoffset == -1 && PyErr_Occurred()) + if (PyErr_Occurred()) goto onError; /* Backward correction: absdate must be greater than the @@ -1817,23 +1816,22 @@ self->value = (int)(delta*1440 + hour*60 + minute + 1); } else if (self->freq == FR_HR) { long absdays, delta; - absdays = absdate_from_ymd(year, month, day); + if((absdays = absdate_from_ymd(year, month, day)) == INT_ERR_CODE) return -1; delta = (absdays - HIGHFREQ_ORIG); self->value = (int)(delta*24 + hour + 1); } else if (self->freq == FR_DAY) { - self->value = (int)absdate_from_ymd(year, month, day); + if((self->value = (int)absdate_from_ymd(year, month, day)) == INT_ERR_CODE) return -1; } else if (self->freq == FR_UND) { - self->value = (int)absdate_from_ymd(year, month, day); + if((self->value = (int)absdate_from_ymd(year, month, day)) == INT_ERR_CODE) return -1; } else if (self->freq == FR_BUS) { long weeks, days; - days = absdate_from_ymd(year, month, day); + if((days = absdate_from_ymd(year, month, day)) == INT_ERR_CODE) return -1; weeks = days/7; self->value = (int)(days - weeks*2); } else if (freq_group == FR_WK) { - int adj_ordinal; - int ordinal = (int)absdate_from_ymd(year, month, day); - int day_adj = (7 - (self->freq - FR_WK)) % 7; - + int adj_ordinal, ordinal, day_adj; + if((ordinal = (int)absdate_from_ymd(year, month, day)) == INT_ERR_CODE) return -1; + day_adj = (7 - (self->freq - FR_WK)) % 7; adj_ordinal = ordinal + ((7 - day_adj) - ordinal % 7) % 7; self->value = adj_ordinal/7; } else if (self->freq == FR_MTH) { @@ -3049,6 +3047,11 @@ if (PyType_Ready(&DateType) < 0) return; + DateCalc_Error = + PyErr_NewException("cseries.DateCalc_Error", NULL, NULL); + DateCalc_RangeError = + PyErr_NewException("cseries.DateCalc_RangeError", NULL, NULL); + m = Py_InitModule3("cseries", cseries_methods, cseries_doc); if (m == NULL) return; @@ -3069,4 +3072,8 @@ PyModule_AddObject(m, "freq_dict", freq_dict); PyModule_AddObject(m, "freq_dict_rev", freq_dict_rev); PyModule_AddObject(m, "freq_constants", freq_constants); + + PyModule_AddObject(m, "DateCalc_Error", DateCalc_Error); + PyModule_AddObject(m, "DateCalc_RangeError", DateCalc_RangeError); + } \ No newline at end of file From scipy-svn at scipy.org Tue Mar 27 14:10:53 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 27 Mar 2007 13:10:53 -0500 (CDT) Subject: [Scipy-svn] r2876 - trunk/Lib/sandbox/timeseries Message-ID: <20070327181053.04B1C39C06A@new.scipy.org> Author: mattknox_ca Date: 2007-03-27 13:10:50 -0500 (Tue, 27 Mar 2007) New Revision: 2876 Modified: trunk/Lib/sandbox/timeseries/tdates.py Log: added DateCalc_Error and DateCalc_RangeError exception objects to module namespace Modified: trunk/Lib/sandbox/timeseries/tdates.py =================================================================== --- trunk/Lib/sandbox/timeseries/tdates.py 2007-03-27 18:10:02 UTC (rev 2875) +++ trunk/Lib/sandbox/timeseries/tdates.py 2007-03-27 18:10:50 UTC (rev 2876) @@ -36,7 +36,8 @@ cseries.set_callback_DateFromString(DateFromString) cseries.set_callback_DateTimeFromString(DateTimeFromString) -from cseries import Date, thisday, check_freq, check_freq_str, get_freq_group +from cseries import Date, thisday, check_freq, check_freq_str, get_freq_group,\ + DateCalc_Error, DateCalc_RangeError today = thisday __all__ = [ @@ -45,7 +46,7 @@ 'datearray','date_array', 'date_array_fromlist', 'date_array_fromrange', 'day_of_week','day_of_year','day','month','quarter','year','hour','minute', 'second','thisday','today','prevbusday','period_break', 'check_freq', -'check_freq_str','get_freq_group' +'check_freq_str','get_freq_group', 'DateCalc_Error', 'DateCalc_RangeError' ] From scipy-svn at scipy.org Tue Mar 27 15:12:33 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 27 Mar 2007 14:12:33 -0500 (CDT) Subject: [Scipy-svn] r2877 - in trunk/Lib/sandbox/maskedarray: . tests Message-ID: <20070327191233.2A5C039C2A9@new.scipy.org> Author: pierregm Date: 2007-03-27 14:12:29 -0500 (Tue, 27 Mar 2007) New Revision: 2877 Added: trunk/Lib/sandbox/maskedarray/mstats.py trunk/Lib/sandbox/maskedarray/tests/test_mstats.py Modified: trunk/Lib/sandbox/maskedarray/core.py trunk/Lib/sandbox/maskedarray/tests/test_core.py Log: core : fixed .sort for ndarrays mstats : misc. statistics supporting masked arrays (quantiles + medians) Modified: trunk/Lib/sandbox/maskedarray/core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/core.py 2007-03-27 18:10:50 UTC (rev 2876) +++ trunk/Lib/sandbox/maskedarray/core.py 2007-03-27 19:12:29 UTC (rev 2877) @@ -1775,20 +1775,24 @@ |'heapsort' | 3 | O(n*log(n)) | 0 | no | |------------------------------------------------------| - All the sort algorithms make temporary copies of the data when the sort is - not along the last axis. Consequently, sorts along the last axis are faster - and use less space than sorts along other axis. - """ - if fill_value is None: - if endwith: - filler = minimum_fill_value(self) + if self._mask is nomask: + ndarray.sort(self,axis=axis, kind=kind, order=order) + else: + if fill_value is None: + if endwith: + filler = minimum_fill_value(self) + else: + filler = maximum_fill_value(self) else: - filler = maximum_fill_value(self) - else: - filler = fill_value - indx = self.filled(filler).argsort(axis=axis,kind=kind,order=order) - self[:] = self[indx] + filler = fill_value + idx = numpy.indices(self.shape) + idx[axis] = self.filled(filler).argsort(axis=axis,kind=kind,order=order) + idx_l = idx.tolist() + tmp_mask = self._mask[idx_l].flat + tmp_data = self._data[idx_l].flat + self.flat = tmp_data + self._mask.flat = tmp_mask return #............................................ def min(self, axis=None, fill_value=None): @@ -2620,18 +2624,35 @@ if __name__ == '__main__': import numpy as N from maskedarray.testutils import assert_equal, assert_array_equal + marray = masked_array # - a = arange(10) - a[::3] = masked - a.fill_value = 999 - a_pickled = cPickle.loads(a.dumps()) - assert_equal(a_pickled._mask, a._mask) - assert_equal(a_pickled._data, a._data) - assert_equal(a_pickled.fill_value, 999) + if 0: + a = arange(10) + a[::3] = masked + a.fill_value = 999 + a_pickled = cPickle.loads(a.dumps()) + assert_equal(a_pickled._mask, a._mask) + assert_equal(a_pickled._data, a._data) + assert_equal(a_pickled.fill_value, 999) + # + a = array(numpy.matrix(range(10)), mask=[1,0,1,0,0]*2) + a_pickled = cPickle.loads(a.dumps()) + assert_equal(a_pickled._mask, a._mask) + assert_equal(a_pickled, a) + assert(isinstance(a_pickled._data,numpy.matrix)) # - a = array(numpy.matrix(range(10)), mask=[1,0,1,0,0]*2) - a_pickled = cPickle.loads(a.dumps()) - assert_equal(a_pickled._mask, a._mask) - assert_equal(a_pickled, a) - assert(isinstance(a_pickled._data,numpy.matrix)) + # + if 1: + x = marray(numpy.linspace(-1.,1.,31),) + x[:10] = x[-10:] = masked + z = marray(numpy.empty((len(x),3), dtype=numpy.float_)) + z[:,0] = x[:] + for i in range(1,3): + idx = numpy.arange(len(x)) + numpy.random.shuffle(idx) + z[:,i] = x[idx] + # + z.sort(0) + + Added: trunk/Lib/sandbox/maskedarray/mstats.py =================================================================== --- trunk/Lib/sandbox/maskedarray/mstats.py 2007-03-27 18:10:50 UTC (rev 2876) +++ trunk/Lib/sandbox/maskedarray/mstats.py 2007-03-27 19:12:29 UTC (rev 2877) @@ -0,0 +1,209 @@ +""" +Generic statistics functions, with support to MA. + +:author: Pierre GF Gerard-Marchant +:contact: pierregm_at_uga_edu +:date: $Date$ +:version: $Id$ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author$)" +__version__ = '1.0' +__revision__ = "$Revision$" +__date__ = '$Date$' + + +import numpy +from numpy import bool_, float_, int_ +from numpy import array as narray +from numpy.core import numeric as numeric + +import maskedarray as MA +from maskedarray.core import masked, nomask, MaskedArray +from maskedarray.core import masked_array as marray +from maskedarray.extras import apply_along_axis + + +def _quantiles_1D(data,m,p): + """Returns quantiles for 1D compressed data. + Used internally by `mquantiles`. + +:Parameters: + data : ndarray + Array to quantize + m : Sequence + p : float ndarray + Quantiles to compute + """ + n = data.count() + if n == 0: + return MA.resize(masked, len(p)) + elif n == 1: + return MA.resize(data,len(p)) + data = data.compressed() + aleph = (n*p + m) + k = numpy.floor(aleph.clip(1, n-1)).astype(int_) + gamma = (aleph-k).clip(0,1) + y = MA.sort(data) + return (1.-gamma)*y[(k-1).tolist()] + gamma*y[k.tolist()] + +def mquantiles(data, prob=list([.25,.5,.75]), alphap=.4, betap=.4, axis=None): + """Computes empirical quantiles for a *1xN* data array. +Samples quantile are defined by: +*Q(p) = (1-g).x[i] +g.x[i+1]* +where *x[j]* is the jth order statistic, +with *i = (floor(n*p+m))*, *m=alpha+p*(1-alpha-beta)* and *g = n*p + m - i)*. + +Typical values of (alpha,beta) are: + + - (0,1) : *p(k) = k/n* : linear interpolation of cdf (R, type 4) + - (.5,.5) : *p(k) = (k+1/2.)/n* : piecewise linear function (R, type 5) + - (0,0) : *p(k) = k/(n+1)* : (R type 6) + - (1,1) : *p(k) = (k-1)/(n-1)*. In this case, p(k) = mode[F(x[k])]. + That's R default (R type 7) + - (1/3,1/3): *p(k) = (k-1/3)/(n+1/3)*. Then p(k) ~ median[F(x[k])]. + The resulting quantile estimates are approximately median-unbiased + regardless of the distribution of x. (R type 8) + - (3/8,3/8): *p(k) = (k-3/8)/(n+1/4)*. Blom. + The resulting quantile estimates are approximately unbiased + if x is normally distributed (R type 9) + - (.4,.4) : approximately quantile unbiased (Cunnane) + - (.35,.35): APL, used with PWM + +:Parameters: + x : Sequence + Input data, as a sequence or array of dimension at most 2. + prob : Sequence *[(0.25, 0.5, 0.75)]* + List of quantiles to compute. + alpha : Float (*[0.4]*) + Plotting positions parameter. + beta : Float (*[0.4]*) + Plotting positions parameter. + axis : Integer *[None]* + Axis along which to compute quantiles. If *None*, uses the whole + (flattened/compressed) dataset. + """ + + # Initialization & checks --------- + data = marray(data, copy=False) + assert data.ndim <= 2, "Array should be 2D at most !" + p = narray(prob, copy=False, ndmin=1) + m = alphap + p*(1.-alphap-betap) + # Computes quantiles along axis (or globally) + if (axis is None): + return _quantiles_1D(data, m, p) + else: + return apply_along_axis(_quantiles_1D, axis, data, m, p) + + +def _median1d(data): + """Returns the median of a 1D masked array. Used internally by mmedian.""" + datac = data.compressed() + if datac.size > 0: + return numpy.median(data.compressed()) + return masked + +def _median2d_1(data): + data = marray(data, subok=True, copy=True) + if data._mask is nomask: + return numpy.median(data) + if data.ndim != 2 : + raise ValueError("Input array should be 2D!") + (n,p) = data.shape + if p < n//3: + return apply_along_axis(_median1d, 0, data) + data.sort(axis=0) + counts = data.count(axis=0) + midx = (counts//2) + midx_even = (counts%2==0) + med = marray(numeric.empty((data.shape[-1],), dtype=data.dtype)) + med[midx_even] = (data[midx-1]+data[midx])/2. + med[numpy.logical_not(midx_even)] = data[midx] + if not med._mask.any(): + med._mask = nomask + return med + +def _median2d_2(data): + return apply_along_axis(_median1d, 0, data) + + +def mmedian(data): + """Returns the median of data along the first axis. Missing data are discarded.""" + data = marray(data, subok=True, copy=True) + if data._mask is nomask: + return numpy.median(data) + if data.ndim == 1: + return _median1d(data) +# elif data.ndim == 2: +# (n, p) = data.shape +# if p < n//3: +# return apply_along_axis(_median1d, 0, data) +# data.sort(axis=0) +# counts = data.count(axis=0) +# midx = (counts//2) +# midx_even = (counts%2==0) +# med = marray(numeric.empty((p,), dtype=data.dtype)) +# med[midx_even] = (data[midx-1]+data[midx])/2. +# med[numpy.logical_not(midx_even)] = data[midx] +# if not med._mask.any(): +# med._mask = nomask +# return med + return apply_along_axis(_median1d, 0, data) + + + +################################################################################ +if __name__ == '__main__': + from maskedarray.testutils import assert_almost_equal, assert_equal + import timeit + import maskedarray + + if 1: + (n,p) = (101,30) + x = marray(numpy.linspace(-1.,1.,n),) + x[:10] = x[-10:] = masked + z = marray(numpy.empty((n,p), dtype=numpy.float_)) + z[:,0] = x[:] + idx = numpy.arange(len(x)) + for i in range(1,p): + numpy.random.shuffle(idx) + z[:,i] = x[idx] + + assert_equal(mmedian(z[:,0]), 0) + assert_equal(mmedian(z), numpy.zeros((p,))) + + x = maskedarray.arange(24).reshape(3,4,2) + x[x%3==0] = masked + assert_equal(mmedian(x), [[12,9],[6,15],[12,9],[18,15]]) + x.shape = (4,3,2) + assert_equal(mmedian(x),[[99,10],[11,99],[13,14]]) + x = maskedarray.arange(24).reshape(4,3,2) + x[x%5==0] = masked + assert_equal(mmedian(x), [[12,10],[8,9],[16,17]]) + + + """ [[[0 1], [2 3], [4 5]] + [[6 7], [8 9], [10 11]] + [[9 13] [14 15] [16 17]] + [[18 19] [20 21] [22 23]]], + + [[[-- 1] [2 --] [4 5] [-- 7]] + [[8 --] [10 11] [-- 13] [14 --]] + [[16 17] [-- 19] [20 --] [22 23]]], + + """ + + if 0: + print "GO!" + med_setup1 = "from __main__ import _median2d_1,z" + med_setup3 = "from __main__ import mmedian,z" + med_setup2 = "from __main__ import _median2d_2,z" + (nrep, nloop) = (3,10) + med_r1 = timeit.Timer("_median2d_1(z)", med_setup1).repeat(nrep,nloop) + med_r2 = timeit.Timer("_median2d_2(z)", med_setup2).repeat(nrep,nloop) + med_r3 = timeit.Timer("mmedian(z)", med_setup3).repeat(nrep,nloop) + med_r1 = numpy.sort(med_r1) + med_r2 = numpy.sort(med_r2) + med_r3 = numpy.sort(med_r3) + print "median2d_1 : %s" % med_r1 + print "median2d_2 : %s" % med_r2 + print "median : %s" % med_r3 \ No newline at end of file Property changes on: trunk/Lib/sandbox/maskedarray/mstats.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id Modified: trunk/Lib/sandbox/maskedarray/tests/test_core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_core.py 2007-03-27 18:10:50 UTC (rev 2876) +++ trunk/Lib/sandbox/maskedarray/tests/test_core.py 2007-03-27 19:12:29 UTC (rev 2877) @@ -1105,6 +1105,47 @@ assert_equal(sortedx._data, [1,2,-2,-1,0]) assert_equal(sortedx._mask, [1,1,0,0,0]) + def check_sort_2d(self): + "Check sort of 2D array." + # 2D array w/o mask + a = masked_array([[8,4,1],[2,0,9]]) + a.sort(0) + assert_equal(a, [[2,0,1],[8,4,9]]) + a = masked_array([[8,4,1],[2,0,9]]) + a.sort(1) + assert_equal(a, [[1,4,8],[0,2,9]]) + # 2D array w/mask + a = masked_array([[8,4,1],[2,0,9]], mask=[[1,0,0],[0,0,1]]) + a.sort(0) + assert_equal(a, [[2,0,1],[8,4,9]]) + assert_equal(a._mask, [[0,0,0],[1,0,1]]) + a = masked_array([[8,4,1],[2,0,9]], mask=[[1,0,0],[0,0,1]]) + a.sort(1) + assert_equal(a, [[1,4,8],[0,2,9]]) + assert_equal(a._mask, [[0,0,1],[0,0,1]]) + # 3D + a = masked_array([[[7, 8, 9],[4, 5, 6],[1, 2, 3]], + [[1, 2, 3],[7, 8, 9],[4, 5, 6]], + [[7, 8, 9],[1, 2, 3],[4, 5, 6]], + [[4, 5, 6],[1, 2, 3],[7, 8, 9]]]) + a[a%4==0] = masked + am = a.copy() + an = a.filled(99) + am.sort(0) + an.sort(0) + assert_equal(am, an) + am = a.copy() + an = a.filled(99) + am.sort(1) + an.sort(1) + assert_equal(am, an) + am = a.copy() + an = a.filled(99) + am.sort(2) + an.sort(2) + assert_equal(am, an) + + def check_ravel(self): "Tests ravel" a = array([[1,2,3,4,5]], mask=[[0,1,0,0,0]]) Added: trunk/Lib/sandbox/maskedarray/tests/test_mstats.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_mstats.py 2007-03-27 18:10:50 UTC (rev 2876) +++ trunk/Lib/sandbox/maskedarray/tests/test_mstats.py 2007-03-27 19:12:29 UTC (rev 2877) @@ -0,0 +1,117 @@ +# pylint: disable-msg=W0611, W0612, W0511,R0201 +"""Tests suite for maskedArray statistics. + +:author: Pierre Gerard-Marchant +:contact: pierregm_at_uga_dot_edu +:version: $Id$ +""" +__author__ = "Pierre GF Gerard-Marchant ($Author$)" +__version__ = '1.0' +__revision__ = "$Revision$" +__date__ = '$Date$' + +import numpy + +import maskedarray +from maskedarray import masked, masked_array + +import maskedarray.testutils +from maskedarray.testutils import * + +from maskedarray.mstats import mquantiles, mmedian + +#.............................................................................. +class test_quantiles(NumpyTestCase): + "Base test class for MaskedArrays." + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + self.a = maskedarray.arange(1,101) + # + def test_1d_nomask(self): + "Test quantiles 1D - w/o mask." + a = self.a + assert_almost_equal(mquantiles(a, alphap=1., betap=1.), + [25.75, 50.5, 75.25]) + assert_almost_equal(mquantiles(a, alphap=0, betap=1.), + [25., 50., 75.]) + assert_almost_equal(mquantiles(a, alphap=0.5, betap=0.5), + [25.5, 50.5, 75.5]) + assert_almost_equal(mquantiles(a, alphap=0., betap=0.), + [25.25, 50.5, 75.75]) + assert_almost_equal(mquantiles(a, alphap=1./3, betap=1./3), + [25.41666667, 50.5, 75.5833333]) + assert_almost_equal(mquantiles(a, alphap=3./8, betap=3./8), + [25.4375, 50.5, 75.5625]) + assert_almost_equal(mquantiles(a), [25.45, 50.5, 75.55])# + # + def test_1d_mask(self): + "Test quantiles 1D - w/ mask." + a = self.a + a[1::2] = masked + assert_almost_equal(mquantiles(a, alphap=1., betap=1.), + [25.5, 50.0, 74.5]) + assert_almost_equal(mquantiles(a, alphap=0, betap=1.), + [24., 49., 74.]) + assert_almost_equal(mquantiles(a, alphap=0.5, betap=0.5), + [25., 50., 75.]) + assert_almost_equal(mquantiles(a, alphap=0., betap=0.), + [24.5, 50.0, 75.5]) + assert_almost_equal(mquantiles(a, alphap=1./3, betap=1./3), + [24.833333, 50.0, 75.166666]) + assert_almost_equal(mquantiles(a, alphap=3./8, betap=3./8), + [24.875, 50., 75.125]) + assert_almost_equal(mquantiles(a), [24.9, 50., 75.1]) + # + def test_2d_nomask(self): + "Test quantiles 2D - w/o mask." + a = self.a + b = maskedarray.resize(a, (100,100)) + assert_almost_equal(mquantiles(b), [25.45, 50.5, 75.55]) + assert_almost_equal(mquantiles(b, axis=0), maskedarray.resize(a,(3,100))) + assert_almost_equal(mquantiles(b, axis=1), + maskedarray.resize([25.45, 50.5, 75.55], (100,3))) + # + def test_2d_mask(self): + "Test quantiles 2D - w/ mask." + a = self.a + a[1::2] = masked + b = maskedarray.resize(a, (100,100)) + assert_almost_equal(mquantiles(b), [25., 50., 75.]) + assert_almost_equal(mquantiles(b, axis=0), maskedarray.resize(a,(3,100))) + assert_almost_equal(mquantiles(b, axis=1), + maskedarray.resize([24.9, 50., 75.1], (100,3))) + +class test_median(NumpyTestCase): + def __init__(self, *args, **kwds): + NumpyTestCase.__init__(self, *args, **kwds) + + def test_2d(self): + "Tests median w/ 2D" + (n,p) = (101,30) + x = masked_array(numpy.linspace(-1.,1.,n),) + x[:10] = x[-10:] = masked + z = masked_array(numpy.empty((n,p), dtype=numpy.float_)) + z[:,0] = x[:] + idx = numpy.arange(len(x)) + for i in range(1,p): + numpy.random.shuffle(idx) + z[:,i] = x[idx] + assert_equal(mmedian(z[:,0]), 0) + assert_equal(mmedian(z), numpy.zeros((p,))) + + def test_3d(self): + "Tests median w/ 3D" + x = maskedarray.arange(24).reshape(3,4,2) + x[x%3==0] = masked + assert_equal(mmedian(x), [[12,9],[6,15],[12,9],[18,15]]) + x.shape = (4,3,2) + assert_equal(mmedian(x),[[99,10],[11,99],[13,14]]) + x = maskedarray.arange(24).reshape(4,3,2) + x[x%5==0] = masked + assert_equal(mmedian(x), [[12,10],[8,9],[16,17]]) + +############################################################################### +#------------------------------------------------------------------------------ +if __name__ == "__main__": + NumpyTest().run() + \ No newline at end of file Property changes on: trunk/Lib/sandbox/maskedarray/tests/test_mstats.py ___________________________________________________________________ Name: svn:keywords + Date Author Revision Id From scipy-svn at scipy.org Tue Mar 27 15:23:28 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Tue, 27 Mar 2007 14:23:28 -0500 (CDT) Subject: [Scipy-svn] r2878 - trunk/Lib/sandbox/timeseries/io/fame/src Message-ID: <20070327192328.3E9C839C06A@new.scipy.org> Author: mattknox_ca Date: 2007-03-27 14:23:23 -0500 (Tue, 27 Mar 2007) New Revision: 2878 Modified: trunk/Lib/sandbox/timeseries/io/fame/src/cfame.c Log: no longer raise error if CHLI previously initialized Modified: trunk/Lib/sandbox/timeseries/io/fame/src/cfame.c =================================================================== --- trunk/Lib/sandbox/timeseries/io/fame/src/cfame.c 2007-03-27 19:12:29 UTC (rev 2877) +++ trunk/Lib/sandbox/timeseries/io/fame/src/cfame.c 2007-03-27 19:23:23 UTC (rev 2878) @@ -1278,7 +1278,11 @@ { PyObject *m, *FAME_CONSTANTS; int status; - CALLFAME(cfmini(&status)); + CALLFAME_NOCHECK(cfmini(&status)); + if (status != HSUCC && status != HINITD) { + if (checkError(status)) { return NULL; } + } + if ((m = Py_InitModule3("cfame", cfame_methods, cfame_doc)) == NULL) return NULL; import_array(); makeTranslationTables(); From scipy-svn at scipy.org Wed Mar 28 10:46:18 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 Mar 2007 09:46:18 -0500 (CDT) Subject: [Scipy-svn] r2879 - in trunk/Lib/ndimage: . src Message-ID: <20070328144618.88E5A39C108@new.scipy.org> Author: stefan Date: 2007-03-28 09:46:04 -0500 (Wed, 28 Mar 2007) New Revision: 2879 Modified: trunk/Lib/ndimage/setup.py trunk/Lib/ndimage/src/nd_image.h trunk/Lib/ndimage/src/ni_interpolation.c Log: Port ndimage to numpy API. Modified: trunk/Lib/ndimage/setup.py =================================================================== --- trunk/Lib/ndimage/setup.py 2007-03-27 19:23:23 UTC (rev 2878) +++ trunk/Lib/ndimage/setup.py 2007-03-28 14:46:04 UTC (rev 2879) @@ -1,6 +1,6 @@ from numpy.distutils.core import setup from numpy.distutils.misc_util import Configuration -from numpy.numarray import get_numarray_include_dirs +from numpy import get_include def configuration(parent_package='', top_path=None): @@ -11,7 +11,7 @@ "src/ni_fourier.c","src/ni_interpolation.c", "src/ni_measure.c", "src/ni_morphology.c","src/ni_support.c"], - include_dirs=['src']+get_numarray_include_dirs(), + include_dirs=['src']+[get_include()], ) config.add_data_dir('tests') Modified: trunk/Lib/ndimage/src/nd_image.h =================================================================== --- trunk/Lib/ndimage/src/nd_image.h 2007-03-27 19:23:23 UTC (rev 2878) +++ trunk/Lib/ndimage/src/nd_image.h 2007-03-28 14:46:04 UTC (rev 2879) @@ -32,20 +32,46 @@ #ifndef ND_IMAGE_H #define ND_IMAGE_H -#if !defined(ND_IMPORT_ARRAY) -#define NO_IMPORT_ARRAY -#endif #include "Python.h" -#include "numpy/libnumarray.h" +#include #define NI_MAXDIM NPY_MAXDIMS -int NI_GetArrayRank(PyArrayObject*); +typedef npy_intp maybelong; +#define MAXDIM NPY_MAXDIMS + +typedef enum +{ + tAny=-1, + tBool=PyArray_BOOL, + tInt8=PyArray_INT8, + tUInt8=PyArray_UINT8, + tInt16=PyArray_INT16, + tUInt16=PyArray_UINT16, + tInt32=PyArray_INT32, + tUInt32=PyArray_UINT32, + tInt64=PyArray_INT64, + tUInt64=PyArray_UINT64, + tFloat32=PyArray_FLOAT32, + tFloat64=PyArray_FLOAT64, + tComplex32=PyArray_COMPLEX64, + tComplex64=PyArray_COMPLEX128, + tObject=PyArray_OBJECT, /* placeholder... does nothing */ + tMaxType=PyArray_NTYPES, + tDefault = tFloat64, +#if NPY_BITSOF_LONG == 64 + tLong = tInt64, +#else + tLong = tInt32, +#endif +} NumarrayType; + +/* int NI_GetArrayRank(PyArrayObject*); NumarrayType NI_GetArrayType(PyArrayObject*); void NI_GetArrayDimensions(PyArrayObject*, int*); void NI_GetArrayStrides(PyArrayObject*, int*); char* NI_GetArrayData(PyArrayObject*); int NI_ShapeEqual(PyArrayObject*, PyArrayObject*); -int NI_CheckArray(PyArrayObject*, NumarrayType, int, int*); +int NI_CheckArray(PyArrayObject*, NumarrayType, int, int*); */ #endif Modified: trunk/Lib/ndimage/src/ni_interpolation.c =================================================================== --- trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-27 19:23:23 UTC (rev 2878) +++ trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-28 14:46:04 UTC (rev 2879) @@ -308,7 +308,7 @@ } #define CASE_MAP_COORDINATES(_p, _coor, _rank, _stride, _type) \ -case t ## _type: \ +case t ## _type: \ { \ int _hh; \ for(_hh = 0; _hh < _rank; _hh++) { \ @@ -354,8 +354,8 @@ double **splvals = NULL, icoor[MAXDIM]; double idimensions[MAXDIM], istrides[MAXDIM]; NI_Iterator io, ic; - Float64 *matrix = matrix_ar ? (Float64*)NA_OFFSETDATA(matrix_ar) : NULL; - Float64 *shift = shift_ar ? (Float64*)NA_OFFSETDATA(shift_ar) : NULL; + Float64 *matrix = matrix_ar ? (Float64*)PyArray_DATA(matrix_ar) : NULL; + Float64 *shift = shift_ar ? (Float64*)PyArray_DATA(shift_ar) : NULL; int irank = 0, orank, qq; for(kk = 0; kk < input->nd; kk++) { @@ -373,7 +373,7 @@ cstride = ic.strides[0]; if (!NI_LineIterator(&ic, 0)) goto exit; - pc = NA_OFFSETDATA(coordinates); + pc = (void *)(PyArray_DATA(coordinates)); } /* offsets used at the borders: */ @@ -422,8 +422,8 @@ goto exit; /* get data pointers: */ - pi = NA_OFFSETDATA(input); - po = NA_OFFSETDATA(output); + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); /* make a table of all possible coordinates within the spline filter: */ fcoordinates = (maybelong*)malloc(irank * filter_size * sizeof(maybelong)); @@ -659,8 +659,8 @@ maybelong size; double ***splvals = NULL; NI_Iterator io; - Float64 *zooms = zoom_ar ? (Float64*)NA_OFFSETDATA(zoom_ar) : NULL; - Float64 *shifts = shift_ar ? (Float64*)NA_OFFSETDATA(shift_ar) : NULL; + Float64 *zooms = zoom_ar ? (Float64*)PyArray_DATA(zoom_ar) : NULL; + Float64 *shifts = shift_ar ? (Float64*)PyArray_DATA(shift_ar) : NULL; int rank = 0, qq; for(kk = 0; kk < input->nd; kk++) { @@ -792,8 +792,8 @@ if (!NI_InitPointIterator(output, &io)) goto exit; - pi = NA_OFFSETDATA(input); - po = NA_OFFSETDATA(output); + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); /* store all coordinates and offsets with filter: */ fcoordinates = (maybelong*)malloc(rank * filter_size * sizeof(maybelong)); From scipy-svn at scipy.org Wed Mar 28 10:57:30 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 Mar 2007 09:57:30 -0500 (CDT) Subject: [Scipy-svn] r2880 - trunk/Lib/ndimage/src Message-ID: <20070328145730.83F2A39C03D@new.scipy.org> Author: stefan Date: 2007-03-28 09:57:22 -0500 (Wed, 28 Mar 2007) New Revision: 2880 Modified: trunk/Lib/ndimage/src/ni_interpolation.c Log: ndimage: clip values according to the output type. Modified: trunk/Lib/ndimage/src/ni_interpolation.c =================================================================== --- trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-28 14:46:04 UTC (rev 2879) +++ trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-28 14:57:22 UTC (rev 2880) @@ -328,15 +328,19 @@ *(_type*)_po = (_type)_t; \ break; -#define CASE_INTERP_OUT_UINT(_po, _t, _type) \ +#define CASE_INTERP_OUT_UINT(_po, _t, _type, type_min, type_max) \ case t ## _type: \ _t = _t > 0 ? _t + 0.5 : 0; \ + _t = _t > type_max ? type_max : t; \ + _t = _t < type_min ? type_min : t; \ *(_type*)_po = (_type)_t; \ break; -#define CASE_INTERP_OUT_INT(_po, _t, _type) \ +#define CASE_INTERP_OUT_INT(_po, _t, _type, type_min, type_max) \ case t ## _type: \ _t = _t > 0 ? _t + 0.5 : _t - 0.5; \ + _t = _t > type_max ? type_max : t; \ + _t = _t < type_min ? type_min : t; \ *(_type*)_po = (_type)_t; \ break; @@ -602,16 +606,16 @@ /* store output value: */ switch (output->descr->type_num) { CASE_INTERP_OUT(po, t, Bool); - CASE_INTERP_OUT_UINT(po, t, UInt8); - CASE_INTERP_OUT_UINT(po, t, UInt16); - CASE_INTERP_OUT_UINT(po, t, UInt32); + CASE_INTERP_OUT_UINT(po, t, UInt8, 0, MAX_UINT8); + CASE_INTERP_OUT_UINT(po, t, UInt16, 0, MAX_UINT16); + CASE_INTERP_OUT_UINT(po, t, UInt32, 0, MAX_UINT32); #if HAS_UINT64 CASE_INTERP_OUT_UINT(po, t, UInt64); #endif - CASE_INTERP_OUT_INT(po, t, Int8); - CASE_INTERP_OUT_INT(po, t, Int16); - CASE_INTERP_OUT_INT(po, t, Int32); - CASE_INTERP_OUT_INT(po, t, Int64); + CASE_INTERP_OUT_INT(po, t, Int8, MIN_INT8, MAX_INT8); + CASE_INTERP_OUT_INT(po, t, Int16, MIN_INT16, MAX_INT16); + CASE_INTERP_OUT_INT(po, t, Int32, MIN_INT32, MAX_INT32); + CASE_INTERP_OUT_INT(po, t, Int64, MIN_INT64, MAX_INT64); CASE_INTERP_OUT(po, t, Float32); CASE_INTERP_OUT(po, t, Float64); default: @@ -896,16 +900,16 @@ /* store output: */ switch (output->descr->type_num) { CASE_INTERP_OUT(po, t, Bool); - CASE_INTERP_OUT_UINT(po, t, UInt8); - CASE_INTERP_OUT_UINT(po, t, UInt16); - CASE_INTERP_OUT_UINT(po, t, UInt32); + CASE_INTERP_OUT_UINT(po, t, UInt8, 0, MAX_UINT8); + CASE_INTERP_OUT_UINT(po, t, UInt16, 0, MAX_UINT16); + CASE_INTERP_OUT_UINT(po, t, UInt32, 0, MAX_UINT32); #if HAS_UINT64 - CASE_INTERP_OUT_UINT(po, t, UInt64); + CASE_INTERP_OUT_UINT(po, t, UInt64, 0, MAX_UINT64); #endif - CASE_INTERP_OUT_INT(po, t, Int8); - CASE_INTERP_OUT_INT(po, t, Int16); - CASE_INTERP_OUT_INT(po, t, Int32); - CASE_INTERP_OUT_INT(po, t, Int64); + CASE_INTERP_OUT_INT(po, t, Int8, MIN_INT8, MAX_INT8); + CASE_INTERP_OUT_INT(po, t, Int16, MIN_INT16, MAX_INT16); + CASE_INTERP_OUT_INT(po, t, Int32, MIN_INT32, MAX_INT32); + CASE_INTERP_OUT_INT(po, t, Int64, MIN_INT64, MAX_INT64); CASE_INTERP_OUT(po, t, Float32); CASE_INTERP_OUT(po, t, Float64); default: From scipy-svn at scipy.org Wed Mar 28 11:01:28 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 Mar 2007 10:01:28 -0500 (CDT) Subject: [Scipy-svn] r2881 - trunk/Lib/ndimage Message-ID: <20070328150128.466AC39C03D@new.scipy.org> Author: stefan Date: 2007-03-28 10:01:14 -0500 (Wed, 28 Mar 2007) New Revision: 2881 Modified: trunk/Lib/ndimage/interpolation.py Log: Change default axis of rotation from (-1,-2) to (1,0). Modified: trunk/Lib/ndimage/interpolation.py =================================================================== --- trunk/Lib/ndimage/interpolation.py 2007-03-28 14:57:22 UTC (rev 2880) +++ trunk/Lib/ndimage/interpolation.py 2007-03-28 15:01:14 UTC (rev 2881) @@ -337,7 +337,7 @@ maxc[1] = coor[1] return minc, maxc -def rotate(input, angle, axes = (-1, -2), reshape = True, +def rotate(input, angle, axes = (1, 0), reshape = True, output_type = None, output = None, order = 3, mode = 'constant', cval = 0.0, prefilter = True): """Rotate an array. From scipy-svn at scipy.org Wed Mar 28 12:46:27 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 Mar 2007 11:46:27 -0500 (CDT) Subject: [Scipy-svn] r2882 - trunk/Lib/ndimage/src Message-ID: <20070328164627.0937539C288@new.scipy.org> Author: stefan Date: 2007-03-28 11:45:03 -0500 (Wed, 28 Mar 2007) New Revision: 2882 Modified: trunk/Lib/ndimage/src/ni_interpolation.c Log: Correct boundary checking. Modified: trunk/Lib/ndimage/src/ni_interpolation.c =================================================================== --- trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-28 15:01:14 UTC (rev 2881) +++ trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-28 16:45:03 UTC (rev 2882) @@ -153,7 +153,7 @@ in = -1; break; } - } else if (in >= len) { + } else if (in > len-1) { switch (mode) { case NI_EXTEND_MIRROR: if (len <= 1) { From scipy-svn at scipy.org Wed Mar 28 13:39:57 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 Mar 2007 12:39:57 -0500 (CDT) Subject: [Scipy-svn] r2883 - trunk/Lib/ndimage/src Message-ID: <20070328173957.BB72639C1E0@new.scipy.org> Author: stefan Date: 2007-03-28 12:39:40 -0500 (Wed, 28 Mar 2007) New Revision: 2883 Modified: trunk/Lib/ndimage/src/ni_interpolation.c Log: Fix boundary condition. Modified: trunk/Lib/ndimage/src/ni_interpolation.c =================================================================== --- trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-28 16:45:03 UTC (rev 2882) +++ trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-28 17:39:40 UTC (rev 2883) @@ -130,7 +130,7 @@ if (len <= 1) { in = 0; } else { - maybelong sz2 = 2 * len; + maybelong sz2 = 2 * len - 1; if (in < -sz2) in = sz2 * (maybelong)(-in / sz2) + in; in = in < -len ? in + sz2 : -in - 1; From scipy-svn at scipy.org Wed Mar 28 15:10:04 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 Mar 2007 14:10:04 -0500 (CDT) Subject: [Scipy-svn] r2884 - trunk/Lib/sandbox/timeseries/plotlib Message-ID: <20070328191004.A10D539C1F1@new.scipy.org> Author: mattknox_ca Date: 2007-03-28 14:10:01 -0500 (Wed, 28 Mar 2007) New Revision: 2884 Modified: trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py Log: added "add_yaxis" function/method Modified: trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py =================================================================== --- trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py 2007-03-28 17:39:40 UTC (rev 2883) +++ trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py 2007-03-28 19:10:01 UTC (rev 2884) @@ -757,7 +757,67 @@ TSPlot = TimeSeriesPlot +def add_yaxis(fsp=None, position='right', yscale=None, basey=10, subsy=None, + **kwargs): + """Adds a second y-axis to a plot. + +:Parameters: + `fsp` : Subplot *[None]* + Subplot to which the secondary y-axis is added. If *None*, the current + subplot is selected + `position` : String in `('left','right')` *['right']* + Position of the new axis. + `yscale` : String, in `('log', 'linear')` *[None]* + Scale of the new axis. If None, uses the same scale as the first y +axis + `basey` : Integer *[10]* + Base of the logarithm for the new axis (if needed). + `subsy` : sequence *[None]* + Sequence of the location of the minor ticks; + None defaults to autosubs, which depend on the number of decades in +the plot. + Eg for base 10, subsy=(1,2,5) will put minor ticks on 1,2,5,11,12,15, +21, .... + To turn off minor ticking, set subsy=[] + + """ + if fsp is None: + fsp = pylab.gca() + if not isinstance(fsp, TimeSeriesPlot): + raise TypeError("The current plot is not a TimeSeriesPlot") + fig = fsp.figure + axisini = fsp.axis() + fsp_alt_args = (fsp._rows, fsp._cols, fsp._num+1) + fsp_alt = fig.add_tsplot(frameon=False, position=fsp.get_position(), + sharex=fsp, *fsp_alt_args) + # Set position .................... + if position == 'right': + (inipos, newpos) = ('left', 'right') + else: + (inipos, newpos) = ('right','left') + # Force scales tics to one side ... + fsp.yaxis.set_ticks_position(inipos) + fsp.yaxis.set_label_position(inipos) + # Force 2nd ticks to the other side.. + fsp_alt.yaxis.set_ticks_position(newpos) + fsp_alt.yaxis.set_label_position(newpos) + # Force period axis scale.......... + if yscale is None: + yscale = fsp.get_yscale() + try: + basey = fsp.yaxis.get_major_locator()._base + except AttributeError: + basey = 10. + fsp_alt.set_yscale(yscale, basey=basey, subsy=subsy) + # Guess we're good ................ + fsp_alt.set_xticks('') + fsp_alt.set_xticklabels('') + + pylab.draw_if_interactive() + return fsp_alt +TimeSeriesPlot.add_yaxis = add_yaxis + #####-------------------------------------------------------------------------- #---- --- TimeSeries Figures --- #####-------------------------------------------------------------------------- From scipy-svn at scipy.org Wed Mar 28 17:54:38 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Wed, 28 Mar 2007 16:54:38 -0500 (CDT) Subject: [Scipy-svn] r2885 - in trunk/Lib/ndimage: src tests Message-ID: <20070328215438.01E4A39C0D5@new.scipy.org> Author: stefan Date: 2007-03-28 16:54:24 -0500 (Wed, 28 Mar 2007) New Revision: 2885 Modified: trunk/Lib/ndimage/src/ni_interpolation.c trunk/Lib/ndimage/tests/test_ndimage.py Log: Fix ndimage tests. Add brief comment in map_coordinates code. Modified: trunk/Lib/ndimage/src/ni_interpolation.c =================================================================== --- trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-28 19:10:01 UTC (rev 2884) +++ trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-28 21:54:24 UTC (rev 2885) @@ -141,9 +141,9 @@ in = 0; } else { maybelong sz = len; - in += sz * (maybelong)(-in / sz); - if (in < 0) - in += sz; + // Integer division of -in/sz gives (-in mod sz) + // Note that 'in' is negative + in += sz * ((maybelong)(-in / sz) + 1); } break; case NI_EXTEND_NEAREST: @@ -180,7 +180,7 @@ in = 0; } else { maybelong sz = len; - in -= sz * (maybelong)(in / sz); + in -= sz * (maybelong)(in / sz); } break; case NI_EXTEND_NEAREST: Modified: trunk/Lib/ndimage/tests/test_ndimage.py =================================================================== --- trunk/Lib/ndimage/tests/test_ndimage.py 2007-03-28 19:10:01 UTC (rev 2884) +++ trunk/Lib/ndimage/tests/test_ndimage.py 2007-03-28 21:54:24 UTC (rev 2885) @@ -1856,7 +1856,7 @@ for order in range(0, 6): out = ndimage.affine_transform(data, [[0.5]], output_shape = (4,), order=order) - self.failUnless(diff(out, [1, 1, 1, 1]) < eps) + self.failUnless(diff(out, [1, 1, 1, 0]) < eps) def test_affine_transform11(self): "affine transform 11" @@ -2072,7 +2072,7 @@ data = numpy.ones([2], numpy.float64) for order in range(0, 6): out = ndimage.zoom(data, 2.0, order=order) - self.failUnless(diff(out, [1, 1, 1, 1]) < eps) + self.failUnless(diff(out, [1, 1, 1, 0]) < eps) def test_zoom02(self): "zoom 2" @@ -2212,39 +2212,46 @@ def test_rotate05(self): "rotate 5" - data = numpy.array([[[0, 0, 0, 0, 0], - [0, 1, 1, 0, 0], - [0, 0, 0, 0, 0]]] * 3, - dtype = numpy.float64) - true = numpy.array([[[0, 0, 0], - [0, 0, 0], - [0, 1, 0], - [0, 1, 0], - [0, 0, 0]]] * 3, dtype = numpy.float64) + data = numpy.empty((4,3,3)) + for i in range(3): + data[:,:,i] = numpy.array([[0,0,0], + [0,1,0], + [0,1,0], + [0,0,0]], dtype = numpy.float64) + + true = numpy.array([[0,0,0,0], + [0,1,1,0], + [0,0,0,0]], dtype = numpy.float64) + for order in range(0, 6): out = ndimage.rotate(data, 90) - self.failUnless(diff(out, true) < eps) - + for i in range(3): + self.failUnless(diff(out[:,:,i], true) < eps) + def test_rotate06(self): "rotate 6" - data = numpy.array([[[0, 0, 0, 0, 0], - [0, 1, 1, 0, 0], - [0, 0, 0, 0, 0]]] * 3, - dtype = numpy.float64) - true = numpy.array([[[0, 0, 0, 0, 0], - [0, 0, 1, 0, 0], - [0, 0, 1, 0, 0]]] * 3, - dtype = numpy.float64) + data = numpy.empty((3,4,3)) + for i in range(3): + data[:,:,i] = numpy.array([[0,0,0,0], + [0,1,1,0], + [0,0,0,0]], dtype = numpy.float64) + + true = numpy.array([[0,0,0], + [0,1,0], + [0,1,0], + [0,0,0]], dtype = numpy.float64) + for order in range(0, 6): - out = ndimage.rotate(data, 90, reshape = False) - self.failUnless(diff(out, true) < eps) - + out = ndimage.rotate(data, 90) + for i in range(3): + self.failUnless(diff(out[:,:,i], true) < eps) + def test_rotate07(self): "rotate 7" data = numpy.array([[[0, 0, 0, 0, 0], - [0, 1, 1, 0, 0], - [0, 0, 0, 0, 0]]] * 2, - dtype = numpy.float64) + [0, 1, 1, 0, 0], + [0, 0, 0, 0, 0]]] * 2, + dtype = numpy.float64) data = data.transpose() true = numpy.array([[[0, 0, 0], [0, 1, 0], From scipy-svn at scipy.org Thu Mar 29 00:04:25 2007 From: scipy-svn at scipy.org (Online MensHealth) Date: Wed, 28 Mar 2007 23:04:25 -0500 (CDT) Subject: [Scipy-svn] Doc Martina Message-ID: <20070329090426.51056.qmail@olga_nikolaevna> An HTML attachment was scrubbed... URL: From scipy-svn at scipy.org Thu Mar 29 05:21:13 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 29 Mar 2007 04:21:13 -0500 (CDT) Subject: [Scipy-svn] r2886 - trunk/Lib/ndimage/src Message-ID: <20070329092113.613AAC7C011@new.scipy.org> Author: stefan Date: 2007-03-29 04:20:23 -0500 (Thu, 29 Mar 2007) New Revision: 2886 Modified: trunk/Lib/ndimage/src/nd_image.c trunk/Lib/ndimage/src/nd_image.h trunk/Lib/ndimage/src/ni_filters.c trunk/Lib/ndimage/src/ni_fourier.c trunk/Lib/ndimage/src/ni_interpolation.c trunk/Lib/ndimage/src/ni_interpolation.h trunk/Lib/ndimage/src/ni_measure.c trunk/Lib/ndimage/src/ni_morphology.c trunk/Lib/ndimage/src/ni_support.c trunk/Lib/ndimage/src/ni_support.h Log: Pull out numarray dependencies into nd_image header file. Some tests in morphology still fail. Modified: trunk/Lib/ndimage/src/nd_image.c =================================================================== --- trunk/Lib/ndimage/src/nd_image.c 2007-03-28 21:54:24 UTC (rev 2885) +++ trunk/Lib/ndimage/src/nd_image.c 2007-03-29 09:20:23 UTC (rev 2886) @@ -2,7 +2,7 @@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions - * are met: + * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. @@ -15,7 +15,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -26,7 +26,7 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #define ND_IMPORT_ARRAY @@ -46,52 +46,52 @@ } NI_PythonCallbackData; /* Convert an input array of any type, not necessarily contiguous */ -static int +static int NI_ObjectToInputArray(PyObject *object, PyArrayObject **array) { - *array = NA_InputArray(object, tAny, NUM_ALIGNED|NUM_NOTSWAPPED); + *array = NA_InputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); return *array ? 1 : 0; } /* Convert an input array of any type, not necessarily contiguous */ -static int +static int NI_ObjectToOptionalInputArray(PyObject *object, PyArrayObject **array) { if (object == Py_None) { *array = NULL; return 1; } else { - *array = NA_InputArray(object, tAny, NUM_ALIGNED|NUM_NOTSWAPPED); + *array = NA_InputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); return *array ? 1 : 0; } } /* Convert an output array of any type, not necessarily contiguous */ -static int +static int NI_ObjectToOutputArray(PyObject *object, PyArrayObject **array) { - *array = NA_OutputArray(object, tAny, NUM_ALIGNED|NUM_NOTSWAPPED); + *array = NA_OutputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); return *array ? 1 : 0; } /* Convert an output array of any type, not necessarily contiguous */ -static int +static int NI_ObjectToOptionalOutputArray(PyObject *object, PyArrayObject **array) { if (object == Py_None) { *array = NULL; return 1; } else { - *array = NA_OutputArray(object, tAny, NUM_ALIGNED|NUM_NOTSWAPPED); + *array = NA_OutputArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); return *array ? 1 : 0; } } /* Convert an input/output array of any type, not necessarily contiguous */ -static int +static int NI_ObjectToIoArray(PyObject *object, PyArrayObject **array) { - *array = NA_IoArray(object, tAny, NUM_ALIGNED|NUM_NOTSWAPPED); + *array = NA_IoArray(object, tAny, NPY_ALIGNED|NPY_NOTSWAPPED); return *array ? 1 : 0; } @@ -100,23 +100,23 @@ NI_ObjectToLongSequenceAndLength(PyObject *object, maybelong **sequence) { long *pa, ii; - PyArrayObject *array = NA_InputArray(object, PyArray_LONG, C_ARRAY); + PyArrayObject *array = NA_InputArray(object, PyArray_LONG, NPY_CARRAY); maybelong length = NA_elements(array); - + *sequence = (maybelong*)malloc(length * sizeof(maybelong)); if (!*sequence) { PyErr_NoMemory(); Py_XDECREF(array); return -1; } - pa = (long*)NA_OFFSETDATA(array); + pa = (long*)PyArray_DATA(array); for(ii = 0; ii < length; ii++) (*sequence)[ii] = pa[ii]; Py_XDECREF(array); return length; } -static int +static int NI_ObjectToLongSequence(PyObject *object, maybelong **sequence) { return NI_ObjectToLongSequenceAndLength(object, sequence) >= 0; @@ -132,9 +132,9 @@ int axis, mode; long origin; double cval; - - if (!PyArg_ParseTuple(args, "O&O&iO&idl", NI_ObjectToInputArray, &input, - NI_ObjectToInputArray, &weights, &axis, + + if (!PyArg_ParseTuple(args, "O&O&iO&idl", NI_ObjectToInputArray, &input, + NI_ObjectToInputArray, &weights, &axis, NI_ObjectToOutputArray, &output, &mode, &cval, &origin)) goto exit; if (!NI_Correlate1D(input, weights, axis, output, @@ -153,12 +153,12 @@ maybelong *origin = NULL; int mode; double cval; - - if (!PyArg_ParseTuple(args, "O&O&O&idO&", NI_ObjectToInputArray, &input, - NI_ObjectToInputArray, &weights, NI_ObjectToOutputArray, &output, + + if (!PyArg_ParseTuple(args, "O&O&O&idO&", NI_ObjectToInputArray, &input, + NI_ObjectToInputArray, &weights, NI_ObjectToOutputArray, &output, &mode, &cval, NI_ObjectToLongSequence, &origin)) goto exit; - if (!NI_Correlate(input, weights, output, (NI_ExtendMode)mode, cval, + if (!NI_Correlate(input, weights, output, (NI_ExtendMode)mode, cval, origin)) goto exit; exit: @@ -176,8 +176,8 @@ int axis, mode; long filter_size, origin; double cval; - - if (!PyArg_ParseTuple(args, "O&liO&idl", NI_ObjectToInputArray, &input, + + if (!PyArg_ParseTuple(args, "O&liO&idl", NI_ObjectToInputArray, &input, &filter_size, &axis, NI_ObjectToOutputArray, &output, &mode, &cval, &origin)) goto exit; @@ -196,8 +196,8 @@ int axis, mode, minimum; long filter_size, origin; double cval; - - if (!PyArg_ParseTuple(args, "O&liO&idli", NI_ObjectToInputArray, &input, + + if (!PyArg_ParseTuple(args, "O&liO&idli", NI_ObjectToInputArray, &input, &filter_size, &axis, NI_ObjectToOutputArray, &output, &mode, &cval, &origin, &minimum)) goto exit; @@ -217,7 +217,7 @@ maybelong *origin = NULL; int mode, minimum; double cval; - + if (!PyArg_ParseTuple(args, "O&O&O&O&idO&i", NI_ObjectToInputArray, &input, NI_ObjectToInputArray, &footprint, NI_ObjectToOptionalInputArray, &structure, @@ -243,7 +243,7 @@ maybelong *origin = NULL; int mode, rank; double cval; - + if (!PyArg_ParseTuple(args, "O&iO&O&idO&", NI_ObjectToInputArray, &input, &rank, NI_ObjectToInputArray, &footprint, NI_ObjectToOutputArray, &output, &mode, &cval, @@ -264,12 +264,12 @@ static int Py_Filter1DFunc(double *iline, maybelong ilen, double *oline, maybelong olen, void *data) { - PyArrayObject *py_ibuffer = NULL, *py_obuffer = NULL; + PyArrayObject *py_ibuffer = NULL, *py_obuffer = NULL; PyObject *rv = NULL, *args = NULL, *tmp = NULL; maybelong ii; double *po = NULL; NI_PythonCallbackData *cbdata = (NI_PythonCallbackData*)data; - + py_ibuffer = NA_NewArray(iline, PyArray_DOUBLE, 1, (int)ilen); py_obuffer = NA_NewArray(NULL, PyArray_DOUBLE, 1, (int)olen); if (!py_ibuffer || !py_obuffer) @@ -283,7 +283,7 @@ rv = PyObject_Call(cbdata->function, args, cbdata->extra_keywords); if (!rv) goto exit; - po = (double*)NA_OFFSETDATA(py_obuffer); + po = (double*)PyArray_DATA(py_obuffer); for(ii = 0; ii < olen; ii++) oline[ii] = po[ii]; exit: @@ -304,9 +304,9 @@ int axis, mode; long origin, filter_size; double cval; - - if (!PyArg_ParseTuple(args, "O&OliO&idlOO", NI_ObjectToInputArray, - &input, &fnc, &filter_size, &axis, NI_ObjectToOutputArray, + + if (!PyArg_ParseTuple(args, "O&OliO&idlOO", NI_ObjectToInputArray, + &input, &fnc, &filter_size, &axis, NI_ObjectToOutputArray, &output, &mode, &cval, &origin, &extra_arguments, &extra_keywords)) goto exit; if (!PyTuple_Check(extra_arguments)) { @@ -378,8 +378,8 @@ int mode; maybelong *origin = NULL; double cval; - - if (!PyArg_ParseTuple(args, "O&OO&O&idO&OO", NI_ObjectToInputArray, + + if (!PyArg_ParseTuple(args, "O&OO&O&idO&OO", NI_ObjectToInputArray, &input, &fnc, NI_ObjectToInputArray, &footprint, NI_ObjectToOutputArray, &output, &mode, &cval, NI_ObjectToLongSequence, &origin, @@ -425,15 +425,15 @@ PyArrayObject *input = NULL, *output = NULL, *parameters = NULL; int axis, filter_type; long n; - - if (!PyArg_ParseTuple(args, "O&O&liO&i", NI_ObjectToInputArray, &input, + + if (!PyArg_ParseTuple(args, "O&O&liO&i", NI_ObjectToInputArray, &input, NI_ObjectToInputArray, ¶meters, &n, &axis, NI_ObjectToOutputArray, &output, &filter_type)) - goto exit; - + goto exit; + if (!NI_FourierFilter(input, parameters, n, axis, output, filter_type)) goto exit; - + exit: Py_XDECREF(input); Py_XDECREF(parameters); @@ -446,15 +446,15 @@ PyArrayObject *input = NULL, *output = NULL, *shifts = NULL; int axis; long n; - - if (!PyArg_ParseTuple(args, "O&O&liO&", NI_ObjectToInputArray, &input, + + if (!PyArg_ParseTuple(args, "O&O&liO&", NI_ObjectToInputArray, &input, NI_ObjectToInputArray, &shifts, &n, &axis, NI_ObjectToOutputArray, &output)) - goto exit; - + goto exit; + if (!NI_FourierShift(input, shifts, n, axis, output)) goto exit; - + exit: Py_XDECREF(input); Py_XDECREF(shifts); @@ -466,11 +466,11 @@ { PyArrayObject *input = NULL, *output = NULL; int axis, order; - + if (!PyArg_ParseTuple(args, "O&iiO&", NI_ObjectToInputArray, &input, &order, &axis, NI_ObjectToOutputArray, &output)) goto exit; - + if (!NI_SplineFilter1D(input, order, axis, output)) goto exit; @@ -480,7 +480,7 @@ return PyErr_Occurred() ? NULL : Py_BuildValue(""); } -static int Py_Map(maybelong *ocoor, double* icoor, int orank, int irank, +static int Py_Map(maybelong *ocoor, double* icoor, int orank, int irank, void *data) { PyObject *coors = NULL, *rets = NULL, *args = NULL, *tmp = NULL; @@ -527,10 +527,10 @@ double cval; void *func = NULL, *data = NULL; NI_PythonCallbackData cbdata; - + if (!PyArg_ParseTuple(args, "O&OO&O&O&O&iidOO", NI_ObjectToInputArray, &input, &fnc, NI_ObjectToOptionalInputArray, - &coordinates, NI_ObjectToOptionalInputArray, + &coordinates, NI_ObjectToOptionalInputArray, &matrix, NI_ObjectToOptionalInputArray, &shift, NI_ObjectToOutputArray, &output, &order, &mode, &cval, &extra_arguments, &extra_keywords)) @@ -562,8 +562,8 @@ goto exit; } } - - if (!NI_GeometricTransform(input, func, data, matrix, shift, coordinates, + + if (!NI_GeometricTransform(input, func, data, matrix, shift, coordinates, output, order, (NI_ExtendMode)mode, cval)) goto exit; @@ -582,8 +582,8 @@ PyArrayObject *zoom = NULL; int mode, order; double cval; - - if (!PyArg_ParseTuple(args, "O&O&O&O&iid", NI_ObjectToInputArray, + + if (!PyArg_ParseTuple(args, "O&O&O&O&iid", NI_ObjectToInputArray, &input, NI_ObjectToOptionalInputArray, &zoom, NI_ObjectToOptionalInputArray, &shift, NI_ObjectToOutputArray, &output, &order, &mode, &cval)) @@ -606,10 +606,10 @@ PyArrayObject *input = NULL, *output = NULL, *strct = NULL; maybelong max_label; - if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &input, + if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &input, NI_ObjectToInputArray, &strct, NI_ObjectToOutputArray, &output)) goto exit; - + if (!NI_Label(input, strct, &max_label, output)) goto exit; @@ -632,12 +632,12 @@ if (!PyArg_ParseTuple(args, "O&l", NI_ObjectToInputArray, &input, &max_label)) goto exit; - + if (max_label < 0) max_label = 0; if (max_label > 0) { if (input->nd > 0) { - regions = (maybelong*)malloc(2 * max_label * input->nd * + regions = (maybelong*)malloc(2 * max_label * input->nd * sizeof(maybelong)); } else { regions = (maybelong*)malloc(max_label * sizeof(maybelong)); @@ -647,7 +647,7 @@ goto exit; } } - + if (!NI_FindObjects(input, max_label, regions)) goto exit; @@ -715,11 +715,11 @@ PyArrayObject *input = NULL, *output = NULL, *markers = NULL; PyArrayObject *strct = NULL; - if (!PyArg_ParseTuple(args, "O&O&O&O&", NI_ObjectToInputArray, &input, + if (!PyArg_ParseTuple(args, "O&O&O&O&", NI_ObjectToInputArray, &input, NI_ObjectToInputArray, &markers, NI_ObjectToInputArray, &strct, NI_ObjectToOutputArray, &output)) goto exit; - + if (!NI_WatershedIFT(input, markers, strct, output)) goto exit; @@ -731,7 +731,7 @@ return PyErr_Occurred() ? NULL : Py_BuildValue(""); } -static int _NI_GetIndices(PyObject* indices_object, +static int _NI_GetIndices(PyObject* indices_object, maybelong** result_indices, maybelong* min_label, maybelong* max_label, maybelong* n_results) { @@ -765,7 +765,7 @@ if (indices[ii] > *max_label) *max_label = indices[ii]; } - *result_indices = (maybelong*)malloc((*max_label - *min_label + 1) * + *result_indices = (maybelong*)malloc((*max_label - *min_label + 1) * sizeof(maybelong)); if (!*result_indices) { PyErr_NoMemory(); @@ -912,8 +912,8 @@ maybelong *lresult1 = NULL, *lresult2 = NULL; maybelong min_label, max_label, *result_indices = NULL, n_results, ii; int type; - - if (!PyArg_ParseTuple(args, "O&O&Oi", NI_ObjectToInputArray, &input, + + if (!PyArg_ParseTuple(args, "O&O&Oi", NI_ObjectToInputArray, &input, NI_ObjectToOptionalInputArray, &labels, &indices_object, &type)) goto exit; @@ -951,53 +951,53 @@ } switch(type) { case 0: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, n_results, dresult1, NULL, NULL, NULL, NULL, NULL, NULL)) goto exit; result = _NI_BuildMeasurementResultDouble(n_results, dresult1); break; case 1: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, n_results, dresult1, lresult1, NULL, NULL, NULL, NULL, NULL)) goto exit; for(ii = 0; ii < n_results; ii++) dresult1[ii] = lresult1[ii] > 0 ? dresult1[ii] / lresult1[ii] : 0.0; - + result = _NI_BuildMeasurementResultDouble(n_results, dresult1); - break; + break; case 2: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, n_results, dresult1, lresult1, dresult2, NULL, NULL, NULL, NULL)) goto exit; result = _NI_BuildMeasurementResultDouble(n_results, dresult2); break; case 3: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, n_results, NULL, NULL, NULL, dresult1, NULL, NULL, NULL)) goto exit; result = _NI_BuildMeasurementResultDouble(n_results, dresult1); break; case 4: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, n_results, NULL, NULL, NULL, NULL, dresult1, NULL, NULL)) goto exit; result = _NI_BuildMeasurementResultDouble(n_results, dresult1); break; case 5: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, n_results, NULL, NULL, NULL, dresult1, NULL, lresult1, NULL)) goto exit; result = _NI_BuildMeasurementResultInt(n_results, lresult1); break; case 6: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, n_results, NULL, NULL, NULL, NULL, dresult1, NULL, lresult1)) goto exit; result = _NI_BuildMeasurementResultInt(n_results, lresult1); break; case 7: - if (!NI_Statistics(input, labels, min_label, max_label, result_indices, - n_results, NULL, NULL, NULL, dresult1, dresult2, + if (!NI_Statistics(input, labels, min_label, max_label, result_indices, + n_results, NULL, NULL, NULL, dresult1, dresult2, lresult1, lresult2)) goto exit; res1 = _NI_BuildMeasurementResultDouble(n_results, dresult1); @@ -1036,8 +1036,8 @@ PyObject *indices_object, *result = NULL; double *center_of_mass = NULL; maybelong min_label, max_label, *result_indices = NULL, n_results; - - if (!PyArg_ParseTuple(args, "O&O&O", NI_ObjectToInputArray, &input, + + if (!PyArg_ParseTuple(args, "O&O&O", NI_ObjectToInputArray, &input, NI_ObjectToOptionalInputArray, &labels, &indices_object)) goto exit; @@ -1045,13 +1045,13 @@ &max_label, &n_results)) goto exit; - center_of_mass = (double*)malloc(input->nd * n_results * + center_of_mass = (double*)malloc(input->nd * n_results * sizeof(double)); if (!center_of_mass) { PyErr_NoMemory(); goto exit; } - + if (!NI_CenterOfMass(input, labels, min_label, max_label, result_indices, n_results, center_of_mass)) goto exit; @@ -1101,8 +1101,8 @@ goto exit; } } - - if (!NI_Histogram(input, labels, min_label, max_label, result_indices, + + if (!NI_Histogram(input, labels, min_label, max_label, result_indices, n_results, histograms, min, max, nbins)) goto exit; @@ -1130,11 +1130,11 @@ int metric; if (!PyArg_ParseTuple(args, "O&iO&O&O&", NI_ObjectToInputArray, &input, - &metric, NI_ObjectToOptionalInputArray, &sampling, - NI_ObjectToOptionalOutputArray, &output, + &metric, NI_ObjectToOptionalInputArray, &sampling, + NI_ObjectToOptionalOutputArray, &output, NI_ObjectToOptionalOutputArray, &features)) goto exit; - if (!NI_DistanceTransformBruteForce(input, metric, sampling, + if (!NI_DistanceTransformBruteForce(input, metric, sampling, output, features)) goto exit; exit: @@ -1156,9 +1156,9 @@ if (!NI_DistanceTransformOnePass(strct, distances, features)) goto exit; exit: - Py_XDECREF(strct); - Py_XDECREF(distances); - Py_XDECREF(features); + Py_XDECREF(strct); + Py_XDECREF(distances); + Py_XDECREF(features); return PyErr_Occurred() ? NULL : Py_BuildValue(""); } @@ -1167,7 +1167,7 @@ { PyArrayObject *input = NULL, *features = NULL, *sampling = NULL; - if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &input, + if (!PyArg_ParseTuple(args, "O&O&O&", NI_ObjectToInputArray, &input, NI_ObjectToOptionalInputArray, &sampling, NI_ObjectToOutputArray, &features)) goto exit; @@ -1180,7 +1180,7 @@ return PyErr_Occurred() ? NULL : Py_BuildValue(""); } -static void _FreeCoordinateList(void* ptr) +static void _FreeCoordinateList(void* ptr) { NI_FreeCoordinateList((NI_CoordinateList*)ptr); } @@ -1198,12 +1198,12 @@ if (!PyArg_ParseTuple(args, "O&O&O&O&iO&iii", NI_ObjectToInputArray, &input, NI_ObjectToInputArray, &strct, NI_ObjectToOptionalInputArray, &mask, - NI_ObjectToOutputArray, &output, &border_value, + NI_ObjectToOutputArray, &output, &border_value, NI_ObjectToLongSequence, &origins, &invert, ¢er_is_true, &return_coordinates)) goto exit; if (!NI_BinaryErosion(input, strct, mask, output, border_value, - origins, invert, center_is_true, &changed, + origins, invert, center_is_true, &changed, return_coordinates ? &coordinate_list : NULL)) goto exit; if (return_coordinates) { @@ -1235,15 +1235,15 @@ int invert, niter; maybelong *origins = NULL; - if (!PyArg_ParseTuple(args, "O&O&O&iO&iO", NI_ObjectToIoArray, &array, - NI_ObjectToInputArray, &strct, NI_ObjectToOptionalInputArray, + if (!PyArg_ParseTuple(args, "O&O&O&iO&iO", NI_ObjectToIoArray, &array, + NI_ObjectToInputArray, &strct, NI_ObjectToOptionalInputArray, &mask, &niter, NI_ObjectToLongSequence, &origins, &invert, &cobj)) goto exit; - + if (PyCObject_Check(cobj)) { NI_CoordinateList *cobj_data = PyCObject_AsVoidPtr(cobj); - if (!NI_BinaryErosion2(array, strct, mask, niter, origins, invert, + if (!NI_BinaryErosion2(array, strct, mask, niter, origins, invert, &cobj_data)) goto exit; } else { @@ -1297,9 +1297,9 @@ METH_VARARGS, ""}, {"histogram", (PyCFunction)Py_Histogram, METH_VARARGS, ""}, - {"distance_transform_bf", (PyCFunction)Py_DistanceTransformBruteForce, + {"distance_transform_bf", (PyCFunction)Py_DistanceTransformBruteForce, METH_VARARGS, ""}, - {"distance_transform_op", (PyCFunction)Py_DistanceTransformOnePass, + {"distance_transform_op", (PyCFunction)Py_DistanceTransformOnePass, METH_VARARGS, ""}, {"euclidean_feature_transform", (PyCFunction)Py_EuclideanFeatureTransform, METH_VARARGS, ""}, @@ -1313,5 +1313,5 @@ PyMODINIT_FUNC init_nd_image(void) { Py_InitModule("_nd_image", methods); - import_libnumarray(); + import_array(); } Modified: trunk/Lib/ndimage/src/nd_image.h =================================================================== --- trunk/Lib/ndimage/src/nd_image.h 2007-03-28 21:54:24 UTC (rev 2885) +++ trunk/Lib/ndimage/src/nd_image.h 2007-03-29 09:20:23 UTC (rev 2886) @@ -2,7 +2,7 @@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions - * are met: + * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. @@ -15,7 +15,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -26,7 +26,7 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef ND_IMAGE_H @@ -41,7 +41,7 @@ #define MAXDIM NPY_MAXDIMS typedef enum -{ +{ tAny=-1, tBool=PyArray_BOOL, tInt8=PyArray_INT8, @@ -66,12 +66,218 @@ #endif } NumarrayType; -/* int NI_GetArrayRank(PyArrayObject*); -NumarrayType NI_GetArrayType(PyArrayObject*); -void NI_GetArrayDimensions(PyArrayObject*, int*); -void NI_GetArrayStrides(PyArrayObject*, int*); -char* NI_GetArrayData(PyArrayObject*); -int NI_ShapeEqual(PyArrayObject*, PyArrayObject*); -int NI_CheckArray(PyArrayObject*, NumarrayType, int, int*); */ +/* satisfies ensures that 'a' meets a set of requirements and matches +the specified type. +*/ +static int +satisfies(PyArrayObject *a, int requirements, NumarrayType t) +{ + int type_ok = (a->descr->type_num == t) || (t == tAny); + if (PyArray_ISCARRAY(a)) + return type_ok; + if (PyArray_ISBYTESWAPPED(a) && (requirements & NPY_NOTSWAPPED)) + return 0; + if (!PyArray_ISALIGNED(a) && (requirements & NPY_ALIGNED)) + return 0; + if (!PyArray_ISCONTIGUOUS(a) && (requirements & NPY_CONTIGUOUS)) + return 0; + if (!PyArray_ISWRITEABLE(a) && (requirements & NPY_WRITEABLE)) + return 0; + if (requirements & NPY_ENSURECOPY) + return 0; + return type_ok; +} + +static PyArrayObject* +NA_InputArray(PyObject *a, NumarrayType t, int requires) +{ + PyArray_Descr *descr; + if (t == tAny) descr = NULL; + else descr = PyArray_DescrFromType(t); + return (PyArrayObject *) \ + PyArray_CheckFromAny(a, descr, 0, 0, requires, NULL); +} + +static PyArrayObject * +NA_OutputArray(PyObject *a, NumarrayType t, int requires) +{ + PyArray_Descr *dtype; + PyArrayObject *ret; + + if (!PyArray_Check(a) || !PyArray_ISWRITEABLE(a)) { + PyErr_Format(PyExc_TypeError, + "NA_OutputArray: only writeable arrays work for output."); + return NULL; + } + + if (satisfies((PyArrayObject *)a, requires, t)) { + Py_INCREF(a); + return (PyArrayObject *)a; + } + if (t == tAny) { + dtype = PyArray_DESCR(a); + Py_INCREF(dtype); + } + else { + dtype = PyArray_DescrFromType(t); + } + ret = (PyArrayObject *)PyArray_Empty(PyArray_NDIM(a), PyArray_DIMS(a), + dtype, 0); + ret->flags |= NPY_UPDATEIFCOPY; + ret->base = a; + PyArray_FLAGS(a) &= ~NPY_WRITEABLE; + Py_INCREF(a); + return ret; +} + +/* NA_IoArray is a combination of NA_InputArray and NA_OutputArray. + +Unlike NA_OutputArray, if a temporary is required it is initialized to a copy +of the input array. + +Unlike NA_InputArray, deallocating any resulting temporary array results in a +copy from the temporary back to the original. +*/ +static PyArrayObject * +NA_IoArray(PyObject *a, NumarrayType t, int requires) +{ + PyArrayObject *shadow = NA_InputArray(a, t, requires | NPY_UPDATEIFCOPY ); + + if (!shadow) return NULL; + + /* Guard against non-writable, but otherwise satisfying requires. + In this case, shadow == a. + */ + if (!PyArray_ISWRITEABLE(shadow)) { + PyErr_Format(PyExc_TypeError, + "NA_IoArray: I/O array must be writable array"); + PyArray_XDECREF_ERR(shadow); + return NULL; + } + + return shadow; +} + +static unsigned long +NA_elements(PyArrayObject *a) +{ + int i; + unsigned long n = 1; + for(i = 0; ind; i++) + n *= a->dimensions[i]; + return n; +} + +#define NUM_LITTLE_ENDIAN 0 +#define NUM_BIG_ENDIAN 1 + +static int +NA_ByteOrder(void) +{ + unsigned long byteorder_test; + byteorder_test = 1; + if (*((char *) &byteorder_test)) + return NUM_LITTLE_ENDIAN; + else + return NUM_BIG_ENDIAN; +} + +/* ignores bytestride */ +static PyArrayObject * +NA_NewAllFromBuffer(int ndim, maybelong *shape, NumarrayType type, + PyObject *bufferObject, maybelong byteoffset, maybelong bytestride, + int byteorder, int aligned, int writeable) +{ + PyArrayObject *self = NULL; + PyArray_Descr *dtype; + + if (type == tAny) + type = tDefault; + + dtype = PyArray_DescrFromType(type); + if (dtype == NULL) return NULL; + + if (byteorder != NA_ByteOrder()) { + PyArray_Descr *temp; + temp = PyArray_DescrNewByteorder(dtype, PyArray_SWAP); + Py_DECREF(dtype); + if (temp == NULL) return NULL; + dtype = temp; + } + + if (bufferObject == Py_None || bufferObject == NULL) { + self = (PyArrayObject *) \ + PyArray_NewFromDescr(&PyArray_Type, dtype, + ndim, shape, NULL, NULL, + 0, NULL); + } + else { + npy_intp size = 1; + int i; + PyArrayObject *newself; + PyArray_Dims newdims; + for(i=0; idescr->elsize * NA_elements(a)) + +static PyArrayObject * +NA_NewAll(int ndim, maybelong *shape, NumarrayType type, + void *buffer, maybelong byteoffset, maybelong bytestride, + int byteorder, int aligned, int writeable) +{ + PyArrayObject *result = NA_NewAllFromBuffer( + ndim, shape, type, Py_None, + byteoffset, bytestride, + byteorder, aligned, writeable); + if (result) { + if (!PyArray_Check((PyObject *) result)) { + PyErr_Format( PyExc_TypeError, + "NA_NewAll: non-NumArray result"); + result = NULL; + } else { + if (buffer) { + memcpy(result->data, buffer, NA_NBYTES(result)); + } else { + memset(result->data, 0, NA_NBYTES(result)); + } + } + } + return result; +} + +/* Create a new numarray which is initially a C_array, or which +references a C_array: aligned, !byteswapped, contiguous, ... +Call with buffer==NULL to allocate storage. +*/ +static PyArrayObject * +NA_NewArray(void *buffer, NumarrayType type, int ndim, maybelong *shape) +{ + return (PyArrayObject *) NA_NewAll(ndim, shape, type, buffer, 0, 0, + NA_ByteOrder(), 1, 1); +} + + +#define NA_InputArray (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) (void *) NA_InputArray) +#define NA_OutputArray (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) (void *) NA_OutputArray) +#define NA_IoArray (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) (void *) NA_IoArray) +#define NA_elements (*(unsigned long (*) (PyArrayObject*) ) (void *) NA_elements) +#define NA_NewArray (*(PyArrayObject* (*) (void* buffer, NumarrayType type, int ndim, ...) ) (void *) NA_NewArray ) + #endif Modified: trunk/Lib/ndimage/src/ni_filters.c =================================================================== --- trunk/Lib/ndimage/src/ni_filters.c 2007-03-28 21:54:24 UTC (rev 2885) +++ trunk/Lib/ndimage/src/ni_filters.c 2007-03-29 09:20:23 UTC (rev 2886) @@ -2,7 +2,7 @@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions - * are met: + * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. @@ -15,7 +15,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -26,7 +26,7 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "ni_support.h" @@ -50,7 +50,7 @@ filter_size = weights->dimensions[0]; size1 = filter_size / 2; size2 = filter_size - size1 - 1; - fw = NA_OFFSETDATA(weights); + fw = (void *)PyArray_DATA(weights); if (filter_size & 0x1) { symmetric = 1; for(ii = 1; ii <= filter_size / 2; ii++) { @@ -74,13 +74,13 @@ if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin, &lines, BUFFER_SIZE, &ibuffer)) goto exit; - if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, + if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, &obuffer)) goto exit; - if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, + if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, lines, ibuffer, mode, cval, &iline_buffer)) goto exit; - if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, + if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, &oline_buffer)) goto exit; length = input->nd > 0 ? input->dimensions[axis] : 1; @@ -162,12 +162,12 @@ Float64 *pw; Float64 *ww = NULL; int ll; - + /* get the the footprint: */ fsize = 1; for(ll = 0; ll < weights->nd; ll++) fsize *= weights->dimensions[ll]; - pw = (Float64*)NA_OFFSETDATA(weights); + pw = (Float64*)PyArray_DATA(weights); pf = (Bool*)malloc(fsize * sizeof(Bool)); if (!pf) { PyErr_NoMemory(); @@ -208,8 +208,8 @@ if (!NI_InitPointIterator(output, &io)) goto exit; /* get data pointers an array size: */ - pi = NA_OFFSETDATA(input); - po = NA_OFFSETDATA(output); + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); size = 1; for(ll = 0; ll < input->nd; ll++) size *= input->dimensions[ll]; @@ -229,7 +229,7 @@ #if HAS_UINT64 CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, UInt64, tmp, border_flag_value); -#endif +#endif CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Int8, tmp, border_flag_value); CASE_CORRELATE_POINT(pi, ww, oo, filter_size, cvalue, Int16, @@ -253,7 +253,7 @@ CASE_FILTER_OUT(po, tmp, UInt32); #if HAS_UINT64 CASE_FILTER_OUT(po, tmp, UInt64); -#endif +#endif CASE_FILTER_OUT(po, tmp, Int8); CASE_FILTER_OUT(po, tmp, Int16); CASE_FILTER_OUT(po, tmp, Int32); @@ -290,17 +290,17 @@ if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin, &lines, BUFFER_SIZE, &ibuffer)) goto exit; - if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, + if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, &obuffer)) goto exit; - if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, + if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, lines, ibuffer, mode, cval, &iline_buffer)) goto exit; - if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, + if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, &oline_buffer)) goto exit; length = input->nd > 0 ? input->dimensions[axis] : 1; - + /* iterate over all the array lines: */ do { /* copy lines from array to buffer: */ @@ -352,17 +352,17 @@ if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin, &lines, BUFFER_SIZE, &ibuffer)) goto exit; - if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, + if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, &obuffer)) goto exit; - if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, + if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, lines, ibuffer, mode, cval, &iline_buffer)) goto exit; - if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, + if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, &oline_buffer)) goto exit; length = input->nd > 0 ? input->dimensions[axis] : 1; - + /* iterate over all the array lines: */ do { /* copy lines from array to buffer: */ @@ -378,7 +378,7 @@ double val = iline[ll - size1]; for(jj = -size1 + 1; jj <= size2; jj++) { double tmp = iline[ll + jj]; - if (minimum) { + if (minimum) { if (tmp < val) val = tmp; } else { @@ -439,12 +439,12 @@ int ll; double *ss = NULL; Float64 *ps; - + /* get the the footprint: */ fsize = 1; for(ll = 0; ll < footprint->nd; ll++) fsize *= footprint->dimensions[ll]; - pf = (Bool*)NA_OFFSETDATA(footprint); + pf = (Bool*)PyArray_DATA(footprint); for(jj = 0; jj < fsize; jj++) { if (pf[jj]) { ++filter_size; @@ -458,7 +458,7 @@ goto exit; } /* copy the weights to contiguous memory: */ - ps = (Float64*)NA_OFFSETDATA(structure); + ps = (Float64*)PyArray_DATA(structure); jj = 0; for(kk = 0; kk < fsize; kk++) if (pf[kk]) @@ -469,7 +469,7 @@ mode, &offsets, &border_flag_value, NULL)) goto exit; /* initialize filter iterator: */ - if (!NI_InitFilterIterator(input->nd, footprint->dimensions, + if (!NI_InitFilterIterator(input->nd, footprint->dimensions, filter_size, input->dimensions, origins, &fi)) goto exit; /* initialize input element iterator: */ @@ -479,8 +479,8 @@ if (!NI_InitPointIterator(output, &io)) goto exit; /* get data pointers an array size: */ - pi = NA_OFFSETDATA(input); - po = NA_OFFSETDATA(output); + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); size = 1; for(ll = 0; ll < input->nd; ll++) size *= input->dimensions[ll]; @@ -500,7 +500,7 @@ #if HAS_UINT64 CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, UInt64, minimum, tmp, border_flag_value, ss); -#endif +#endif CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Int8, minimum, tmp, border_flag_value, ss); CASE_MIN_OR_MAX_POINT(pi, oo, filter_size, cvalue, Int16, @@ -524,7 +524,7 @@ CASE_FILTER_OUT(po, tmp, UInt32); #if HAS_UINT64 CASE_FILTER_OUT(po, tmp, UInt64); -#endif +#endif CASE_FILTER_OUT(po, tmp, Int8); CASE_FILTER_OUT(po, tmp, Int16); CASE_FILTER_OUT(po, tmp, Int32); @@ -544,37 +544,37 @@ } static double NI_Select(double *buffer, int min, int max, int rank) -{ - int ii, jj; - double x, t; - - if (min == max) - return buffer[min]; - - x = buffer[min]; - ii = min - 1; - jj = max + 1; - for(;;) { - do - jj--; - while(buffer[jj] > x); - do - ii++; - while(buffer[ii] < x); - if (ii < jj) { - t = buffer[ii]; - buffer[ii] = buffer[jj]; - buffer[jj] = t; - } else { - break; - } - } - - ii = jj - min + 1; - if (rank < ii) - return NI_Select(buffer, min, jj, rank); - else - return NI_Select(buffer, jj + 1, max, rank - ii); +{ + int ii, jj; + double x, t; + + if (min == max) + return buffer[min]; + + x = buffer[min]; + ii = min - 1; + jj = max + 1; + for(;;) { + do + jj--; + while(buffer[jj] > x); + do + ii++; + while(buffer[ii] < x); + if (ii < jj) { + t = buffer[ii]; + buffer[ii] = buffer[jj]; + buffer[jj] = t; + } else { + break; + } + } + + ii = jj - min + 1; + if (rank < ii) + return NI_Select(buffer, min, jj, rank); + else + return NI_Select(buffer, jj + 1, max, rank - ii); } #define CASE_RANK_POINT(_pi, _offsets, _filter_size, _cval, _type, \ @@ -593,7 +593,7 @@ } \ break -int NI_RankFilter(PyArrayObject* input, int rank, +int NI_RankFilter(PyArrayObject* input, int rank, PyArrayObject* footprint, PyArrayObject* output, NI_ExtendMode mode, double cvalue, maybelong *origins) { @@ -605,12 +605,12 @@ Bool *pf = NULL; double *buffer = NULL; int ll; - + /* get the the footprint: */ fsize = 1; for(ll = 0; ll < footprint->nd; ll++) fsize *= footprint->dimensions[ll]; - pf = (Bool*)NA_OFFSETDATA(footprint); + pf = (Bool*)PyArray_DATA(footprint); for(jj = 0; jj < fsize; jj++) { if (pf[jj]) { ++filter_size; @@ -625,11 +625,11 @@ /* iterator over the elements: */ oo = offsets; /* initialize filter offsets: */ - if (!NI_InitFilterOffsets(input, pf, footprint->dimensions, origins, + if (!NI_InitFilterOffsets(input, pf, footprint->dimensions, origins, mode, &offsets, &border_flag_value, NULL)) goto exit; /* initialize filter iterator: */ - if (!NI_InitFilterIterator(input->nd, footprint->dimensions, + if (!NI_InitFilterIterator(input->nd, footprint->dimensions, filter_size, input->dimensions, origins, &fi)) goto exit; /* initialize input element iterator: */ @@ -639,8 +639,8 @@ if (!NI_InitPointIterator(output, &io)) goto exit; /* get data pointers an array size: */ - pi = NA_OFFSETDATA(input); - po = NA_OFFSETDATA(output); + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); size = 1; for(ll = 0; ll < input->nd; ll++) size *= input->dimensions[ll]; @@ -660,7 +660,7 @@ #if HAS_UINT64 CASE_RANK_POINT(pi, oo, filter_size, cvalue, UInt64, rank, buffer, tmp, border_flag_value); -#endif +#endif CASE_RANK_POINT(pi, oo, filter_size, cvalue, Int8, rank, buffer, tmp, border_flag_value); CASE_RANK_POINT(pi, oo, filter_size, cvalue, Int16, @@ -684,7 +684,7 @@ CASE_FILTER_OUT(po, tmp, UInt32); #if HAS_UINT64 CASE_FILTER_OUT(po, tmp, UInt64); -#endif +#endif CASE_FILTER_OUT(po, tmp, Int8); CASE_FILTER_OUT(po, tmp, Int16); CASE_FILTER_OUT(po, tmp, Int32); @@ -705,7 +705,7 @@ int NI_GenericFilter1D(PyArrayObject *input, int (*function)(double*, maybelong, double*, maybelong, void*), - void* data, long filter_size, int axis, PyArrayObject *output, + void* data, long filter_size, int axis, PyArrayObject *output, NI_ExtendMode mode, double cval, long origin) { int more; @@ -720,13 +720,13 @@ if (!NI_AllocateLineBuffer(input, axis, size1 + origin, size2 - origin, &lines, BUFFER_SIZE, &ibuffer)) goto exit; - if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, + if (!NI_AllocateLineBuffer(output, axis, 0, 0, &lines, BUFFER_SIZE, &obuffer)) goto exit; - if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, + if (!NI_InitLineBuffer(input, axis, size1 + origin, size2 - origin, lines, ibuffer, mode, cval, &iline_buffer)) goto exit; - if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, + if (!NI_InitLineBuffer(output, axis, 0, 0, lines, obuffer, mode, 0.0, &oline_buffer)) goto exit; length = input->nd > 0 ? input->dimensions[axis] : 1; @@ -741,11 +741,11 @@ double *iline = NI_GET_LINE(iline_buffer, ii); double *oline = NI_GET_LINE(oline_buffer, ii); if (!function(iline, length + size1 + size2, oline, length, data)) { - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_RuntimeError, - "unknown error in line processing function"); - goto exit; - } + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, + "unknown error in line processing function"); + goto exit; + } } /* copy lines from buffer to array: */ if (!NI_LineBufferToArray(&oline_buffer)) @@ -792,12 +792,12 @@ char *pi, *po; double *buffer = NULL; int ll; - + /* get the the footprint: */ fsize = 1; for(ll = 0; ll < footprint->nd; ll++) fsize *= footprint->dimensions[ll]; - pf = (Bool*)NA_OFFSETDATA(footprint); + pf = (Bool*)PyArray_DATA(footprint); for(jj = 0; jj < fsize; jj++) { if (pf[jj]) ++filter_size; @@ -807,7 +807,7 @@ mode, &offsets, &border_flag_value, NULL)) goto exit; /* initialize filter iterator: */ - if (!NI_InitFilterIterator(input->nd, footprint->dimensions, + if (!NI_InitFilterIterator(input->nd, footprint->dimensions, filter_size, input->dimensions, origins, &fi)) goto exit; /* initialize input element iterator: */ @@ -817,8 +817,8 @@ if (!NI_InitPointIterator(output, &io)) goto exit; /* get data pointers an array size: */ - pi = NA_OFFSETDATA(input); - po = NA_OFFSETDATA(output); + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); size = 1; for(ll = 0; ll < input->nd; ll++) size *= input->dimensions[ll]; @@ -844,7 +844,7 @@ #if HAS_UINT64 CASE_FILTER_POINT(pi, oo, filter_size, cvalue, UInt64, tmp, border_flag_value, function, data, buffer); -#endif +#endif CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Int8, tmp, border_flag_value, function, data, buffer); CASE_FILTER_POINT(pi, oo, filter_size, cvalue, Int16, @@ -868,7 +868,7 @@ CASE_FILTER_OUT(po, tmp, UInt32); #if HAS_UINT64 CASE_FILTER_OUT(po, tmp, UInt64); -#endif +#endif CASE_FILTER_OUT(po, tmp, Int8); CASE_FILTER_OUT(po, tmp, Int16); CASE_FILTER_OUT(po, tmp, Int32); @@ -886,5 +886,3 @@ if (buffer) free(buffer); return PyErr_Occurred() ? 0 : 1; } - - Modified: trunk/Lib/ndimage/src/ni_fourier.c =================================================================== --- trunk/Lib/ndimage/src/ni_fourier.c 2007-03-28 21:54:24 UTC (rev 2885) +++ trunk/Lib/ndimage/src/ni_fourier.c 2007-03-29 09:20:23 UTC (rev 2886) @@ -2,7 +2,7 @@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions - * are met: + * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. @@ -15,7 +15,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -26,7 +26,7 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "ni_support.h" @@ -135,14 +135,14 @@ w = x; if (x < 0) w = -x; - + if (w <= 5.0) { - z = x * x; + z = x * x; w = polevl(z, RP, 3) / p1evl(z, RQ, 8); w = w * x * (z - Z1) * (z - Z2); return w ; } - + w = 5.0 / x; z = w * w; p = polevl(z, PP, 6) / polevl(z, PQ, 6); @@ -159,20 +159,20 @@ #define CASE_FOURIER_OUT_RC(_po, _tmp, _type) \ case t ## _type: \ - (*(_type*)_po).r = tmp; \ - (*(_type*)_po).i = 0.0; \ + (*(_type*)_po).real = tmp; \ + (*(_type*)_po).imag = 0.0; \ break #define CASE_FOURIER_OUT_CC(_po, _tmp_r, _tmp_i, _type) \ case t ## _type: \ - (*(_type*)_po).r = _tmp_r; \ - (*(_type*)_po).i = _tmp_i; \ + (*(_type*)_po).real = _tmp_r; \ + (*(_type*)_po).imag = _tmp_i; \ break #define CASE_FOURIER_FILTER_RC(_pi, _tmp, _tmp_r, _tmp_i, _type) \ case t ## _type: \ - _tmp_r = (*(_type*)_pi).r * _tmp; \ - _tmp_i = (*(_type*)_pi).i * _tmp; \ + _tmp_r = (*(_type*)_pi).real * _tmp; \ + _tmp_i = (*(_type*)_pi).imag * _tmp; \ break; #define CASE_FOURIER_FILTER_RR(_pi, _tmp, _type) \ @@ -180,16 +180,16 @@ _tmp *= *(_type*)_pi; \ break; -int NI_FourierFilter(PyArrayObject *input, PyArrayObject* parameter_array, +int NI_FourierFilter(PyArrayObject *input, PyArrayObject* parameter_array, maybelong n, int axis, PyArrayObject* output, int filter_type) { NI_Iterator ii, io; char *pi, *po; double *parameters = NULL, **params = NULL; maybelong kk, hh, size; - Float64 *iparameters = NA_OFFSETDATA(parameter_array); + Float64 *iparameters = (void *)PyArray_DATA(parameter_array); int ll; - + /* precalculate the parameters: */ parameters = (double*)malloc(input->nd * sizeof(double)); if (!parameters) { @@ -200,7 +200,7 @@ /* along the direction of the real transform we must use the given length of that dimensons, unless a complex transform is assumed (n < 0): */ - int shape = kk == axis ? + int shape = kk == axis ? (n < 0 ? input->dimensions[kk] : n) : input->dimensions[kk]; switch (filter_type) { case _NI_GAUSSIAN: @@ -219,7 +219,7 @@ PyErr_NoMemory(); goto exit; } - for(kk = 0; kk < input->nd; kk++) + for(kk = 0; kk < input->nd; kk++) params[kk] = NULL; for(kk = 0; kk < input->nd; kk++) { if (input->dimensions[kk] > 1) { @@ -262,7 +262,7 @@ if (hh == axis && n >= 0) { double tmp = M_PI * parameters[hh] / n; for(kk = 1; kk < input->dimensions[hh]; kk++) - params[hh][kk] = tmp > 0.0 ? + params[hh][kk] = tmp > 0.0 ? sin(tmp * kk) / (tmp * kk) : 0.0; } else { double tmp = M_PI * parameters[hh] / input->dimensions[hh]; @@ -275,7 +275,7 @@ sin(tmp * kk) / (tmp * kk) : 0.0; } } - } + } break; case _NI_ELLIPSOID: /* calculate the tables of parameters: */ @@ -312,8 +312,8 @@ /* initialize output element iterator: */ if (!NI_InitPointIterator(output, &io)) goto exit; - pi = NA_OFFSETDATA(input); - po = NA_OFFSETDATA(output); + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); size = 1; for(ll = 0; ll < input->nd; ll++) size *= input->dimensions[ll]; @@ -363,14 +363,14 @@ input->descr->type_num == tComplex64) { double tmp_r = 0.0, tmp_i = 0.0; switch (input->descr->type_num) { - CASE_FOURIER_FILTER_RC(pi, tmp, tmp_r, tmp_i, Complex32); + /*CASE_FOURIER_FILTER_RC(pi, tmp, tmp_r, tmp_i, Complex32);*/ CASE_FOURIER_FILTER_RC(pi, tmp, tmp_r, tmp_i, Complex64); default: PyErr_SetString(PyExc_RuntimeError, "data type not supported"); goto exit; } switch (output->descr->type_num) { - CASE_FOURIER_OUT_CC(po, tmp_r, tmp_i, Complex32); + /*CASE_FOURIER_OUT_CC(po, tmp_r, tmp_i, Complex32);*/ CASE_FOURIER_OUT_CC(po, tmp_r, tmp_i, Complex64); default: PyErr_SetString(PyExc_RuntimeError, "data type not supported"); @@ -398,7 +398,7 @@ switch (output->descr->type_num) { CASE_FOURIER_OUT_RR(po, tmp, Float32); CASE_FOURIER_OUT_RR(po, tmp, Float64); - CASE_FOURIER_OUT_RC(po, tmp, Complex32); + /*CASE_FOURIER_OUT_RC(po, tmp, Complex32);*/ CASE_FOURIER_OUT_RC(po, tmp, Complex64); default: PyErr_SetString(PyExc_RuntimeError, "data type not supported"); @@ -407,7 +407,7 @@ } NI_ITERATOR_NEXT2(ii, io, pi, po); } - + exit: if (parameters) free(parameters); if (params) { @@ -425,22 +425,22 @@ _i = _tmp * _sint; \ break; -#define CASE_FOURIER_SHIFT_C(_pi, _r, _i, _cost, _sint, _type) \ -case t ## _type: \ - _r = (*(_type*)_pi).r * _cost - (*(_type*)_pi).i * _sint; \ - _i = (*(_type*)_pi).r * _sint + (*(_type*)_pi).i * _cost; \ +#define CASE_FOURIER_SHIFT_C(_pi, _r, _i, _cost, _sint, _type) \ +case t ## _type: \ + _r = (*(_type*)_pi).real * _cost - (*(_type*)_pi).imag * _sint; \ + _i = (*(_type*)_pi).real * _sint + (*(_type*)_pi).imag * _cost; \ break; -int NI_FourierShift(PyArrayObject *input, PyArrayObject* shift_array, +int NI_FourierShift(PyArrayObject *input, PyArrayObject* shift_array, maybelong n, int axis, PyArrayObject* output) { NI_Iterator ii, io; char *pi, *po; double *shifts = NULL, **params = NULL; maybelong kk, hh, size; - Float64 *ishifts = NA_OFFSETDATA(shift_array); + Float64 *ishifts = (void *)PyArray_DATA(shift_array); int ll; - + /* precalculate the shifts: */ shifts = (double*)malloc(input->nd * sizeof(double)); if (!shifts) { @@ -451,9 +451,9 @@ /* along the direction of the real transform we must use the given length of that dimensons, unless a complex transform is assumed (n < 0): */ - int shape = kk == axis ? + int shape = kk == axis ? (n < 0 ? input->dimensions[kk] : n) : input->dimensions[kk]; - shifts[kk] = -2.0 * M_PI * *ishifts++ / (double)shape; + shifts[kk] = -2.0 * M_PI * *ishifts++ / (double)shape; } /* allocate memory for tables: */ params = (double**) malloc(input->nd * sizeof(double*)); @@ -461,7 +461,7 @@ PyErr_NoMemory(); goto exit; } - for(kk = 0; kk < input->nd; kk++) + for(kk = 0; kk < input->nd; kk++) params[kk] = NULL; for(kk = 0; kk < input->nd; kk++) { if (input->dimensions[kk] > 1) { @@ -494,8 +494,8 @@ /* initialize output element iterator: */ if (!NI_InitPointIterator(output, &io)) goto exit; - pi = NA_OFFSETDATA(input); - po = NA_OFFSETDATA(output); + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); size = 1; for(ll = 0; ll < input->nd; ll++) size *= input->dimensions[ll]; @@ -521,14 +521,14 @@ CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Int64) CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Float32) CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Float64) - CASE_FOURIER_SHIFT_C(pi, r, i, cost, sint, Complex32) + /*CASE_FOURIER_SHIFT_C(pi, r, i, cost, sint, Complex32)*/ CASE_FOURIER_SHIFT_C(pi, r, i, cost, sint, Complex64) default: PyErr_SetString(PyExc_RuntimeError, "data type not supported"); goto exit; } switch (output->descr->type_num) { - CASE_FOURIER_OUT_CC(po, r, i, Complex32); + /*CASE_FOURIER_OUT_CC(po, r, i, Complex32);*/ CASE_FOURIER_OUT_CC(po, r, i, Complex64); default: PyErr_SetString(PyExc_RuntimeError, "data type not supported"); @@ -536,7 +536,7 @@ } NI_ITERATOR_NEXT2(ii, io, pi, po); } - + exit: if (shifts) free(shifts); if (params) { @@ -546,4 +546,3 @@ } return PyErr_Occurred() ? 0 : 1; } - Modified: trunk/Lib/ndimage/src/ni_interpolation.c =================================================================== --- trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-28 21:54:24 UTC (rev 2885) +++ trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-29 09:20:23 UTC (rev 2886) @@ -2,7 +2,7 @@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions - * are met: + * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. @@ -15,7 +15,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -26,7 +26,7 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "ni_support.h" @@ -36,7 +36,7 @@ /* calculate the B-spline interpolation coefficients for given x: */ static void -spline_coefficients(double x, int order, double *result) +spline_coefficients(double x, int order, double *result) { int hh; double y, start; @@ -66,21 +66,21 @@ break; case 3: if (y < 1.0) { - result[hh] = + result[hh] = (y * y * (y - 2.0) * 3.0 + 4.0) / 6.0; } else if (y < 2.0) { y = 2.0 - y; result[hh] = y * y * y / 6.0; } else { result[hh] = 0.0; - } + } break; case 4: if (y < 0.5) { y *= y; result[hh] = y * (y * 0.25 - 0.625) + 115.0 / 192.0; } else if (y < 1.5) { - result[hh] = y * (y * (y * (5.0 / 6.0 - y / 6.0) - 1.25) + + result[hh] = y * (y * (y * (5.0 / 6.0 - y / 6.0) - 1.25) + 5.0 / 24.0) + 55.0 / 96.0; } else if (y < 2.5) { y -= 2.5; @@ -93,10 +93,10 @@ case 5: if (y < 1.0) { double f = y * y; - result[hh] = + result[hh] = f * (f * (0.25 - y / 12.0) - 0.5) + 0.55; } else if (y < 2.0) { - result[hh] = y * (y * (y * (y * (y / 24.0 - 0.375) + result[hh] = y * (y * (y * (y * (y / 24.0 - 0.375) + 1.25) - 1.75) + 0.625) + 0.425; } else if (y < 3.0) { double f = 3.0 - y; @@ -112,7 +112,7 @@ /* map a coordinate outside the borders, according to the requested boundary condition: */ -static double +static double map_coordinate(double in, maybelong len, int mode) { if (in < 0) { @@ -136,7 +136,7 @@ in = in < -len ? in + sz2 : -in - 1; } break; - case NI_EXTEND_WRAP: + case NI_EXTEND_WRAP: if (len <= 1) { in = 0; } else { @@ -175,7 +175,7 @@ in = sz2 - in - 1; } break; - case NI_EXTEND_WRAP: + case NI_EXTEND_WRAP: if (len <= 1) { in = 0; } else { @@ -199,7 +199,7 @@ #define TOLERANCE 1e-15 /* one-dimensional spline filter: */ -int NI_SplineFilter1D(PyArrayObject *input, int order, int axis, +int NI_SplineFilter1D(PyArrayObject *input, int order, int axis, PyArrayObject *output) { int hh, npoles = 0, more; @@ -251,7 +251,7 @@ if (!NI_InitLineBuffer(output, axis, 0, 0, lines, buffer, NI_EXTEND_DEFAULT, 0.0, &oline_buffer)) goto exit; - + /* iterate over all the array lines: */ do { /* copy lines from array to buffer: */ @@ -265,36 +265,36 @@ if (len > 1) { for(ll = 0; ll < len; ll++) ln[ll] *= weight; - for(hh = 0; hh < npoles; hh++) { - double p = pole[hh]; + for(hh = 0; hh < npoles; hh++) { + double p = pole[hh]; int max = (int)ceil(log(TOLERANCE) / log(fabs(p))); - if (max < len) { - double zn = p; - double sum = ln[0]; - for(ll = 1; ll < max; ll++) { - sum += zn * ln[ll]; - zn *= p; - } - ln[0] = sum; - } else { - double zn = p; - double iz = 1.0 / p; - double z2n = pow(p, (double)(len - 1)); - double sum = ln[0] + z2n * ln[len - 1]; - z2n *= z2n * iz; - for(ll = 1; ll <= len - 2; ll++) { - sum += (zn + z2n) * ln[ll]; - zn *= p; - z2n *= iz; - } + if (max < len) { + double zn = p; + double sum = ln[0]; + for(ll = 1; ll < max; ll++) { + sum += zn * ln[ll]; + zn *= p; + } + ln[0] = sum; + } else { + double zn = p; + double iz = 1.0 / p; + double z2n = pow(p, (double)(len - 1)); + double sum = ln[0] + z2n * ln[len - 1]; + z2n *= z2n * iz; + for(ll = 1; ll <= len - 2; ll++) { + sum += (zn + z2n) * ln[ll]; + zn *= p; + z2n *= iz; + } ln[0] = sum / (1.0 - zn * zn); - } - for(ll = 1; ll < len; ll++) - ln[ll] += p * ln[ll - 1]; + } + for(ll = 1; ll < len; ll++) + ln[ll] += p * ln[ll - 1]; ln[len-1] = (p / (p * p - 1.0)) * (ln[len-1] + p * ln[len-2]); - for(ll = len - 2; ll >= 0; ll--) - ln[ll] = p * (ln[ll + 1] - ln[ll]); - } + for(ll = len - 2; ll >= 0; ll--) + ln[ll] = p * (ln[ll + 1] - ln[ll]); + } } } /* copy lines from buffer to array: */ @@ -306,7 +306,7 @@ if (buffer) free(buffer); return PyErr_Occurred() ? 0 : 1; } - + #define CASE_MAP_COORDINATES(_p, _coor, _rank, _stride, _type) \ case t ## _type: \ { \ @@ -321,7 +321,7 @@ #define CASE_INTERP_COEFF(_coeff, _pi, _idx, _type) \ case t ## _type: \ _coeff = *(_type*)(_pi + _idx); \ - break; + break; #define CASE_INTERP_OUT(_po, _t, _type) \ case t ## _type: \ @@ -344,8 +344,8 @@ *(_type*)_po = (_type)_t; \ break; -int -NI_GeometricTransform(PyArrayObject *input, int (*map)(maybelong*, double*, +int +NI_GeometricTransform(PyArrayObject *input, int (*map)(maybelong*, double*, int, int, void*), void* map_data, PyArrayObject* matrix_ar, PyArrayObject* shift_ar, PyArrayObject *coordinates, PyArrayObject *output, int order, int mode, double cval) @@ -440,7 +440,7 @@ for(jj = 0; jj < irank; jj++) ftmp[jj] = 0; kk = 0; - for(hh = 0; hh < filter_size; hh++) { + for(hh = 0; hh < filter_size; hh++) { for(jj = 0; jj < irank; jj++) fcoordinates[jj + hh * irank] = ftmp[jj]; foffsets[hh] = kk; @@ -497,7 +497,7 @@ CASE_MAP_COORDINATES(p, icoor, irank, cstride, Float32); CASE_MAP_COORDINATES(p, icoor, irank, cstride, Float64); default: - PyErr_SetString(PyExc_RuntimeError, + PyErr_SetString(PyExc_RuntimeError, "coordinate array data type not supported"); goto exit; } @@ -551,17 +551,17 @@ } } - if (!constant) { - maybelong *ff = fcoordinates; - for(hh = 0; hh < filter_size; hh++) { + if (!constant) { + maybelong *ff = fcoordinates; + for(hh = 0; hh < filter_size; hh++) { int idx = 0; - if (edge) { - for(ll = 0; ll < irank; ll++) { - if (edge_offsets[ll]) - idx += edge_offsets[ll][ff[ll]]; - else + if (edge) { + for(ll = 0; ll < irank; ll++) { + if (edge_offsets[ll]) + idx += edge_offsets[ll][ff[ll]]; + else idx += ff[ll] * istrides[ll]; - } + } } else { idx = foffsets[hh]; } @@ -570,36 +570,36 @@ ff += irank; } } - if (!constant) { - maybelong *ff = fcoordinates; + if (!constant) { + maybelong *ff = fcoordinates; t = 0.0; - for(hh = 0; hh < filter_size; hh++) { + for(hh = 0; hh < filter_size; hh++) { double coeff = 0.0; switch(input->descr->type_num) { - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Bool); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt8); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt16); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt32); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Bool); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt8); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt16); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt32); #if HAS_UINT64 - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt64); -#endif - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int8); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int16); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int32); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int64); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float32); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float64); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt64); +#endif + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int8); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int16); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int32); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int64); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float32); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float64); default: PyErr_SetString(PyExc_RuntimeError, "data type not supported"); goto exit; } /* calculate the interpolated value: */ for(ll = 0; ll < irank; ll++) - if (order > 0) + if (order > 0) coeff *= splvals[ll][ff[ll]]; - t += coeff; + t += coeff; ff += irank; - } + } } else { t = cval; } @@ -630,7 +630,7 @@ } exit: - if (edge_offsets) + if (edge_offsets) free(edge_offsets); if (data_offsets) { for(jj = 0; jj < irank; jj++) @@ -651,13 +651,13 @@ return PyErr_Occurred() ? 0 : 1; } -int NI_ZoomShift(PyArrayObject *input, PyArrayObject* zoom_ar, +int NI_ZoomShift(PyArrayObject *input, PyArrayObject* zoom_ar, PyArrayObject* shift_ar, PyArrayObject *output, int order, int mode, double cval) { char *po, *pi; maybelong **zeros = NULL, **offsets = NULL, ***edge_offsets = NULL; - maybelong ftmp[MAXDIM], *fcoordinates = NULL, *foffsets = NULL; + maybelong ftmp[MAXDIM], *fcoordinates = NULL, *foffsets = NULL; maybelong jj, hh, kk, filter_size, odimensions[MAXDIM]; maybelong idimensions[MAXDIM], istrides[MAXDIM], *idxs = NULL; maybelong size; @@ -666,7 +666,7 @@ Float64 *zooms = zoom_ar ? (Float64*)PyArray_DATA(zoom_ar) : NULL; Float64 *shifts = shift_ar ? (Float64*)PyArray_DATA(shift_ar) : NULL; int rank = 0, qq; - + for(kk = 0; kk < input->nd; kk++) { idimensions[kk] = input->dimensions[kk]; istrides[kk] = input->strides[kk]; @@ -688,10 +688,10 @@ if(!zeros[jj]) { PyErr_NoMemory(); goto exit; - } + } } } - + /* store offsets, along each axis: */ offsets = (maybelong**)malloc(rank * sizeof(maybelong*)); /* store spline coefficients, along each axis: */ @@ -714,7 +714,7 @@ if (!offsets[jj] || !splvals[jj] || !edge_offsets[jj]) { PyErr_NoMemory(); goto exit; - } + } for(hh = 0; hh < odimensions[jj]; hh++) { splvals[jj][hh] = NULL; edge_offsets[jj][hh] = NULL; @@ -775,9 +775,9 @@ if (!splvals[jj][kk]) { PyErr_NoMemory(); goto exit; - } + } spline_coefficients(cc, order, splvals[jj][kk]); - } + } } else { zeros[jj][kk] = 1; } @@ -798,7 +798,7 @@ pi = (void *)PyArray_DATA(input); po = (void *)PyArray_DATA(output); - + /* store all coordinates and offsets with filter: */ fcoordinates = (maybelong*)malloc(rank * filter_size * sizeof(maybelong)); foffsets = (maybelong*)malloc(filter_size * sizeof(maybelong)); @@ -810,7 +810,7 @@ for(jj = 0; jj < rank; jj++) ftmp[jj] = 0; kk = 0; - for(hh = 0; hh < filter_size; hh++) { + for(hh = 0; hh < filter_size; hh++) { for(jj = 0; jj < rank; jj++) fcoordinates[jj + hh * rank] = ftmp[jj]; foffsets[hh] = kk; @@ -828,31 +828,31 @@ size = 1; for(qq = 0; qq < output->nd; qq++) size *= output->dimensions[qq]; - for(kk = 0; kk < size; kk++) { - double t = 0.0; + for(kk = 0; kk < size; kk++) { + double t = 0.0; int edge = 0, oo = 0, zero = 0; - - for(hh = 0; hh < rank; hh++) { - if (zeros && zeros[hh][io.coordinates[hh]]) { + + for(hh = 0; hh < rank; hh++) { + if (zeros && zeros[hh][io.coordinates[hh]]) { /* we use constant border condition */ - zero = 1; - break; - } - oo += offsets[hh][io.coordinates[hh]]; - if (edge_offsets[hh][io.coordinates[hh]]) - edge = 1; - } - - if (!zero) { + zero = 1; + break; + } + oo += offsets[hh][io.coordinates[hh]]; + if (edge_offsets[hh][io.coordinates[hh]]) + edge = 1; + } + + if (!zero) { maybelong *ff = fcoordinates; for(hh = 0; hh < filter_size; hh++) { - int idx = 0; + int idx = 0; if (edge) { /* use precalculated edge offsets: */ - for(jj = 0; jj < rank; jj++) { - if (edge_offsets[jj][io.coordinates[jj]]) - idx += edge_offsets[jj][io.coordinates[jj]][ff[jj]]; - else + for(jj = 0; jj < rank; jj++) { + if (edge_offsets[jj][io.coordinates[jj]]) + idx += edge_offsets[jj][io.coordinates[jj]][ff[jj]]; + else idx += ff[jj] * istrides[jj]; } idx += oo; @@ -864,39 +864,39 @@ ff += rank; } } - if (!zero) { + if (!zero) { maybelong *ff = fcoordinates; t = 0.0; for(hh = 0; hh < filter_size; hh++) { double coeff = 0.0; switch(input->descr->type_num) { - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Bool); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt8); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt16); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt32); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Bool); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt8); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt16); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt32); #if HAS_UINT64 - CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt64); -#endif - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int8); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int16); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int32); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int64); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float32); - CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float64); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], UInt64); +#endif + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int8); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int16); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int32); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Int64); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float32); + CASE_INTERP_COEFF(coeff, pi, idxs[hh], Float64); default: PyErr_SetString(PyExc_RuntimeError, "data type not supported"); goto exit; } /* calculate interpolated value: */ - for(jj = 0; jj < rank; jj++) - if (order > 0) - coeff *= splvals[jj][io.coordinates[jj]][ff[jj]]; - t += coeff; + for(jj = 0; jj < rank; jj++) + if (order > 0) + coeff *= splvals[jj][io.coordinates[jj]][ff[jj]]; + t += coeff; ff += rank; - } + } } else { t = cval; - } + } /* store output: */ switch (output->descr->type_num) { CASE_INTERP_OUT(po, t, Bool); @@ -917,7 +917,7 @@ goto exit; } NI_ITERATOR_NEXT(io, po); - } + } exit: if (zeros) { Modified: trunk/Lib/ndimage/src/ni_interpolation.h =================================================================== --- trunk/Lib/ndimage/src/ni_interpolation.h 2007-03-28 21:54:24 UTC (rev 2885) +++ trunk/Lib/ndimage/src/ni_interpolation.h 2007-03-29 09:20:23 UTC (rev 2886) @@ -2,7 +2,7 @@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions - * are met: + * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. @@ -15,7 +15,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -26,7 +26,7 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef NI_INTERPOLATION_H Modified: trunk/Lib/ndimage/src/ni_measure.c =================================================================== --- trunk/Lib/ndimage/src/ni_measure.c 2007-03-28 21:54:24 UTC (rev 2885) +++ trunk/Lib/ndimage/src/ni_measure.c 2007-03-29 09:20:23 UTC (rev 2886) @@ -2,7 +2,7 @@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions - * are met: + * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. @@ -15,7 +15,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -26,7 +26,7 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "ni_support.h" @@ -63,14 +63,14 @@ ssize = 1; for(kk = 0; kk < strct->nd; kk++) ssize *= strct->dimensions[kk]; - /* we only use the first half of the structure data, so we make a + /* we only use the first half of the structure data, so we make a temporary structure for use with the filter functions: */ footprint = (Bool*)malloc(ssize * sizeof(Bool)); if (!footprint) { PyErr_NoMemory(); goto exit; } - ps = (Bool*)NA_OFFSETDATA(strct); + ps = (Bool*)PyArray_DATA(strct); filter_size = 0; for(jj = 0; jj < ssize / 2; jj++) { footprint[jj] = ps[jj]; @@ -80,8 +80,8 @@ for(jj = ssize / 2; jj < ssize; jj++) footprint[jj] = 0; /* get data and size */ - pi = NA_OFFSETDATA(input); - po = NA_OFFSETDATA(output); + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); size = 1; for(kk = 0; kk < output->nd; kk++) size *= output->dimensions[kk]; @@ -119,12 +119,12 @@ NI_EXTEND_CONSTANT, &offsets, &mask_value, NULL)) goto exit; /* initialize filter iterator: */ - if (!NI_InitFilterIterator(input->nd, strct->dimensions, filter_size, + if (!NI_InitFilterIterator(input->nd, strct->dimensions, filter_size, input->dimensions, NULL, &fi)) goto exit; /* reset output iterator: */ NI_ITERATOR_RESET(io); - po = NA_OFFSETDATA(output); + po = (void *)PyArray_DATA(output); /* iterator over the elements: */ oo = offsets; for(jj = 0; jj < size; jj++) { @@ -185,7 +185,7 @@ Int32 idx1 = pairs->index1 - 1; Int32 idx2 = pairs->index2 - 1; if (index_map[idx2] == idx1 || index_map[idx2] == idx2) { - /* if this pair was already processed, or if idx2 was not + /* if this pair was already processed, or if idx2 was not mapped yet, we delete this pair and map idx2 to idx1: */ _index_pair *tp = pairs; pairs = tp->next; @@ -228,7 +228,7 @@ if (index_map) { *max_label = 0; NI_ITERATOR_RESET(io); - po = NA_OFFSETDATA(output); + po = (void *)PyArray_DATA(output); for(jj = 0; jj < size; jj++) { Int32 p = *(Int32*)po; if (p > 0 ) @@ -291,7 +291,7 @@ char *pi; /* get input data, size and iterator: */ - pi = NA_OFFSETDATA(input); + pi = (void *)PyArray_DATA(input); size = 1; for(kk = 0; kk < input->nd; kk++) size *= input->dimensions[kk]; @@ -307,25 +307,25 @@ /* iterate over all points: */ for(jj = 0 ; jj < size; jj++) { switch (input->descr->type_num) { - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, max_label, ii, Bool); - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, max_label, ii, UInt8); - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, max_label, ii, UInt16); - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, max_label, ii, UInt32); #if HAS_UINT64 - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, max_label, ii, UInt64); #endif - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, max_label, ii, Int8); - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, max_label, ii, Int16); - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, max_label, ii, Int32); - CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, + CASE_FIND_OBJECT_POINT(pi, regions, input->nd, input->dimensions, max_label, ii, Int64); break; default: @@ -511,8 +511,8 @@ } #endif -int NI_Statistics(PyArrayObject *input, PyArrayObject *labels, - maybelong min_label, maybelong max_label, maybelong *indices, +int NI_Statistics(PyArrayObject *input, PyArrayObject *labels, + maybelong min_label, maybelong max_label, maybelong *indices, maybelong n_results, double *sum, maybelong *total, double *variance, double *minimum, double *maximum, maybelong* min_pos, maybelong* max_pos) { @@ -520,16 +520,16 @@ NI_Iterator ii, mi; maybelong jj, size, idx = 0, label = 1, doit = 1; int qq; - + /* input iterator: */ if (!NI_InitPointIterator(input, &ii)) return 0; /* input data: */ - pi = NA_OFFSETDATA(input); + pi = (void *)PyArray_DATA(input); if (labels) { if (!NI_InitPointIterator(labels, &mi)) return 0; - pm = NA_OFFSETDATA(labels); + pm = (void *)PyArray_DATA(labels); } /* input size: */ size = 1; @@ -560,7 +560,7 @@ doit = idx >= 0; } else { doit = 0; - } + } } else { doit = label != 0; } @@ -610,11 +610,11 @@ if (do_var) { /* reset input iterator: */ NI_ITERATOR_RESET(ii); - pi = NA_OFFSETDATA(input); + pi = (void *)PyArray_DATA(input); if (labels) { /* reset label iterator: */ NI_ITERATOR_RESET(mi); - pm = NA_OFFSETDATA(labels); + pm = (void *)PyArray_DATA(labels); } for(jj = 0; jj < size; jj++) { NI_GET_LABEL(pm, label, labels->descr->type_num); @@ -624,7 +624,7 @@ doit = idx >= 0; } else { doit = 0; - } + } } else { doit = label != 0; } @@ -641,7 +641,7 @@ } } for(jj = 0; jj < n_results; jj++) - variance[jj] = (total[jj] > 1 ? + variance[jj] = (total[jj] > 1 ? variance[jj] / (total[jj] - 1) : 0.0); } } @@ -649,8 +649,8 @@ } -int NI_CenterOfMass(PyArrayObject *input, PyArrayObject *labels, - maybelong min_label, maybelong max_label, maybelong *indices, +int NI_CenterOfMass(PyArrayObject *input, PyArrayObject *labels, + maybelong min_label, maybelong max_label, maybelong *indices, maybelong n_results, double *center_of_mass) { char *pi = NULL, *pm = NULL; @@ -663,11 +663,11 @@ if (!NI_InitPointIterator(input, &ii)) goto exit; /* input data: */ - pi = NA_OFFSETDATA(input); + pi = (void *)PyArray_DATA(input); if (labels) { if (!NI_InitPointIterator(labels, &mi)) goto exit; - pm = NA_OFFSETDATA(labels); + pm = (void *)PyArray_DATA(labels); } /* input size: */ size = 1; @@ -692,7 +692,7 @@ doit = idx >= 0; } else { doit = 0; - } + } } else { doit = label != 0; } @@ -719,8 +719,8 @@ } -int NI_Histogram(PyArrayObject *input, PyArrayObject *labels, - maybelong min_label, maybelong max_label, maybelong *indices, +int NI_Histogram(PyArrayObject *input, PyArrayObject *labels, + maybelong min_label, maybelong max_label, maybelong *indices, maybelong n_results, PyArrayObject **histograms, double min, double max, maybelong nbins) { @@ -730,16 +730,16 @@ Int32 **ph = NULL; double bsize; int qq; - + /* input iterator: */ if (!NI_InitPointIterator(input, &ii)) goto exit; /* input data: */ - pi = NA_OFFSETDATA(input); + pi = (void *)PyArray_DATA(input); if (labels) { if (!NI_InitPointIterator(labels, &mi)) goto exit; - pm = NA_OFFSETDATA(labels); + pm = (void *)PyArray_DATA(labels); } ph = (Int32**)malloc(n_results * sizeof(Int32*)); if (!ph) { @@ -747,9 +747,9 @@ goto exit; } for(jj = 0; jj < n_results; jj++) { - ph[jj] = (Int32*)NA_OFFSETDATA(histograms[jj]); - for(kk = 0; kk < nbins; kk++) - ph[jj][kk] = 0; + ph[jj] = (Int32*)PyArray_DATA(histograms[jj]); + for(kk = 0; kk < nbins; kk++) + ph[jj][kk] = 0; } bsize = (max - min) / (double)nbins; /* input size: */ @@ -765,7 +765,7 @@ doit = idx >= 0; } else { doit = 0; - } + } } else { doit = label != 0; } @@ -821,7 +821,7 @@ case t ## _type: \ *((_type*)_pl) = _label; \ break - + #define CASE_WINDEX1(_v_index, _p_index, _strides, _istrides, _irank, \ _icont, _p_idx, _v_idx, _pi, _vval, _pval, _type) \ case t ## _type: \ @@ -860,7 +860,7 @@ DONE_TYPE done; } NI_WatershedElement; -int NI_WatershedIFT(PyArrayObject* input, PyArrayObject* markers, +int NI_WatershedIFT(PyArrayObject* input, PyArrayObject* markers, PyArrayObject* strct, PyArrayObject* output) { char *pl, *pm, *pi; @@ -872,7 +872,7 @@ NI_WatershedElement *temp = NULL, **first = NULL, **last = NULL; Bool *ps = NULL; NI_Iterator mi, ii, li; - + i_contiguous = PyArray_ISCONTIGUOUS(input); o_contiguous = PyArray_ISCONTIGUOUS(output); ssize = 1; @@ -891,7 +891,7 @@ PyErr_NoMemory(); goto exit; } - pi = NA_OFFSETDATA(input); + pi = (void *)PyArray_DATA(input); if (!NI_InitPointIterator(input, &ii)) goto exit; /* Initialization and find the maximum of the input. */ @@ -911,11 +911,11 @@ maxval = ival; NI_ITERATOR_NEXT(ii, pi); } - pi = NA_OFFSETDATA(input); + pi = (void *)PyArray_DATA(input); /* Allocate and initialize the storage for the queue. */ - first = (NI_WatershedElement**)malloc((maxval + 1) * + first = (NI_WatershedElement**)malloc((maxval + 1) * sizeof(NI_WatershedElement*)); - last = (NI_WatershedElement**)malloc((maxval + 1) * + last = (NI_WatershedElement**)malloc((maxval + 1) * sizeof(NI_WatershedElement*)); if (!first || !last) { PyErr_NoMemory(); @@ -929,15 +929,15 @@ goto exit; if (!NI_InitPointIterator(output, &li)) goto exit; - pm = NA_OFFSETDATA(markers); - pl = NA_OFFSETDATA(output); + pm = (void *)PyArray_DATA(markers); + pl = (void *)PyArray_DATA(output); /* initialize all nodes */ for(ll = 0; ll < input->nd; ll++) coordinates[ll] = 0; for(jj = 0; jj < size; jj++) { /* get marker */ int label = 0; - switch(markers->descr->type_num) { + switch(markers->descr->type_num) { CASE_GET_LABEL(label, pm, UInt8); CASE_GET_LABEL(label, pm, UInt16); CASE_GET_LABEL(label, pm, UInt32); @@ -1001,15 +1001,15 @@ } for(ll = input->nd - 1; ll >= 0; ll--) if (coordinates[ll] < input->dimensions[ll] - 1) { - coordinates[ll]++; - break; - } else { - coordinates[ll] = 0; - } + coordinates[ll]++; + break; + } else { + coordinates[ll] = 0; + } } - - pl = NA_OFFSETDATA(output); - ps = (Bool*)NA_OFFSETDATA(strct); + + pl = (void *)PyArray_DATA(output); + ps = (Bool*)PyArray_DATA(strct); nneigh = 0; for (kk = 0; kk < ssize; kk++) if (ps[kk] && kk != (ssize / 2)) @@ -1037,11 +1037,11 @@ } for(ll = input->nd - 1; ll >= 0; ll--) if (coordinates[ll] < 1) { - coordinates[ll]++; - break; - } else { - coordinates[ll] = -1; - } + coordinates[ll]++; + break; + } else { + coordinates[ll] = -1; + } } /* Propagation phase: */ for(jj = 0; jj <= maxval; jj++) { @@ -1076,11 +1076,11 @@ /* If the neighbor was not processed yet: */ int max, pval, vval, wvp, pcost, label, p_idx, v_idx; switch(input->descr->type_num) { - CASE_WINDEX1(v_index, p_index, strides, input->strides, - input->nd, i_contiguous, p_idx, v_idx, pi, + CASE_WINDEX1(v_index, p_index, strides, input->strides, + input->nd, i_contiguous, p_idx, v_idx, pi, vval, pval, UInt8); - CASE_WINDEX1(v_index, p_index, strides, input->strides, - input->nd, i_contiguous, p_idx, v_idx, pi, + CASE_WINDEX1(v_index, p_index, strides, input->strides, + input->nd, i_contiguous, p_idx, v_idx, pi, vval, pval, UInt16); default: PyErr_SetString(PyExc_RuntimeError, @@ -1091,7 +1091,7 @@ wvp = pval - vval; if (wvp < 0) wvp = -wvp; - /* Find the maximum of this cost and the current + /* Find the maximum of this cost and the current element cost: */ pcost = p->cost; max = v->cost > wvp ? v->cost : wvp; @@ -1157,7 +1157,7 @@ last[pcost] = prev; if (prev) prev->next = next; - if (next) + if (next) next->prev = prev; } /* Insert the neighbor in the appropiate queue: */ Modified: trunk/Lib/ndimage/src/ni_morphology.c =================================================================== --- trunk/Lib/ndimage/src/ni_morphology.c 2007-03-28 21:54:24 UTC (rev 2885) +++ trunk/Lib/ndimage/src/ni_morphology.c 2007-03-29 09:20:23 UTC (rev 2886) @@ -2,7 +2,7 @@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions - * are met: + * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. @@ -15,7 +15,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -26,7 +26,7 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "ni_support.h" @@ -41,7 +41,7 @@ #define CASE_GET_MASK(_msk_value, _pm, _type) \ case t ## _type: \ _msk_value = *(_type*)_pm ? 1 : 0; \ - break + break #define CASE_OUTPUT(_po, _out, _type) \ case t ## _type: \ @@ -84,30 +84,30 @@ } \ break -int NI_BinaryErosion(PyArrayObject* input, PyArrayObject* strct, +int NI_BinaryErosion(PyArrayObject* input, PyArrayObject* strct, PyArrayObject* mask, PyArrayObject* output, int bdr_value, - maybelong *origins, int invert, int center_is_true, int* changed, + maybelong *origins, int invert, int center_is_true, int* changed, NI_CoordinateList **coordinate_list) { maybelong struct_size = 0, *offsets = NULL, size, *oo, jj; maybelong ssize, block_size = 0, *current = NULL, border_flag_value; - int kk, true, false, msk_value; + int kk, true, false, msk_value; NI_Iterator ii, io, mi; NI_FilterIterator fi; Bool *ps, out = 0; char *pi, *po, *pm = NULL; NI_CoordinateBlock *block = NULL; - ps = (Bool*)NA_OFFSETDATA(strct); + ps = (Bool*)PyArray_DATA(strct); ssize = 1; for(kk = 0; kk < strct->nd; kk++) ssize *= strct->dimensions[kk]; - for(jj = 0; jj < ssize; jj++) + for(jj = 0; jj < ssize; jj++) if (ps[jj]) ++struct_size; if (mask) { if (!NI_InitPointIterator(mask, &mi)) return 0; - pm = NA_OFFSETDATA(mask); + pm = (void *)PyArray_DATA(mask); } /* calculate the filter offsets: */ if (!NI_InitFilterOffsets(input, ps, strct->dimensions, origins, @@ -123,10 +123,10 @@ if (!NI_InitFilterIterator(input->nd, strct->dimensions, struct_size, input->dimensions, origins, &fi)) goto exit; - + /* get data pointers an size: */ - pi = NA_OFFSETDATA(input); - po = NA_OFFSETDATA(output); + pi = (void *)PyArray_DATA(input); + po = (void *)PyArray_DATA(output); size = 1; for(kk = 0; kk < input->nd; kk++) size *= input->dimensions[kk]; @@ -155,8 +155,8 @@ msk_value = 1; for(jj = 0; jj < size; jj++) { int pchange = 0; - if (mask) { - switch(mask->descr->type_num) { + if (mask) { + switch(mask->descr->type_num) { CASE_GET_MASK(msk_value, pm, Bool); CASE_GET_MASK(msk_value, pm, UInt8); CASE_GET_MASK(msk_value, pm, UInt16); @@ -170,10 +170,10 @@ CASE_GET_MASK(msk_value, pm, Int64); CASE_GET_MASK(msk_value, pm, Float32); CASE_GET_MASK(msk_value, pm, Float64); - default: - PyErr_SetString(PyExc_RuntimeError, "data type not supported"); - return 0; - } + default: + PyErr_SetString(PyExc_RuntimeError, "data type not supported"); + return 0; + } } switch (input->descr->type_num) { CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Bool, msk_value, @@ -182,14 +182,14 @@ CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt8, msk_value, bdr_value, border_flag_value, center_is_true, true, false, pchange); - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt16, msk_value, - bdr_value, border_flag_value, center_is_true, + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt16, msk_value, + bdr_value, border_flag_value, center_is_true, true, false, pchange); CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt32, msk_value, bdr_value, border_flag_value, center_is_true, true, false, pchange); #if HAS_UINT64 - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt64, msk_value, + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, UInt64, msk_value, bdr_value, border_flag_value, center_is_true, true, false, pchange); #endif @@ -205,7 +205,7 @@ CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Int64, msk_value, bdr_value, border_flag_value, center_is_true, true, false, pchange); - CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Float32, msk_value, + CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Float32, msk_value, bdr_value, border_flag_value, center_is_true, true, false, pchange); CASE_NI_ERODE_POINT(pi, out, oo, struct_size, Float64, msk_value, @@ -253,7 +253,7 @@ } exit: - if (offsets) + if (offsets) free(offsets); if (PyErr_Occurred()) { if (coordinate_list) { @@ -310,11 +310,11 @@ NI_CoordinateBlock *block1 = NULL, *block2 = NULL; NI_CoordinateList *list1 = NULL, *list2 = NULL; - ps = (Bool*)NA_OFFSETDATA(strct); + ps = (Bool*)PyArray_DATA(strct); ssize = 1; for(kk = 0; kk < strct->nd; kk++) ssize *= strct->dimensions[kk]; - for(jj = 0; jj < ssize; jj++) + for(jj = 0; jj < ssize; jj++) if (ps[jj]) ++struct_size; /* calculate the filter offsets: */ @@ -322,22 +322,22 @@ NI_EXTEND_CONSTANT, &offsets, &border_flag_value, &coordinate_offsets)) goto exit; - + /* initialize input element iterator: */ if (!NI_InitPointIterator(array, &ii)) goto exit; /* initialize filter iterator: */ - if (!NI_InitFilterIterator(array->nd, strct->dimensions, struct_size, + if (!NI_InitFilterIterator(array->nd, strct->dimensions, struct_size, array->dimensions, origins, &fi)) goto exit; if (!NI_InitFilterIterator(array->nd, strct->dimensions, struct_size * array->nd, array->dimensions, origins, &ci)) goto exit; - + /* get data pointers and size: */ - ibase = pi = NA_OFFSETDATA(array); + ibase = pi = (void *)PyArray_DATA(array); if (invert) { true = 0; @@ -351,7 +351,7 @@ /* iterator, data pointer and type of mask array: */ if (!NI_InitPointIterator(mask, &mi)) return 0; - pm = NA_OFFSETDATA(mask); + pm = (void *)PyArray_DATA(mask); size = 1; for(kk = 0; kk < array->nd; kk++) @@ -364,12 +364,12 @@ *(Int8*)pm = (Int8)*(Bool*)pi; *(Bool*)pi = false; } - NI_ITERATOR_NEXT2(ii, mi, pi, pm) + NI_ITERATOR_NEXT2(ii, mi, pi, pm) } NI_ITERATOR_RESET(ii) - pi = NA_OFFSETDATA(array); + pi = (void *)PyArray_DATA(array); } - + list1 = NI_InitCoordinateList((*iclist)->block_size, (*iclist)->rank); list2 = NI_InitCoordinateList((*iclist)->block_size, (*iclist)->rank); if (!list1 || !list2) @@ -388,61 +388,61 @@ block2 = NULL; current_coordinates1 = block1->coordinates; current = 0; - ++jj; - mklist = niter <= 0 || jj < niter; + ++jj; + mklist = niter <= 0 || jj < niter; } else { break; - } + } } NI_ITERATOR_GOTO(ii, current_coordinates1, ibase, pi); NI_FILTER_GOTO(fi, ii, 0, oo); switch (array->descr->type_num) { CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, border_flag_value, true, false, Bool, mklist); CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, border_flag_value, true, false, UInt8, mklist); CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, border_flag_value, true, false, UInt16, mklist); CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, border_flag_value, true, false, UInt32, mklist); #if HAS_UINT64 CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, border_flag_value, true, false, UInt64, mklist); #endif CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, border_flag_value, true, false, Int8, mklist); CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, border_flag_value, true, false, Int16, mklist); CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, border_flag_value, true, false, Int32, mklist); CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, border_flag_value, true, false, Int64, mklist); CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, border_flag_value, true, false, Float32, mklist); CASE_ERODE_POINT2(struct_size, offsets, coordinate_offsets, pi, - oo, array->nd, list1, list2, current_coordinates1, - current_coordinates2, block1, block2, + oo, array->nd, list1, list2, current_coordinates1, + current_coordinates2, block1, block2, border_flag_value, true, false, Float64, mklist); default: PyErr_SetString(PyExc_RuntimeError, "data type not supported"); @@ -460,22 +460,22 @@ current_coordinates1 += array->nd; } } - + if (mask) { NI_ITERATOR_RESET(ii) NI_ITERATOR_RESET(mi) - pi = NA_OFFSETDATA(array); - pm = NA_OFFSETDATA(mask); + pi = (void *)PyArray_DATA(array); + pm = (void *)PyArray_DATA(mask); for(jj = 0; jj < size; jj++) { int value = *(Int8*)pm; if (value >= 0) *(Bool*)pi = value; - NI_ITERATOR_NEXT2(ii, mi, pi, pm) + NI_ITERATOR_NEXT2(ii, mi, pi, pm) } } exit: - if (offsets) + if (offsets) free(offsets); if (coordinate_offsets) free(coordinate_offsets); @@ -501,8 +501,8 @@ } NI_BorderElement; int NI_DistanceTransformBruteForce(PyArrayObject* input, int metric, - PyArrayObject *sampling_arr, - PyArrayObject* distances, + PyArrayObject *sampling_arr, + PyArrayObject* distances, PyArrayObject* features) { maybelong size, jj, min_index = 0; @@ -510,17 +510,17 @@ NI_BorderElement *border_elements = NULL, *temp; NI_Iterator ii, di, fi; char *pi, *pd = NULL, *pf = NULL; - Float64 *sampling = sampling_arr ? NA_OFFSETDATA(sampling_arr) : NULL; - + Float64 *sampling = sampling_arr ? (void *)PyArray_DATA(sampling_arr) : NULL; + /* check the output arrays: */ if (distances) { - pd = NA_OFFSETDATA(distances); + pd = (void *)PyArray_DATA(distances); if (!NI_InitPointIterator(distances, &di)) goto exit; } if (features) { - pf = NA_OFFSETDATA(features); + pf = (void *)PyArray_DATA(features); if (!NI_InitPointIterator(features, &fi)) goto exit; } @@ -528,11 +528,11 @@ size = 1; for(kk = 0; kk < input->nd; kk++) size *= input->dimensions[kk]; - pi = NA_OFFSETDATA(input); + pi = (void *)PyArray_DATA(input); if (!NI_InitPointIterator(input, &ii)) goto exit; - + for(jj = 0; jj < size; jj++) { if (*(Int8*)pi < 0) { temp = (NI_BorderElement*)malloc(sizeof(NI_BorderElement)); @@ -545,13 +545,13 @@ temp->index = jj; temp->coordinates = (maybelong*)malloc(input->nd * sizeof(maybelong)); for(kk = 0; kk < input->nd; kk++) - temp->coordinates[kk] = ii.coordinates[kk]; + temp->coordinates[kk] = ii.coordinates[kk]; } NI_ITERATOR_NEXT(ii, pi); } NI_ITERATOR_RESET(ii); - pi = NA_OFFSETDATA(input); + pi = (void *)PyArray_DATA(input); switch(metric) { case NI_DISTANCE_EUCLIDIAN: @@ -574,12 +574,12 @@ } temp = temp->next; } - if (distances) + if (distances) *(Float64*)pd = sqrt(distance); if (features) *(Int32*)pf = min_index; } else { - if (distances) + if (distances) *(Float64*)pd = 0.0; if (features) *(Int32*)pf = jj; @@ -620,12 +620,12 @@ } temp = temp->next; } - if (distances) + if (distances) *(UInt32*)pd = distance; if (features) *(Int32*)pf = min_index; } else { - if (distances) + if (distances) *(UInt32*)pd = 0; if (features) *(Int32*)pf = jj; @@ -659,7 +659,7 @@ int NI_DistanceTransformOnePass(PyArrayObject *strct, PyArrayObject* distances, PyArrayObject *features) { - int kk; + int kk; maybelong jj, ii, ssize, size, filter_size, mask_value, *oo; maybelong *foffsets = NULL, *foo = NULL, *offsets = NULL; Bool *ps, *pf = NULL, *footprint = NULL; @@ -671,14 +671,14 @@ for(kk = 0; kk < strct->nd; kk++) ssize *= strct->dimensions[kk]; - /* we only use the first half of the structure data, so we make a + /* we only use the first half of the structure data, so we make a temporary structure for use with the filter functions: */ footprint = (Bool*)malloc(ssize * sizeof(Bool)); if (!footprint) { PyErr_NoMemory(); goto exit; } - ps = (Bool*)NA_OFFSETDATA(strct); + ps = (Bool*)PyArray_DATA(strct); filter_size = 0; for(jj = 0; jj < ssize / 2; jj++) { footprint[jj] = ps[jj]; @@ -688,25 +688,25 @@ for(jj = ssize / 2; jj < ssize; jj++) footprint[jj] = 0; /* get data and size */ - pd = NA_OFFSETDATA(distances); + pd = (void *)PyArray_DATA(distances); size = 1; for(kk = 0; kk < distances->nd; kk++) size *= distances->dimensions[kk]; if (!NI_InitPointIterator(distances, &di)) goto exit; /* calculate the filter offsets: */ - if (!NI_InitFilterOffsets(distances, footprint, strct->dimensions, NULL, + if (!NI_InitFilterOffsets(distances, footprint, strct->dimensions, NULL, NI_EXTEND_CONSTANT, &offsets, &mask_value, NULL)) goto exit; /* initialize filter iterator: */ - if (!NI_InitFilterIterator(distances->nd, strct->dimensions, + if (!NI_InitFilterIterator(distances->nd, strct->dimensions, filter_size, distances->dimensions, NULL, &si)) goto exit; - + if (features) { maybelong dummy; /* initialize point iterator: */ - pf = NA_OFFSETDATA(features); + pf = (void *)PyArray_DATA(features); if (!NI_InitPointIterator(features, &fi)) goto exit; /* calculate the filter offsets: */ @@ -714,7 +714,7 @@ NULL, NI_EXTEND_CONSTANT, &foffsets, &dummy, NULL)) goto exit; /* initialize filter iterator: */ - if (!NI_InitFilterIterator(distances->nd, strct->dimensions, + if (!NI_InitFilterIterator(distances->nd, strct->dimensions, filter_size, distances->dimensions, NULL, &ti)) goto exit; } @@ -750,7 +750,7 @@ } NI_FILTER_NEXT(si, di, oo, pd); } - + exit: if (offsets) free(offsets); if (foffsets) free(foffsets); @@ -760,12 +760,12 @@ } static void _VoronoiFT(char *pf, maybelong len, maybelong *coor, int rank, - int d, maybelong stride, maybelong cstride, + int d, maybelong stride, maybelong cstride, maybelong **f, maybelong *g, Float64 *sampling) { maybelong l = -1, ii, maxl, idx1, idx2; int jj; - + for(ii = 0; ii < len; ii++) for(jj = 0; jj < rank; jj++) f[ii][jj] = *(Int32*)(pf + ii * stride + cstride * jj); @@ -847,9 +847,9 @@ /* Recursive feature transform */ -static void _ComputeFT(char *pi, char *pf, maybelong *ishape, +static void _ComputeFT(char *pi, char *pf, maybelong *ishape, maybelong *istrides, maybelong *fstrides, int rank, - int d, maybelong *coor, maybelong **f, maybelong *g, + int d, maybelong *coor, maybelong **f, maybelong *g, PyArrayObject *features, Float64 *sampling) { int kk; @@ -918,10 +918,10 @@ maybelong coor[NI_MAXDIM], mx = 0, jj; maybelong *tmp = NULL, **f = NULL, *g = NULL; char *pi, *pf; - Float64 *sampling = sampling_arr ? NA_OFFSETDATA(sampling_arr) : NULL; + Float64 *sampling = sampling_arr ? ((void *)PyArray_DATA(sampling_arr)) : NULL; - pi = NA_OFFSETDATA(input); - pf = NA_OFFSETDATA(features); + pi = (void *)PyArray_DATA(input); + pf = (void *)PyArray_DATA(features); for(ii = 0; ii < input->nd; ii++) { coor[ii] = 0; if (input->dimensions[ii] > mx) @@ -936,9 +936,9 @@ PyErr_NoMemory(); goto exit; } - for(jj = 0; jj < mx; jj++) + for(jj = 0; jj < mx; jj++) f[jj] = tmp + jj * input->nd; - + /* First call of recursive feature transform */ _ComputeFT(pi, pf, input->dimensions, input->strides, features->strides, input->nd, input->nd - 1, coor, f, g, features, sampling); @@ -950,6 +950,6 @@ free(g); if (tmp) free(tmp); - + return PyErr_Occurred() ? 0 : 1; } Modified: trunk/Lib/ndimage/src/ni_support.c =================================================================== --- trunk/Lib/ndimage/src/ni_support.c 2007-03-28 21:54:24 UTC (rev 2885) +++ trunk/Lib/ndimage/src/ni_support.c 2007-03-29 09:20:23 UTC (rev 2886) @@ -2,7 +2,7 @@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions - * are met: + * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. @@ -15,7 +15,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -26,7 +26,7 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "ni_support.h" @@ -45,7 +45,7 @@ /* initialize strides: */ iterator->strides[ii] = array->strides[ii]; /* calculate the strides to move back at the end of an axis: */ - iterator->backstrides[ii] = + iterator->backstrides[ii] = array->strides[ii] * iterator->dimensions[ii]; } return 1; @@ -56,7 +56,7 @@ int NI_SubspaceIterator(NI_Iterator *iterator, UInt32 axes) { int ii, last = 0; - + for(ii = 0; ii <= iterator->rank_m1; ii++) { if (axes & (((UInt32)1) << ii)) { if (last != ii) { @@ -84,7 +84,7 @@ /******************************************************************/ /* Allocate line buffer data */ -int NI_AllocateLineBuffer(PyArrayObject* array, int axis, maybelong size1, +int NI_AllocateLineBuffer(PyArrayObject* array, int axis, maybelong size1, maybelong size2, maybelong *lines, maybelong max_size, double **buffer) { maybelong line_size, max_lines; @@ -104,7 +104,7 @@ from the maximum size allowed: */ if (*lines < 1) { *lines = line_size > 0 ? max_size / line_size : 0; - if (*lines < 1) + if (*lines < 1) *lines = 1; } /* no need to allocate too many lines: */ @@ -120,13 +120,13 @@ } /* Initialize a line buffer */ -int NI_InitLineBuffer(PyArrayObject *array, int axis, maybelong size1, +int NI_InitLineBuffer(PyArrayObject *array, int axis, maybelong size1, maybelong size2, maybelong buffer_lines, double *buffer_data, NI_ExtendMode extend_mode, double extend_value, NI_LineBuffer *buffer) { maybelong line_length = 0, array_lines = 0, size; int ii; - + size = 1; for(ii = 0; ii < array->nd; ii++) size *= array->dimensions[ii]; @@ -144,7 +144,7 @@ if (line_length > 0) array_lines = line_length > 0 ? size / line_length : 1; /* initialize the buffer structure: */ - buffer->array_data = NA_OFFSETDATA(array); + buffer->array_data = (void *)PyArray_DATA(array); buffer->buffer_data = buffer_data; buffer->buffer_lines = buffer_lines; buffer->array_type = array->descr->type_num; @@ -160,7 +160,7 @@ } /* Extend a line in memory to implement boundary conditions: */ -int NI_ExtendLine(double *line, maybelong length, maybelong size1, +int NI_ExtendLine(double *line, maybelong length, maybelong size1, maybelong size2, NI_ExtendMode mode, double constant_value) { maybelong ii, jj, length1, nextend, rextend; @@ -174,25 +174,25 @@ l2 = line; for(ii = 0; ii < rextend; ii++) *l2++ = *l1++; - for(ii = 0; ii < nextend; ii++) { + for(ii = 0; ii < nextend; ii++) { l1 = line + size1; for(jj = 0; jj < length; jj++) *l2++ = *l1++; - } - nextend = size2 / length; - rextend = size2 - nextend * length; - l1 = line + size1; - l2 = line + size1 + length; - for(ii = 0; ii < nextend; ii++) { - l3 = l1; + } + nextend = size2 / length; + rextend = size2 - nextend * length; + l1 = line + size1; + l2 = line + size1 + length; + for(ii = 0; ii < nextend; ii++) { + l3 = l1; for(jj = 0; jj < length; jj++) *l2++ = *l3++; - } + } for(ii = 0; ii < rextend; ii++) *l2++ = *l1++; break; case NI_EXTEND_MIRROR: - if (length == 1) { + if (length == 1) { l1 = line; val = line[size1]; for(ii = 0; ii < size1; ii++) @@ -201,58 +201,58 @@ val = line[size1 + length - 1]; for(ii = 0; ii < size2; ii++) *l1++ = val; - } else { - length1 = length - 1; - nextend = size1 / length1; - rextend = size1 - nextend * length1; - l1 = line + size1 + 1; - l2 = l1 - 2; - for(ii = 0; ii < nextend; ii++) { - l3 = l1; + } else { + length1 = length - 1; + nextend = size1 / length1; + rextend = size1 - nextend * length1; + l1 = line + size1 + 1; + l2 = l1 - 2; + for(ii = 0; ii < nextend; ii++) { + l3 = l1; for(jj = 0; jj < length1; jj++) *l2-- = *l3++; - l1 -= length1; - } + l1 -= length1; + } for(ii = 0; ii < rextend; ii++) *l2-- = *l1++; - nextend = size2 / length1; - rextend = size2 - nextend * length1; - l1 = line + size1 + length1 - 1; - l2 = l1 + 2; - for(ii = 0; ii < nextend; ii++) { - l3 = l1; - for(jj = 0; jj < length1; jj++) + nextend = size2 / length1; + rextend = size2 - nextend * length1; + l1 = line + size1 + length1 - 1; + l2 = l1 + 2; + for(ii = 0; ii < nextend; ii++) { + l3 = l1; + for(jj = 0; jj < length1; jj++) *l2++ = *l3--; - l1 += length1; - } + l1 += length1; + } for(ii = 0; ii < rextend; ii++) *l2++ = *l1--; } break; case NI_EXTEND_REFLECT: - nextend = size1 / length; - rextend = size1 - nextend * length; - l1 = line + size1; - l2 = l1 - 1; - for(ii = 0; ii < nextend; ii++) { - l3 = l1; + nextend = size1 / length; + rextend = size1 - nextend * length; + l1 = line + size1; + l2 = l1 - 1; + for(ii = 0; ii < nextend; ii++) { + l3 = l1; for(jj = 0; jj < length; jj++) *l2-- = *l3++; - l1 -= length; - } - l3 = l1; + l1 -= length; + } + l3 = l1; for(ii = 0; ii < rextend; ii++) *l2-- = *l3++; - nextend = size2 / length; - rextend = size2 - nextend * length; - l1 = line + size1 + length - 1; - l2 = l1 + 1; - for(ii = 0; ii < nextend; ii++) { - l3 = l1; + nextend = size2 / length; + rextend = size2 - nextend * length; + l1 = line + size1 + length - 1; + l2 = l1 + 1; + for(ii = 0; ii < nextend; ii++) { + l3 = l1; for(jj = 0; jj < length; jj++) *l2++ = *l3--; - l1 += length; - } + l1 += length; + } for(ii = 0; ii < rextend; ii++) *l2++ = *l1--; break; @@ -260,19 +260,19 @@ l1 = line; val = line[size1]; for(ii = 0; ii < size1; ii++) - *l1++ = val; - l1 = line + size1 + length; + *l1++ = val; + l1 = line + size1 + length; val = line[size1 + length - 1]; - for(ii = 0; ii < size2; ii++) + for(ii = 0; ii < size2; ii++) *l1++ = val; break; case NI_EXTEND_CONSTANT: l1 = line; for(ii = 0; ii < size1; ii++) - *l1++ = constant_value; - l1 = line + size1 + length; - for(ii = 0; ii < size2; ii++) *l1++ = constant_value; + l1 = line + size1 + length; + for(ii = 0; ii < size2; ii++) + *l1++ = constant_value; break; default: PyErr_SetString(PyExc_RuntimeError, "mode not supported"); @@ -291,7 +291,7 @@ _pi += _stride; \ } \ } \ -break +break /* Copy a line from an array to a buffer: */ @@ -332,14 +332,14 @@ NI_ITERATOR_NEXT(buffer->iterator, buffer->array_data); /* implement boundary conditions to the line: */ if (buffer->size1 + buffer->size2 > 0) - if (!NI_ExtendLine(pb - buffer->size1, length, buffer->size1, - buffer->size2, buffer->extend_mode, + if (!NI_ExtendLine(pb - buffer->size1, length, buffer->size1, + buffer->size2, buffer->extend_mode, buffer->extend_value)) return 0; /* The number of the array lines copied: */ ++(buffer->next_line); /* keep track of (and return) the number of lines in the buffer: */ - ++(*number_of_lines); + ++(*number_of_lines); pb += buffer->line_length + buffer->size1 + buffer->size2; } /* if not all array lines were processed, *more is set true: */ @@ -405,7 +405,7 @@ /******************************************************************/ /* Initialize a filter iterator: */ -int +int NI_InitFilterIterator(int rank, maybelong *filter_shape, maybelong filter_size, maybelong *array_shape, maybelong *origins, NI_FilterIterator *iterator) @@ -428,7 +428,7 @@ } } for(ii = 0; ii < rank; ii++) { - maybelong step = array_shape[ii] < fshape[ii] ? + maybelong step = array_shape[ii] < fshape[ii] ? array_shape[ii] : fshape[ii]; maybelong orgn = fshape[ii] / 2 + forigins[ii]; /* stride for stepping back to previous offsets: */ @@ -452,7 +452,7 @@ maybelong max_stride = 0, *ashape = NULL, *astrides = NULL; maybelong footprint_size = 0, coordinates[MAXDIM], position[MAXDIM]; maybelong fshape[MAXDIM], forigins[MAXDIM], *po, *pc = NULL; - + rank = array->nd; ashape = array->dimensions; astrides = array->strides; @@ -466,7 +466,7 @@ /* calculate the number of non-zero elements in the footprint: */ if (footprint) { for(kk = 0; kk < filter_size; kk++) - if (footprint[kk]) + if (footprint[kk]) ++footprint_size; } else { footprint_size = filter_size; @@ -482,7 +482,7 @@ goto exit; } if (coordinate_offsets) { - *coordinate_offsets = (maybelong*)malloc(offsets_size * rank * + *coordinate_offsets = (maybelong*)malloc(offsets_size * rank * footprint_size * sizeof(maybelong)); if (!*coordinate_offsets) { PyErr_NoMemory(); @@ -503,10 +503,10 @@ /* keep track of the kernel position: */ position[ii] = 0; } - /* the flag to indicate that we are outside the border must have a + /* the flag to indicate that we are outside the border must have a value that is larger than any possible offset: */ *border_flag_value = max_size * max_stride + 1; - /* calculate all possible offsets to elements in the filter kernel, + /* calculate all possible offsets to elements in the filter kernel, for all regions in the array (interior and border regions): */ po = *offsets; if (coordinate_offsets) { @@ -518,7 +518,7 @@ for(kk = 0; kk < filter_size; kk++) { maybelong offset = 0; /* only calculate an offset if the footprint is 1: */ - if (!footprint || footprint[kk]) { + if (!footprint || footprint[kk]) { /* find offsets along all axes: */ for(ii = 0; ii < rank; ii++) { maybelong orgn = fshape[ii] / 2 + forigins[ii]; @@ -572,7 +572,7 @@ cc = 0; } else { int sz = len; - cc += sz * (int)(-cc / sz); + cc += sz * (int)(-cc / sz); if (cc < 0) cc += sz; } @@ -581,7 +581,7 @@ cc = 0; } else { int sz = len; - cc -= sz * (int)(cc / sz); + cc -= sz * (int)(cc / sz); } } break; @@ -633,7 +633,7 @@ } } } - + /* move to the next array region: */ for(ii = rank - 1; ii >= 0; ii--) { int orgn = fshape[ii] / 2 + forigins[ii]; @@ -651,7 +651,7 @@ } } } - + exit: if (PyErr_Occurred()) { if (*offsets) @@ -678,7 +678,7 @@ return list; } -int NI_CoordinateListStealBlocks(NI_CoordinateList *list1, +int NI_CoordinateListStealBlocks(NI_CoordinateList *list1, NI_CoordinateList *list2) { if (list1->block_size != list2->block_size || @@ -703,7 +703,7 @@ PyErr_NoMemory(); goto exit; } - block->coordinates = (maybelong*)malloc(list->block_size * list->rank * + block->coordinates = (maybelong*)malloc(list->block_size * list->rank * sizeof(maybelong)); if (!block->coordinates) { PyErr_NoMemory(); @@ -712,7 +712,7 @@ block->next = list->blocks; list->blocks = block; block->size = 0; - + exit: if (PyErr_Occurred()) { if (block) @@ -727,7 +727,7 @@ NI_CoordinateBlock* block = list->blocks; if (block) { list->blocks = block->next; - if (block->coordinates) + if (block->coordinates) free(block->coordinates); free(block); } Modified: trunk/Lib/ndimage/src/ni_support.h =================================================================== --- trunk/Lib/ndimage/src/ni_support.h 2007-03-28 21:54:24 UTC (rev 2885) +++ trunk/Lib/ndimage/src/ni_support.h 2007-03-29 09:20:23 UTC (rev 2886) @@ -2,7 +2,7 @@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions - * are met: + * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. @@ -15,7 +15,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -26,7 +26,7 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef NI_SUPPORT_H @@ -154,7 +154,7 @@ /******************************************************************/ /* the linebuffer structure: */ -typedef struct { +typedef struct { double *buffer_data; maybelong buffer_lines, line_length, line_stride; maybelong size1, size2, array_lines, next_line; @@ -174,7 +174,7 @@ maybelong*, maybelong, double**); /* Initialize a line buffer */ -int NI_InitLineBuffer(PyArrayObject*, int, maybelong, maybelong, maybelong, +int NI_InitLineBuffer(PyArrayObject*, int, maybelong, maybelong, maybelong, double*, NI_ExtendMode, double, NI_LineBuffer*); /* Extend a line in memory to implement boundary conditions: */ From scipy-svn at scipy.org Thu Mar 29 05:52:07 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 29 Mar 2007 04:52:07 -0500 (CDT) Subject: [Scipy-svn] r2887 - trunk/Lib/ndimage/src Message-ID: <20070329095207.20D63C7C01B@new.scipy.org> Author: stefan Date: 2007-03-29 04:51:45 -0500 (Thu, 29 Mar 2007) New Revision: 2887 Modified: trunk/Lib/ndimage/src/nd_image.h trunk/Lib/ndimage/src/ni_interpolation.c Log: Re-enable 64-bit computations in ndimage. Modified: trunk/Lib/ndimage/src/nd_image.h =================================================================== --- trunk/Lib/ndimage/src/nd_image.h 2007-03-29 09:20:23 UTC (rev 2886) +++ trunk/Lib/ndimage/src/nd_image.h 2007-03-29 09:51:45 UTC (rev 2887) @@ -40,6 +40,8 @@ typedef npy_intp maybelong; #define MAXDIM NPY_MAXDIMS +#define HAS_UINT64 1 + typedef enum { tAny=-1, Modified: trunk/Lib/ndimage/src/ni_interpolation.c =================================================================== --- trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-29 09:20:23 UTC (rev 2886) +++ trunk/Lib/ndimage/src/ni_interpolation.c 2007-03-29 09:51:45 UTC (rev 2887) @@ -610,7 +610,8 @@ CASE_INTERP_OUT_UINT(po, t, UInt16, 0, MAX_UINT16); CASE_INTERP_OUT_UINT(po, t, UInt32, 0, MAX_UINT32); #if HAS_UINT64 - CASE_INTERP_OUT_UINT(po, t, UInt64); + /* FIXME */ + CASE_INTERP_OUT_UINT(po, t, UInt64, 0, MAX_UINT32); #endif CASE_INTERP_OUT_INT(po, t, Int8, MIN_INT8, MAX_INT8); CASE_INTERP_OUT_INT(po, t, Int16, MIN_INT16, MAX_INT16); @@ -904,7 +905,8 @@ CASE_INTERP_OUT_UINT(po, t, UInt16, 0, MAX_UINT16); CASE_INTERP_OUT_UINT(po, t, UInt32, 0, MAX_UINT32); #if HAS_UINT64 - CASE_INTERP_OUT_UINT(po, t, UInt64, 0, MAX_UINT64); + /* FIXME */ + CASE_INTERP_OUT_UINT(po, t, UInt64, 0, MAX_UINT32); #endif CASE_INTERP_OUT_INT(po, t, Int8, MIN_INT8, MAX_INT8); CASE_INTERP_OUT_INT(po, t, Int16, MIN_INT16, MAX_INT16); From scipy-svn at scipy.org Thu Mar 29 06:10:23 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 29 Mar 2007 05:10:23 -0500 (CDT) Subject: [Scipy-svn] r2888 - trunk/Lib/ndimage/src Message-ID: <20070329101023.1305539C042@new.scipy.org> Author: stefan Date: 2007-03-29 05:10:07 -0500 (Thu, 29 Mar 2007) New Revision: 2888 Modified: trunk/Lib/ndimage/src/nd_image.h trunk/Lib/ndimage/src/ni_fourier.c Log: Fix complex handling. Modified: trunk/Lib/ndimage/src/nd_image.h =================================================================== --- trunk/Lib/ndimage/src/nd_image.h 2007-03-29 09:51:45 UTC (rev 2887) +++ trunk/Lib/ndimage/src/nd_image.h 2007-03-29 10:10:07 UTC (rev 2888) @@ -56,8 +56,8 @@ tUInt64=PyArray_UINT64, tFloat32=PyArray_FLOAT32, tFloat64=PyArray_FLOAT64, - tComplex32=PyArray_COMPLEX64, - tComplex64=PyArray_COMPLEX128, + tComplex64=PyArray_COMPLEX64, + tComplex128=PyArray_COMPLEX128, tObject=PyArray_OBJECT, /* placeholder... does nothing */ tMaxType=PyArray_NTYPES, tDefault = tFloat64, Modified: trunk/Lib/ndimage/src/ni_fourier.c =================================================================== --- trunk/Lib/ndimage/src/ni_fourier.c 2007-03-29 09:51:45 UTC (rev 2887) +++ trunk/Lib/ndimage/src/ni_fourier.c 2007-03-29 10:10:07 UTC (rev 2888) @@ -359,19 +359,19 @@ default: break; } - if (input->descr->type_num == tComplex32 || - input->descr->type_num == tComplex64) { + if (input->descr->type_num == tComplex64 || + input->descr->type_num == tComplex128) { double tmp_r = 0.0, tmp_i = 0.0; switch (input->descr->type_num) { - /*CASE_FOURIER_FILTER_RC(pi, tmp, tmp_r, tmp_i, Complex32);*/ CASE_FOURIER_FILTER_RC(pi, tmp, tmp_r, tmp_i, Complex64); + CASE_FOURIER_FILTER_RC(pi, tmp, tmp_r, tmp_i, Complex128); default: PyErr_SetString(PyExc_RuntimeError, "data type not supported"); goto exit; } switch (output->descr->type_num) { - /*CASE_FOURIER_OUT_CC(po, tmp_r, tmp_i, Complex32);*/ CASE_FOURIER_OUT_CC(po, tmp_r, tmp_i, Complex64); + CASE_FOURIER_OUT_CC(po, tmp_r, tmp_i, Complex128); default: PyErr_SetString(PyExc_RuntimeError, "data type not supported"); goto exit; @@ -398,8 +398,8 @@ switch (output->descr->type_num) { CASE_FOURIER_OUT_RR(po, tmp, Float32); CASE_FOURIER_OUT_RR(po, tmp, Float64); - /*CASE_FOURIER_OUT_RC(po, tmp, Complex32);*/ CASE_FOURIER_OUT_RC(po, tmp, Complex64); + CASE_FOURIER_OUT_RC(po, tmp, Complex128); default: PyErr_SetString(PyExc_RuntimeError, "data type not supported"); goto exit; @@ -521,15 +521,15 @@ CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Int64) CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Float32) CASE_FOURIER_SHIFT_R(pi, tmp, r, i, cost, sint, Float64) - /*CASE_FOURIER_SHIFT_C(pi, r, i, cost, sint, Complex32)*/ CASE_FOURIER_SHIFT_C(pi, r, i, cost, sint, Complex64) + CASE_FOURIER_SHIFT_C(pi, r, i, cost, sint, Complex128) default: PyErr_SetString(PyExc_RuntimeError, "data type not supported"); goto exit; } switch (output->descr->type_num) { - /*CASE_FOURIER_OUT_CC(po, r, i, Complex32);*/ CASE_FOURIER_OUT_CC(po, r, i, Complex64); + CASE_FOURIER_OUT_CC(po, r, i, Complex128); default: PyErr_SetString(PyExc_RuntimeError, "data type not supported"); goto exit; From scipy-svn at scipy.org Thu Mar 29 08:07:16 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 29 Mar 2007 07:07:16 -0500 (CDT) Subject: [Scipy-svn] r2889 - trunk/Lib/ndimage/src Message-ID: <20070329120716.792C139C041@new.scipy.org> Author: stefan Date: 2007-03-29 07:07:01 -0500 (Thu, 29 Mar 2007) New Revision: 2889 Modified: trunk/Lib/ndimage/src/nd_image.c Log: Fix memory errors. Modified: trunk/Lib/ndimage/src/nd_image.c =================================================================== --- trunk/Lib/ndimage/src/nd_image.c 2007-03-29 10:10:07 UTC (rev 2888) +++ trunk/Lib/ndimage/src/nd_image.c 2007-03-29 12:07:01 UTC (rev 2889) @@ -270,8 +270,8 @@ double *po = NULL; NI_PythonCallbackData *cbdata = (NI_PythonCallbackData*)data; - py_ibuffer = NA_NewArray(iline, PyArray_DOUBLE, 1, (int)ilen); - py_obuffer = NA_NewArray(NULL, PyArray_DOUBLE, 1, (int)olen); + py_ibuffer = NA_NewArray(iline, PyArray_DOUBLE, 1, &ilen); + py_obuffer = NA_NewArray(NULL, PyArray_DOUBLE, 1, &olen); if (!py_ibuffer || !py_obuffer) goto exit; tmp = Py_BuildValue("(OO)", py_ibuffer, py_obuffer); @@ -348,7 +348,7 @@ PyObject *rv = NULL, *args = NULL, *tmp = NULL; NI_PythonCallbackData *cbdata = (NI_PythonCallbackData*)data; - py_buffer = NA_NewArray(buffer, PyArray_DOUBLE, 1, filter_size); + py_buffer = NA_NewArray(buffer, PyArray_DOUBLE, 1, &filter_size); if (!py_buffer) goto exit; tmp = Py_BuildValue("(O)", py_buffer); @@ -1095,7 +1095,7 @@ goto exit; } for(jj = 0; jj < n_results; jj++) { - histograms[jj] = NA_NewArray(NULL, tInt32, 1, nbins); + histograms[jj] = NA_NewArray(NULL, tInt32, 1, &nbins); if (!histograms[jj]) { PyErr_NoMemory(); goto exit; From scipy-svn at scipy.org Thu Mar 29 08:36:58 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 29 Mar 2007 07:36:58 -0500 (CDT) Subject: [Scipy-svn] r2890 - in trunk/Lib/ndimage: . tests Message-ID: <20070329123658.96EE6C7C04D@new.scipy.org> Author: stefan Date: 2007-03-29 07:36:36 -0500 (Thu, 29 Mar 2007) New Revision: 2890 Modified: trunk/Lib/ndimage/_ni_support.py trunk/Lib/ndimage/tests/test_ndimage.py Log: Add boundary tests. Enable 'mirror' mode. Modified: trunk/Lib/ndimage/_ni_support.py =================================================================== --- trunk/Lib/ndimage/_ni_support.py 2007-03-29 12:07:01 UTC (rev 2889) +++ trunk/Lib/ndimage/_ni_support.py 2007-03-29 12:36:36 UTC (rev 2890) @@ -40,6 +40,8 @@ return 1 elif mode == 'reflect': return 2 + elif mode == 'mirror': + return 3 elif mode == 'constant': return 4 else: Modified: trunk/Lib/ndimage/tests/test_ndimage.py =================================================================== --- trunk/Lib/ndimage/tests/test_ndimage.py 2007-03-29 12:07:01 UTC (rev 2889) +++ trunk/Lib/ndimage/tests/test_ndimage.py 2007-03-29 12:36:36 UTC (rev 2890) @@ -70,8 +70,6 @@ numpy.uint16, numpy.int32, numpy.uint32, numpy.int64, numpy.uint64, numpy.float32, numpy.float64] -## if numinclude.hasUInt64: -## self.types.append(numpy.UInt64) # list of boundary modes: self.modes = ['nearest', 'wrap', 'reflect', 'constant'] @@ -1296,6 +1294,24 @@ mode = mode, cval = 0) self.failUnless(diff(output, true_value) < eps) + def test_boundaries(self): + "boundary modes" + def shift(x): + return (x[0] + 0.1,) + + data = numpy.array([1,2,3,4]) + expected = {'constant': [1,2,3,-1,-1,-1], + 'wrap': [1,2,3,4,1,2], + 'reflect' : [1,2,3,4,4,3], + 'mirror' : [1,2,3,4,3,2], + 'nearest' : [1,2,3,4,4,4]} + + for mode in expected.keys(): + assert_array_equal(expected[mode], + ndimage.geometric_transform(data,shift, + cval=-1,mode=mode, + output_shape=(6,))) + def test_fourier_gaussian_real01(self): "gaussian fourier filter for real transforms 1" for shape in [(32, 16), (31, 15)]: From scipy-svn at scipy.org Thu Mar 29 09:05:55 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 29 Mar 2007 08:05:55 -0500 (CDT) Subject: [Scipy-svn] r2891 - trunk/Lib/ndimage/src Message-ID: <20070329130555.303DD39C11E@new.scipy.org> Author: stefan Date: 2007-03-29 08:05:42 -0500 (Thu, 29 Mar 2007) New Revision: 2891 Modified: trunk/Lib/ndimage/src/nd_image.h Log: Fix compiler warnings. Modified: trunk/Lib/ndimage/src/nd_image.h =================================================================== --- trunk/Lib/ndimage/src/nd_image.h 2007-03-29 12:36:36 UTC (rev 2890) +++ trunk/Lib/ndimage/src/nd_image.h 2007-03-29 13:05:42 UTC (rev 2891) @@ -33,14 +33,15 @@ #define ND_IMAGE_H #include "Python.h" -#include -#define NI_MAXDIM NPY_MAXDIMS +#ifndef ND_IMPORT_ARRAY +#define NO_IMPORT_ARRAY +#endif -typedef npy_intp maybelong; -#define MAXDIM NPY_MAXDIMS +#include +#undef NO_IMPORT_ARRAY -#define HAS_UINT64 1 +/* Eventually get rid of everything below this line */ typedef enum { @@ -68,6 +69,39 @@ #endif } NumarrayType; +#define NI_MAXDIM NPY_MAXDIMS + +typedef npy_intp maybelong; +#define MAXDIM NPY_MAXDIMS + +#define HAS_UINT64 1 + + + +#ifdef ND_IMPORT_ARRAY + +/* Numarray Helper Functions */ + +static PyArrayObject* +NA_InputArray(PyObject *a, NumarrayType t, int requires) +{ + PyArray_Descr *descr; + if (t == tAny) descr = NULL; + else descr = PyArray_DescrFromType(t); + return (PyArrayObject *) \ + PyArray_CheckFromAny(a, descr, 0, 0, requires, NULL); +} + +static unsigned long +NA_elements(PyArrayObject *a) +{ + int i; + unsigned long n = 1; + for(i = 0; ind; i++) + n *= a->dimensions[i]; + return n; +} + /* satisfies ensures that 'a' meets a set of requirements and matches the specified type. */ @@ -91,16 +125,6 @@ return type_ok; } -static PyArrayObject* -NA_InputArray(PyObject *a, NumarrayType t, int requires) -{ - PyArray_Descr *descr; - if (t == tAny) descr = NULL; - else descr = PyArray_DescrFromType(t); - return (PyArrayObject *) \ - PyArray_CheckFromAny(a, descr, 0, 0, requires, NULL); -} - static PyArrayObject * NA_OutputArray(PyObject *a, NumarrayType t, int requires) { @@ -161,16 +185,6 @@ return shadow; } -static unsigned long -NA_elements(PyArrayObject *a) -{ - int i; - unsigned long n = 1; - for(i = 0; ind; i++) - n *= a->dimensions[i]; - return n; -} - #define NUM_LITTLE_ENDIAN 0 #define NUM_BIG_ENDIAN 1 @@ -275,11 +289,12 @@ NA_ByteOrder(), 1, 1); } - -#define NA_InputArray (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) (void *) NA_InputArray) #define NA_OutputArray (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) (void *) NA_OutputArray) #define NA_IoArray (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) (void *) NA_IoArray) +#define NA_NewArray (*(PyArrayObject* (*) (void* buffer, NumarrayType type, int ndim, ...) ) (void *) NA_NewArray ) #define NA_elements (*(unsigned long (*) (PyArrayObject*) ) (void *) NA_elements) -#define NA_NewArray (*(PyArrayObject* (*) (void* buffer, NumarrayType type, int ndim, ...) ) (void *) NA_NewArray ) +#define NA_InputArray (*(PyArrayObject* (*) (PyObject*,NumarrayType,int) ) (void *) NA_InputArray) -#endif +#endif /* ND_IMPORT_ARRAY */ + +#endif /* ND_IMAGE_H */ From scipy-svn at scipy.org Thu Mar 29 15:08:17 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Thu, 29 Mar 2007 14:08:17 -0500 (CDT) Subject: [Scipy-svn] r2892 - in trunk/Lib/sandbox/maskedarray: . tests Message-ID: <20070329190817.C74FA39C24E@new.scipy.org> Author: pierregm Date: 2007-03-29 14:08:14 -0500 (Thu, 29 Mar 2007) New Revision: 2892 Modified: trunk/Lib/sandbox/maskedarray/core.py trunk/Lib/sandbox/maskedarray/tests/test_core.py Log: core : prevents collapsing an array to masked when all the data are masked Modified: trunk/Lib/sandbox/maskedarray/core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/core.py 2007-03-29 13:05:42 UTC (rev 2891) +++ trunk/Lib/sandbox/maskedarray/core.py 2007-03-29 19:08:14 UTC (rev 2892) @@ -1067,6 +1067,7 @@ """Special hook for ufuncs. Wraps the numpy array and sets the mask according to context. """ + #TODO : Should we check for type result result = obj.view(type(self)) #.......... if context is not None: @@ -1085,11 +1086,15 @@ m = d else: m |= d - result._mask = m - if (not m.ndim) and m: - return masked + if not m.ndim and m: + if m: + if result.shape == (): + return masked + result._mask = numeric.ones(result.shape, bool_) + else: + result._mask = m #.... - result._mask = m +# result._mask = m result._fill_value = self._fill_value result._hardmask = self._hardmask result._smallmask = self._smallmask @@ -2626,33 +2631,42 @@ from maskedarray.testutils import assert_equal, assert_array_equal marray = masked_array # - if 0: - a = arange(10) - a[::3] = masked - a.fill_value = 999 - a_pickled = cPickle.loads(a.dumps()) - assert_equal(a_pickled._mask, a._mask) - assert_equal(a_pickled._data, a._data) - assert_equal(a_pickled.fill_value, 999) - # - a = array(numpy.matrix(range(10)), mask=[1,0,1,0,0]*2) - a_pickled = cPickle.loads(a.dumps()) - assert_equal(a_pickled._mask, a._mask) - assert_equal(a_pickled, a) - assert(isinstance(a_pickled._data,numpy.matrix)) - # - - # if 1: - x = marray(numpy.linspace(-1.,1.,31),) - x[:10] = x[-10:] = masked - z = marray(numpy.empty((len(x),3), dtype=numpy.float_)) - z[:,0] = x[:] - for i in range(1,3): - idx = numpy.arange(len(x)) - numpy.random.shuffle(idx) - z[:,i] = x[idx] - # - z.sort(0) - + x = masked_array([1,2]) + y = x * masked + print y + assert_equal(y.shape, x.shape) + assert_equal(y._mask, [True, True]) + y = x + masked + assert_equal(y.shape, x.shape) + assert_equal(y._mask, [True, True]) +# if 0: +# a = arange(10) +# a[::3] = masked +# a.fill_value = 999 +# a_pickled = cPickle.loads(a.dumps()) +# assert_equal(a_pickled._mask, a._mask) +# assert_equal(a_pickled._data, a._data) +# assert_equal(a_pickled.fill_value, 999) +# # +# a = array(numpy.matrix(range(10)), mask=[1,0,1,0,0]*2) +# a_pickled = cPickle.loads(a.dumps()) +# assert_equal(a_pickled._mask, a._mask) +# assert_equal(a_pickled, a) +# assert(isinstance(a_pickled._data,numpy.matrix)) +# # +# +# # +# if 1: +# x = marray(numpy.linspace(-1.,1.,31),) +# x[:10] = x[-10:] = masked +# z = marray(numpy.empty((len(x),3), dtype=numpy.float_)) +# z[:,0] = x[:] +# for i in range(1,3): +# idx = numpy.arange(len(x)) +# numpy.random.shuffle(idx) +# z[:,i] = x[idx] +# # +# z.sort(0) +# Modified: trunk/Lib/sandbox/maskedarray/tests/test_core.py =================================================================== --- trunk/Lib/sandbox/maskedarray/tests/test_core.py 2007-03-29 13:05:42 UTC (rev 2891) +++ trunk/Lib/sandbox/maskedarray/tests/test_core.py 2007-03-29 19:08:14 UTC (rev 2892) @@ -612,6 +612,17 @@ #self.failUnlessRaises(Exception, lambda x,y: x+y, masked, xx) #self.failUnlessRaises(Exception, lambda x,y: x+y, xx, masked) #........................ + def check_usingmasked(self): + "Checks that there's no collapsing to masked" + x = masked_array([1,2]) + y = x * masked + assert_equal(y.shape, x.shape) + assert_equal(y._mask, [True, True]) + y = x + masked + assert_equal(y.shape, x.shape) + assert_equal(y._mask, [True, True]) + + #........................ def check_topython(self): "Tests some communication issues with Python." assert_equal(1, int(array(1))) From scipy-svn at scipy.org Sat Mar 31 03:53:00 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 31 Mar 2007 02:53:00 -0500 (CDT) Subject: [Scipy-svn] r2893 - trunk/Lib/io Message-ID: <20070331075300.42D1839C044@new.scipy.org> Author: oliphant Date: 2007-03-31 02:52:54 -0500 (Sat, 31 Mar 2007) New Revision: 2893 Modified: trunk/Lib/io/mio5.py Log: Fix mio5 for new behavior of rank-0 record arrays. Modified: trunk/Lib/io/mio5.py =================================================================== --- trunk/Lib/io/mio5.py 2007-03-29 19:08:14 UTC (rev 2892) +++ trunk/Lib/io/mio5.py 2007-03-31 07:52:54 UTC (rev 2893) @@ -157,7 +157,7 @@ tag = N.ndarray(shape=(), dtype=self.dtypes['tag_full'], buffer = raw_tag) - mdtype = tag['mdtype'] + mdtype = tag['mdtype'].item() byte_count = mdtype >> 16 if byte_count: # small data element format if byte_count > 4: @@ -168,7 +168,7 @@ return N.ndarray(shape=(el_count,), dtype=dt, buffer=raw_tag[4:]) - byte_count = tag['byte_count'] + byte_count = tag['byte_count'].item() if mdtype == miMATRIX: return self.current_getter(byte_count).get_array() if mdtype in self.codecs: # encoded char data @@ -193,8 +193,8 @@ def matrix_getter_factory(self): ''' Returns reader for next matrix at top level ''' tag = self.read_dtype(self.dtypes['tag_full']) - mdtype = tag['mdtype'] - byte_count = tag['byte_count'] + mdtype = tag['mdtype'].item() + byte_count = tag['byte_count'].item() next_pos = self.mat_stream.tell() + byte_count if mdtype == miCOMPRESSED: getter = Mat5ZArrayReader(self, byte_count).matrix_getter_factory() @@ -506,7 +506,7 @@ ''' Read in mat 5 file header ''' hdict = {} hdr = self.read_dtype(self.dtypes['file_header']) - hdict['__header__'] = hdr['description'].strip(' \t\n\000') + hdict['__header__'] = hdr['description'].item().strip(' \t\n\000') v_major = hdr['version'] >> 8 v_minor = hdr['version'] & 0xFF hdict['__version__'] = '%d.%d' % (v_major, v_minor) From scipy-svn at scipy.org Sat Mar 31 03:57:36 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 31 Mar 2007 02:57:36 -0500 (CDT) Subject: [Scipy-svn] r2894 - trunk/Lib/signal Message-ID: <20070331075736.CE0D139C093@new.scipy.org> Author: oliphant Date: 2007-03-31 02:57:28 -0500 (Sat, 31 Mar 2007) New Revision: 2894 Modified: trunk/Lib/signal/signaltools.py Log: Add Dolph-Cheybshev window. Modified: trunk/Lib/signal/signaltools.py =================================================================== --- trunk/Lib/signal/signaltools.py 2007-03-31 07:52:54 UTC (rev 2893) +++ trunk/Lib/signal/signaltools.py 2007-03-31 07:57:28 UTC (rev 2894) @@ -11,9 +11,10 @@ where, sqrt, rank, newaxis, argmax, product, cos, pi, exp, \ ravel, size, less_equal, sum, r_, iscomplexobj, take, \ argsort, allclose, expand_dims, unique, prod, sort, reshape, c_, \ - transpose, dot, any, minimum, maximum, mean + transpose, dot, any, minimum, maximum, mean, cosh, arccosh, \ + arccos import numpy -from scipy.fftpack import fftn, ifftn +from scipy.fftpack import fftn, ifftn, fft from scipy.misc import factorial _modedict = {'valid':0, 'same':1, 'full':2} @@ -830,6 +831,59 @@ return w +# contributed by Kumanna +def chebwin(M, at, sym=1): + """Dolph-Chebyshev window. + + INPUTS: + + M : int + Window size + at : float + Attenuation (in dB) + sym : bool + Generates symmetric window if True. + + """ + if M < 1: + return array([]) + if M == 1: + return ones(1,'d') + + odd = M % 2 + if not sym and not odd: + M = M+1 + + # compute the parameter beta + beta = cosh(1.0/(M-1.0)*arccosh(10**(at/20.))) + k = r_[0:M]*1.0 + x = beta*cos(pi*k/M) + #find the window's DFT coefficients + p = zeros(x.shape) * 1.0 + for i in range(len(x)): + if x[i] < 1: + p[i] = cos((M - 1) * arccos(x[i])) + else: + p[i] = cosh((M - 1) * arccosh(x[i])) + + # Appropriate IDFT and filling up + # depending on even/odd M + if M % 2: + w = real(fft(p)); + n = (M + 1) / 2; + w = w[:n] / w[0]; + w = concatenate((w[n - 1:0:-1], w)) + else: + p = p * exp(1.j*pi / M * r_[0:M]) + w = real(fft(p)); + n = M / 2 + 1; + w = w / w[1]; + w = concatenate((w[n - 1:0:-1], w[1:n])); + if not sym and not odd: + w = w[:-1] + return w + + def slepian(M,width,sym=1): """Return the M-point slepian window. From scipy-svn at scipy.org Sat Mar 31 23:44:57 2007 From: scipy-svn at scipy.org (scipy-svn at scipy.org) Date: Sat, 31 Mar 2007 22:44:57 -0500 (CDT) Subject: [Scipy-svn] r2895 - trunk/Lib/optimize Message-ID: <20070401034457.B1CA9C7C039@new.scipy.org> Author: oliphant Date: 2007-03-31 22:44:55 -0500 (Sat, 31 Mar 2007) New Revision: 2895 Modified: trunk/Lib/optimize/optimize.py Log: Fix input with extra 1's in the shape. Modified: trunk/Lib/optimize/optimize.py =================================================================== --- trunk/Lib/optimize/optimize.py 2007-03-31 07:57:28 UTC (rev 2894) +++ trunk/Lib/optimize/optimize.py 2007-04-01 03:44:55 UTC (rev 2895) @@ -654,7 +654,9 @@ fixed_point -- scalar fixed-point finder """ - x0 = asarray(x0) + x0 = asarray(x0).squeeze() + if x0.ndim == 0: + x0.shape = (1,) if maxiter is None: maxiter = len(x0)*200 func_calls, f = wrap_function(f, args)